Make 'everbody' setting more clear

This commit is contained in:
Eric Bailey
2024-08-05 14:49:08 -05:00
parent cfbcd99552
commit bb912321d6
4 changed files with 9 additions and 12 deletions
+2 -2
View File
@@ -65,7 +65,7 @@ function DialogContent({
}
const onPressEverybody = () => {
updateThreadgate([])
updateThreadgate([{type: 'everybody'}])
}
const onPressNobody = () => {
@@ -102,7 +102,7 @@ function DialogContent({
<View style={[a.flex_row, a.gap_sm]}>
<Selectable
label={_(msg`Everybody`)}
isSelected={draft.length === 0}
isSelected={!!draft.find(v => v.type === 'everybody')}
onPress={onPressEverybody}
style={{flex: 1}}
/>
-2
View File
@@ -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,
+1
View File
@@ -1,4 +1,5 @@
export type ThreadgateAllowUISetting =
| {type: 'everybody'}
| {type: 'nobody'}
| {type: 'mention'}
| {type: 'following'}
+6 -8
View File
@@ -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<AppBskyFeedThreadgate.Record>,