Some renaming

This commit is contained in:
Eric Bailey
2024-08-09 11:37:20 -05:00
parent c4e5782e1e
commit f9e988c5fb
4 changed files with 43 additions and 47 deletions
+15 -15
View File
@@ -65,14 +65,11 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) {
} }
const isEverybody = settings.length === 0 const isEverybody = settings.length === 0
const isNobody = !!settings.find(gate => gate.type === 'nobody')
const description = isEverybody const description = isEverybody
? _(msg`Everybody can reply`) ? _(msg`Anyone can interact`)
: isNobody : _(msg`Interaction limited`)
? _(msg`Replies disabled`)
: _(msg`Some people can reply`)
const onPressEdit = () => { const onPress = () => {
if (isNative && Keyboard.isVisible()) { if (isNative && Keyboard.isVisible()) {
Keyboard.dismiss() Keyboard.dismiss()
} }
@@ -129,7 +126,7 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) {
label={ label={
isThreadAuthor ? _(msg`Edit who can reply`) : _(msg`Who can reply`) isThreadAuthor ? _(msg`Edit who can reply`) : _(msg`Who can reply`)
} }
onPress={isThreadAuthor ? onPressEdit : infoDialogControl.open} onPress={onPress}
hitSlop={HITSLOP_10}> hitSlop={HITSLOP_10}>
{({hovered}) => ( {({hovered}) => (
<View style={[a.flex_row, a.align_center, a.gap_xs, style]}> <View style={[a.flex_row, a.align_center, a.gap_xs, style]}>
@@ -147,22 +144,25 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) {
]}> ]}>
{description} {description}
</Text> </Text>
{isThreadAuthor && ( {isThreadAuthor && (
<PencilLine width={12} fill={t.palette.primary_500} /> <PencilLine width={12} fill={t.palette.primary_500} />
)} )}
</View> </View>
)} )}
</Button> </Button>
<WhoCanReplyDialog
control={infoDialogControl} {isThreadAuthor ? (
post={post}
settings={settings}
/>
{isThreadAuthor && (
<ThreadgateEditorDialog <ThreadgateEditorDialog
control={editDialogControl} control={editDialogControl}
threadgate={settings} threadgateUISettings={settings}
onConfirm={onEditConfirm} onConfirmThreadgateUISettings={onEditConfirm}
/>
) : (
<WhoCanReplyDialog
control={infoDialogControl}
post={post}
settings={settings}
/> />
)} )}
</> </>
+26 -29
View File
@@ -12,56 +12,53 @@ import * as Dialog from '#/components/Dialog'
import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
interface ThreadgateEditorDialogProps { type Props = {
control: Dialog.DialogControlProps threadgateUISettings: ThreadgateAllowUISetting[]
threadgate: ThreadgateAllowUISetting[] onChangeThreadgateUISettings?: (v: ThreadgateAllowUISetting[]) => void
onChange?: (v: ThreadgateAllowUISetting[]) => void onConfirmThreadgateUISettings?: (v: ThreadgateAllowUISetting[]) => void
onConfirm?: (v: ThreadgateAllowUISetting[]) => void
} }
export function ThreadgateEditorDialog({ export function ThreadgateEditorDialog({
control, control,
threadgate, onChangeThreadgateUISettings,
onChange, onConfirmThreadgateUISettings,
onConfirm, threadgateUISettings,
}: ThreadgateEditorDialogProps) { }: Props & {
control: Dialog.DialogControlProps
}) {
return ( return (
<Dialog.Outer control={control}> <Dialog.Outer control={control}>
<Dialog.Handle /> <Dialog.Handle />
<DialogContent <DialogContent
seedThreadgate={threadgate} onChangeThreadgateUISettings={onChangeThreadgateUISettings}
onChange={onChange} onConfirmThreadgateUISettings={onConfirmThreadgateUISettings}
onConfirm={onConfirm} threadgateUISettings={threadgateUISettings}
/> />
</Dialog.Outer> </Dialog.Outer>
) )
} }
function DialogContent({ function DialogContent({
seedThreadgate, onChangeThreadgateUISettings,
onChange, onConfirmThreadgateUISettings,
onConfirm, threadgateUISettings,
}: { }: Props) {
seedThreadgate: ThreadgateAllowUISetting[]
onChange?: (v: ThreadgateAllowUISetting[]) => void
onConfirm?: (v: ThreadgateAllowUISetting[]) => void
}) {
const {_} = useLingui() const {_} = useLingui()
const control = Dialog.useDialogContext() const control = Dialog.useDialogContext()
const {data: lists} = useMyListsQuery('curate') const {data: lists} = useMyListsQuery('curate')
const [draft, setDraft] = React.useState(seedThreadgate) const [draft, setDraft] = React.useState(threadgateUISettings)
const [prevSeedThreadgate, setPrevSeedThreadgate] = const [prevThreadgateUISettings, setPrevThreadgateUISettings] =
React.useState(seedThreadgate) React.useState(threadgateUISettings)
if (seedThreadgate !== prevSeedThreadgate) { if (threadgateUISettings !== prevThreadgateUISettings) {
// New data flowed from above (e.g. due to update coming through). // New data flowed from above (e.g. due to update coming through).
setPrevSeedThreadgate(seedThreadgate) setPrevThreadgateUISettings(threadgateUISettings)
setDraft(seedThreadgate) // Reset draft. setDraft(threadgateUISettings) // Reset draft.
} }
function updateThreadgate(nextThreadgate: ThreadgateAllowUISetting[]) { function updateThreadgate(nextThreadgate: ThreadgateAllowUISetting[]) {
setDraft(nextThreadgate) setDraft(nextThreadgate)
onChange?.(nextThreadgate) onChangeThreadgateUISettings?.(nextThreadgate)
} }
const onPressEverybody = () => { const onPressEverybody = () => {
@@ -87,7 +84,7 @@ function DialogContent({
updateThreadgate(newSelected) updateThreadgate(newSelected)
} }
const doneLabel = onConfirm ? _(msg`Save`) : _(msg`Done`) const doneLabel = onConfirmThreadgateUISettings ? _(msg`Save`) : _(msg`Done`)
return ( return (
<Dialog.ScrollableInner <Dialog.ScrollableInner
label={_(msg`Choose who can reply`)} label={_(msg`Choose who can reply`)}
@@ -148,7 +145,7 @@ function DialogContent({
label={doneLabel} label={doneLabel}
onPress={() => { onPress={() => {
control.close() control.close()
onConfirm?.(draft) onConfirmThreadgateUISettings?.(draft)
}} }}
onAccessibilityEscape={control.close} onAccessibilityEscape={control.close}
color="primary" color="primary"
-1
View File
@@ -217,7 +217,6 @@ export function useToggleQuotepostEnabledMutation() {
action: 'enable' | 'disable' action: 'enable' | 'disable'
}) => { }) => {
await upsertPostgate({agent, postUri: postUri}, async prev => { await upsertPostgate({agent, postUri: postUri}, async prev => {
console.log({action})
if (prev) { if (prev) {
if (action === 'disable') { if (action === 'disable') {
return mergePostgateRecords(prev, { return mergePostgateRecords(prev, {
@@ -67,8 +67,8 @@ export function ThreadgateBtn({
</Animated.View> </Animated.View>
<ThreadgateEditorDialog <ThreadgateEditorDialog
control={control} control={control}
threadgate={threadgate} threadgateUISettings={threadgate}
onChange={onChange} onChangeThreadgateUISettings={onChange}
/> />
</> </>
) )