Bluesky app fork with some witchin' additions 💫

[Session] Dispose of stale agents immediately

+13
+13
src/state/session/index.tsx
··· 208 208 if (IS_DEV && isWeb) window.agent = state.currentAgentState.agent 209 209 210 210 const agent = state.currentAgentState.agent as BskyAgent 211 + const currentAgentRef = React.useRef(agent) 212 + React.useEffect(() => { 213 + if (currentAgentRef.current !== agent) { 214 + // Read the previous value and immediately advance the pointer. 215 + const prevAgent = currentAgentRef.current 216 + currentAgentRef.current = agent 217 + // We never reuse agents so let's fully neutralize the previous one. 218 + // This ensures it won't try to consume any refresh tokens. 219 + prevAgent.session = undefined 220 + prevAgent.setPersistSessionHandler(undefined) 221 + } 222 + }, [agent]) 223 + 211 224 return ( 212 225 <AgentContext.Provider value={agent}> 213 226 <StateContext.Provider value={stateContext}>