tangled
alpha
login
or
join now
jeanmachine.dev
/
witchsky.app
forked from
jollywhoppers.com/witchsky.app
0
fork
atom
Bluesky app fork with some witchin' additions 💫
0
fork
atom
overview
issues
pulls
pipelines
[Session] Dispose of stale agents immediately
danabra.mov
2 years ago
8938fc87
acf1def6
+13
1 changed file
expand all
collapse all
unified
split
src
state
session
index.tsx
+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
211
+
const currentAgentRef = React.useRef(agent)
212
212
+
React.useEffect(() => {
213
213
+
if (currentAgentRef.current !== agent) {
214
214
+
// Read the previous value and immediately advance the pointer.
215
215
+
const prevAgent = currentAgentRef.current
216
216
+
currentAgentRef.current = agent
217
217
+
// We never reuse agents so let's fully neutralize the previous one.
218
218
+
// This ensures it won't try to consume any refresh tokens.
219
219
+
prevAgent.session = undefined
220
220
+
prevAgent.setPersistSessionHandler(undefined)
221
221
+
}
222
222
+
}, [agent])
223
223
+
211
224
return (
212
225
<AgentContext.Provider value={agent}>
213
226
<StateContext.Provider value={stateContext}>