Skip to content

Commit 3dadd09

Browse files
WIP
1 parent d5f7849 commit 3dadd09

3 files changed

Lines changed: 14 additions & 22 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
- Keep types accurate. Do not use casts or misleading annotations to mask a real type mismatch just to get around an issue; fix the type or fix the implementation.
99
- Do not add new exported functions, types, or constants unless they are required outside the file. Prefer file-local helpers for one-off implementation details and tests.
1010
- Do not use `navigation.setOptions` for header state in this repo. Pass header-driving state through route params so `getOptions` can read it synchronously, or use [`shared/stores/modal-header.tsx`](/Users/ChrisNojima/SourceCode/go/src/github.com/keybase/client/shared/stores/modal-header.tsx) when the flow already uses the shared modal header mechanism.
11+
- Components must not mutate Zustand stores directly with `useXState.setState`, `getState()`-based writes, or similar ad hoc store mutation. If a component needs to affect store state, route it through a store dispatch action or move the state out of the store.
1112
- During refactors, do not delete existing guards, conditionals, or platform/test-specific behavior unless you have proven they are dead and the user asked for that behavior change. Port checks like `androidIsTestDevice` forward into the new code path instead of silently dropping them.
1213
- When addressing PR or review feedback, including bot or lint-style suggestions, do not apply it mechanically. Verify that the reported issue is real in this codebase and that the proposed fix is consistent with repo rules and improves correctness, behavior, or maintainability before making changes.

shared/stores/teams.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ export type State = Store & {
942942
selected: boolean,
943943
clearAll?: boolean
944944
) => void
945+
setRespondToInviteLink: (respondToInviteLink?: (accept: boolean) => void) => void
945946
setNewTeamInfo: (
946947
deletedTeams: ReadonlyArray<T.RPCGen.DeletedTeamInfo>,
947948
newTeams: Set<T.Teams.TeamID>,
@@ -2287,6 +2288,11 @@ export const useTeamsState = Z.createZustand<State>('teams', (set, get) => {
22872288
}
22882289
})
22892290
},
2291+
setRespondToInviteLink: respondToInviteLink => {
2292+
set(s => {
2293+
s.dispatch.dynamic.respondToInviteLink = respondToInviteLink
2294+
})
2295+
},
22902296
setNewTeamInfo: (deletedTeams, newTeams, teamIDToResetUsers) => {
22912297
set(s => {
22922298
s.deletedTeams = T.castDraft(deletedTeams)

shared/teams/join-team/container.tsx

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const Container = ({initialTeamname, success: successParam}: OwnProps) => {
3030
const [open, setOpen] = React.useState(false)
3131
const [successTeamName, setSuccessTeamName] = React.useState('')
3232
const [name, _setName] = React.useState(initialTeamname ?? '')
33+
const setRespondToInviteLink = useTeamsState(s => s.dispatch.setRespondToInviteLink)
3334
const joinTeam = C.useRPC(T.RPCGen.teamsTeamAcceptInviteOrRequestAccessRpcListener)
3435
const navigation = useNavigation<NativeStackNavigationProp<RootParamList, 'teamJoinTeamDialog'>>()
3536
const navigateUp = C.Router2.navigateUp
@@ -57,28 +58,12 @@ const Container = ({initialTeamname, success: successParam}: OwnProps) => {
5758
{
5859
customResponseIncomingCallMap: {
5960
'keybase.1.teamsUi.confirmInviteLinkAccept': (params, response) => {
60-
const currentDispatch = useTeamsState.getState().dispatch
61-
useTeamsState.setState({
62-
dispatch: {
63-
...currentDispatch,
64-
dynamic: {
65-
...currentDispatch.dynamic,
66-
respondToInviteLink: wrapErrors((accept: boolean) => {
67-
const latestDispatch = useTeamsState.getState().dispatch
68-
useTeamsState.setState({
69-
dispatch: {
70-
...latestDispatch,
71-
dynamic: {
72-
...latestDispatch.dynamic,
73-
respondToInviteLink: undefined,
74-
},
75-
},
76-
})
77-
response.result(accept)
78-
}),
79-
},
80-
},
81-
})
61+
setRespondToInviteLink(
62+
wrapErrors((accept: boolean) => {
63+
setRespondToInviteLink(undefined)
64+
response.result(accept)
65+
})
66+
)
8267
C.Router2.navigateAppend(
8368
{
8469
name: 'teamInviteLinkJoin',

0 commit comments

Comments
 (0)