Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add "on_logging_in" to Action
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
  • Loading branch information
Mikhail Aheichyk committed Mar 2, 2023
1 parent 1c6d1bf commit a8ee64a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ async function doSetLoggedIn(
// can be disabled to resolve "Cannot dispatch in the middle of a dispatch."
// error when it is invoked via another dispatch that is not yet finished.
if (dispatchOnLoggingIn) {
dis.dispatch({ action: "on_logging_in" }, true);
dis.dispatch({ action: Action.OnLoggingIn }, true);
}

if (clearStorageEnabled) {
Expand Down
5 changes: 5 additions & 0 deletions src/dispatcher/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ export enum Action {
*/
OnLoggedOut = "on_logged_out",

/**
* Fired when the client has started to log in. No additional payload information required.
*/
OnLoggingIn = "on_logging_in",

/**
* Fired when the client was logged in. No additional payload information required.
*/
Expand Down
2 changes: 1 addition & 1 deletion test/Lifecycle-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("Lifecycle", () => {
// promise to wait 'on_logging_in'
const loggingInPromise = new Promise((resolve, reject) => {
defaultDispatcher.register((payload: ActionPayload) => {
if (payload.action === "on_logging_in") {
if (payload.action === Action.OnLoggingIn) {
resolve(undefined);
}
});
Expand Down

0 comments on commit a8ee64a

Please sign in to comment.