Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

chore(common): add token_refresh auth event and harden no-sync flag

James Georgef344d4e395a2
diff --git a/packages/hoppscotch-common/src/platform/auth.ts b/packages/hoppscotch-common/src/platform/auth.ts
index 152ba63fe..585afb76f 100644
--- a/packages/hoppscotch-common/src/platform/auth.ts
+++ b/packages/hoppscotch-common/src/platform/auth.ts
@@ -38,6 +38,7 @@ export type AuthEvent =
| { event: "probable_login"; user: HoppUser } // We have previous login state, but the app is waiting for authentication
| { event: "login"; user: HoppUser } // We are authenticated
| { event: "logout" } // No authentication and we have no previous state
+ | { event: "token_refresh"; user: HoppUser } // We have refreshed our tokens and have new ones now
export type GithubSignInResult =
| { type: "success"; user: HoppUser } // The authentication was a success
diff --git a/packages/hoppscotch-selfhost-web/src/lib/sync/index.ts b/packages/hoppscotch-selfhost-web/src/lib/sync/index.ts
index 3581daf4c..812093eaf 100644
--- a/packages/hoppscotch-selfhost-web/src/lib/sync/index.ts
+++ b/packages/hoppscotch-selfhost-web/src/lib/sync/index.ts
@@ -22,8 +22,11 @@ let _isRunningDispatchWithoutSyncing = true
export function runDispatchWithOutSyncing(func: () => void) {
_isRunningDispatchWithoutSyncing = false
- func()
- _isRunningDispatchWithoutSyncing = true
+ try {
+ func()
+ } finally {
+ _isRunningDispatchWithoutSyncing = true
+ }
}
export const getSyncInitFunction = <T extends DispatchingStore<any, any>>(