diff --git a/src/components/dialogs/ThreadgateEditor.tsx b/src/components/dialogs/ThreadgateEditor.tsx index f529ecc51a..1f9d754e93 100644 --- a/src/components/dialogs/ThreadgateEditor.tsx +++ b/src/components/dialogs/ThreadgateEditor.tsx @@ -65,7 +65,7 @@ function DialogContent({ } const onPressEverybody = () => { - updateThreadgate([]) + updateThreadgate([{type: 'everybody'}]) } const onPressNobody = () => { @@ -102,7 +102,7 @@ function DialogContent({ v.type === 'everybody')} onPress={onPressEverybody} style={{flex: 1}} /> diff --git a/src/state/queries/threadgate/index.ts b/src/state/queries/threadgate/index.ts index ed0643a482..cb63fcce2f 100644 --- a/src/state/queries/threadgate/index.ts +++ b/src/state/queries/threadgate/index.ts @@ -133,8 +133,6 @@ export async function upsertThreadgate( /** * Update the allow list for a threadgate record. - * - * Note: to allow everyone to reply, pass `allow: []`. */ export async function updateThreadgateAllow({ agent, diff --git a/src/state/queries/threadgate/types.ts b/src/state/queries/threadgate/types.ts index 1fed138d37..0cbea311cb 100644 --- a/src/state/queries/threadgate/types.ts +++ b/src/state/queries/threadgate/types.ts @@ -1,4 +1,5 @@ export type ThreadgateAllowUISetting = + | {type: 'everybody'} | {type: 'nobody'} | {type: 'mention'} | {type: 'following'} diff --git a/src/state/queries/threadgate/util.ts b/src/state/queries/threadgate/util.ts index 590c1cdb80..f2b6cff2a2 100644 --- a/src/state/queries/threadgate/util.ts +++ b/src/state/queries/threadgate/util.ts @@ -50,14 +50,16 @@ export function threadgateViewToAllowUISetting( * Converts an array of {@link ThreadgateAllowUISetting} to the `allow` prop on * {@link AppBskyFeedThreadgate.Record}. * - * If the array passed is empty, we infer that to mean anyone can reply, and - * return undefined. An undefined value in the record is interpretted as anyone - * can reply, whereas an empty array means no on can reply. + * If the `allow` property on the record is undefined, we infer that to mean + * that everyone can reply. If it's an empty array, we infer that to mean that + * no one can reply. */ export function threadgateAllowUISettingToAllowRecordValue( threadgate: ThreadgateAllowUISetting[], ): AppBskyFeedThreadgate.Record['allow'] { - if (threadgate.length === 0) return undefined + if (threadgate.find(v => v.type === 'everybody')) { + return undefined + } let allow: ( | AppBskyFeedThreadgate.MentionRule @@ -108,10 +110,6 @@ export function mergeThreadgateRecords( /** * Create a new {@link AppBskyFeedThreadgate.Record} object with the given * 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( threadgate: Partial,