refactor(auth): support async deferred actions for login gating
Allow deferred login actions to return promises and execute them safely without violating lint rules. Also initialize order detail timer state without impure render-time Date.now calls so React hook purity checks pass.
This commit is contained in:
@@ -2,8 +2,8 @@ import { create } from "zustand"
|
||||
|
||||
interface LoginDialogState {
|
||||
open: boolean
|
||||
pendingActions: Array<() => void>
|
||||
openLoginDialog: (action?: () => void) => void
|
||||
pendingActions: Array<() => void | Promise<void>>
|
||||
openLoginDialog: (action?: () => void | Promise<void>) => void
|
||||
closeLoginDialog: () => void
|
||||
consumePendingAction: () => void
|
||||
}
|
||||
@@ -21,7 +21,7 @@ export const useLoginDialogStore = create<LoginDialogState>((set, get) => ({
|
||||
const actions = get().pendingActions
|
||||
set({ pendingActions: [] })
|
||||
actions.forEach((action) => {
|
||||
action()
|
||||
void action()
|
||||
})
|
||||
},
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user