Make 'everbody' setting more clear
This commit is contained in:
@@ -65,7 +65,7 @@ function DialogContent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onPressEverybody = () => {
|
const onPressEverybody = () => {
|
||||||
updateThreadgate([])
|
updateThreadgate([{type: 'everybody'}])
|
||||||
}
|
}
|
||||||
|
|
||||||
const onPressNobody = () => {
|
const onPressNobody = () => {
|
||||||
@@ -102,7 +102,7 @@ function DialogContent({
|
|||||||
<View style={[a.flex_row, a.gap_sm]}>
|
<View style={[a.flex_row, a.gap_sm]}>
|
||||||
<Selectable
|
<Selectable
|
||||||
label={_(msg`Everybody`)}
|
label={_(msg`Everybody`)}
|
||||||
isSelected={draft.length === 0}
|
isSelected={!!draft.find(v => v.type === 'everybody')}
|
||||||
onPress={onPressEverybody}
|
onPress={onPressEverybody}
|
||||||
style={{flex: 1}}
|
style={{flex: 1}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -133,8 +133,6 @@ export async function upsertThreadgate(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the allow list for a threadgate record.
|
* Update the allow list for a threadgate record.
|
||||||
*
|
|
||||||
* Note: to allow everyone to reply, pass `allow: []`.
|
|
||||||
*/
|
*/
|
||||||
export async function updateThreadgateAllow({
|
export async function updateThreadgateAllow({
|
||||||
agent,
|
agent,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export type ThreadgateAllowUISetting =
|
export type ThreadgateAllowUISetting =
|
||||||
|
| {type: 'everybody'}
|
||||||
| {type: 'nobody'}
|
| {type: 'nobody'}
|
||||||
| {type: 'mention'}
|
| {type: 'mention'}
|
||||||
| {type: 'following'}
|
| {type: 'following'}
|
||||||
|
|||||||
@@ -50,14 +50,16 @@ export function threadgateViewToAllowUISetting(
|
|||||||
* Converts an array of {@link ThreadgateAllowUISetting} to the `allow` prop on
|
* Converts an array of {@link ThreadgateAllowUISetting} to the `allow` prop on
|
||||||
* {@link AppBskyFeedThreadgate.Record}.
|
* {@link AppBskyFeedThreadgate.Record}.
|
||||||
*
|
*
|
||||||
* If the array passed is empty, we infer that to mean anyone can reply, and
|
* If the `allow` property on the record is undefined, we infer that to mean
|
||||||
* return undefined. An undefined value in the record is interpretted as anyone
|
* that everyone can reply. If it's an empty array, we infer that to mean that
|
||||||
* can reply, whereas an empty array means no on can reply.
|
* no one can reply.
|
||||||
*/
|
*/
|
||||||
export function threadgateAllowUISettingToAllowRecordValue(
|
export function threadgateAllowUISettingToAllowRecordValue(
|
||||||
threadgate: ThreadgateAllowUISetting[],
|
threadgate: ThreadgateAllowUISetting[],
|
||||||
): AppBskyFeedThreadgate.Record['allow'] {
|
): AppBskyFeedThreadgate.Record['allow'] {
|
||||||
if (threadgate.length === 0) return undefined
|
if (threadgate.find(v => v.type === 'everybody')) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
let allow: (
|
let allow: (
|
||||||
| AppBskyFeedThreadgate.MentionRule
|
| AppBskyFeedThreadgate.MentionRule
|
||||||
@@ -108,10 +110,6 @@ export function mergeThreadgateRecords(
|
|||||||
/**
|
/**
|
||||||
* Create a new {@link AppBskyFeedThreadgate.Record} object with the given
|
* Create a new {@link AppBskyFeedThreadgate.Record} object with the given
|
||||||
* properties.
|
* properties.
|
||||||
*
|
|
||||||
* Note: setting `allow` to `undefined` resets and allows everyone to reply. An
|
|
||||||
* empty array means that no one can reply. This is a bit of a hack bc of how
|
|
||||||
* these were designed, but should be fine as long as we're careful.
|
|
||||||
*/
|
*/
|
||||||
export function createThreadgateRecord(
|
export function createThreadgateRecord(
|
||||||
threadgate: Partial<AppBskyFeedThreadgate.Record>,
|
threadgate: Partial<AppBskyFeedThreadgate.Record>,
|
||||||
|
|||||||
Reference in New Issue
Block a user