-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shell behaviors update (react-query refactor) (#1915)
* Move tick-every-minute into a hook/context * Move soft-reset event out of the shell model * Update soft-reset listener on new search page * Implement session-loaded and session-dropped events * Update analytics and push-notifications to use new session system
- Loading branch information
Showing
20 changed files
with
185 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import EventEmitter from 'eventemitter3' | ||
import {BskyAgent} from '@atproto/api' | ||
import {SessionAccount} from './session' | ||
|
||
type UnlistenFn = () => void | ||
|
||
const emitter = new EventEmitter() | ||
|
||
// a "soft reset" typically means scrolling to top and loading latest | ||
// but it can depend on the screen | ||
export function emitSoftReset() { | ||
emitter.emit('soft-reset') | ||
} | ||
export function listenSoftReset(fn: () => void): UnlistenFn { | ||
emitter.on('soft-reset', fn) | ||
return () => emitter.off('soft-reset', fn) | ||
} | ||
|
||
export function emitSessionLoaded( | ||
sessionAccount: SessionAccount, | ||
agent: BskyAgent, | ||
) { | ||
emitter.emit('session-loaded', sessionAccount, agent) | ||
} | ||
export function listenSessionLoaded( | ||
fn: (sessionAccount: SessionAccount, agent: BskyAgent) => void, | ||
): UnlistenFn { | ||
emitter.on('session-loaded', fn) | ||
return () => emitter.off('session-loaded', fn) | ||
} | ||
|
||
export function emitSessionDropped() { | ||
emitter.emit('session-dropped') | ||
} | ||
export function listenSessionDropped(fn: () => void): UnlistenFn { | ||
emitter.on('session-dropped', fn) | ||
return () => emitter.off('session-dropped', fn) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.