simplify into a single call

This commit is contained in:
Samuel Newman
2026-06-04 16:45:30 +03:00
parent 07d89287cd
commit f412de521d
7 changed files with 58 additions and 77 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ function InnerProvider({children}: {children: React.ReactNode}) {
const isAgeRestricted = s.access !== AgeAssuranceAccess.Full
if (isAgeRestricted) {
void getAndRegisterPushToken({isAgeRestricted})
maybeRestrictChatSettings({agent})
void maybeRestrictChatSettings({agent})
}
},
[agent, getAndRegisterPushToken],
+2 -5
View File
@@ -12,7 +12,6 @@ import {restrictChatSettings} from '#/state/queries/messages/restrictChatSetting
import {DEFAULT_LOGGED_OUT_LABEL_PREFERENCES} from '#/state/queries/preferences/moderation'
import {
getDidFromAgentSession,
getOtherRequiredDataFromCache,
useAgeAssuranceDataContext,
} from '#/ageAssurance/data'
import {AgeAssuranceAccess} from '#/ageAssurance/types'
@@ -123,8 +122,6 @@ export const makeAgeRestrictedModerationPrefs = (
export function maybeRestrictChatSettings({agent}: {agent: AtpAgent}) {
const did = getDidFromAgentSession(agent)
if (!did) return
const data = getOtherRequiredDataFromCache({did})
// ...update the chat setting record if allowIncoming is not already 'none'.
if (data?.actorDeclaration?.allowIncoming === 'none') return
restrictChatSettings({agent, did})
// restrictChatSettings is a no-op if allowIncoming is already 'none'.
return restrictChatSettings({agent, did, restrictIncoming: true})
}