From f344d4e395a2d8213515e90339a64e290d209fc5 Mon Sep 17 00:00:00 2001 From: James George <25279263+jamesgeorge007@users.noreply.github.com> Date: Tue, 28 Apr 2026 18:58:51 +0530 Subject: [PATCH] chore(common): add token_refresh auth event and harden no-sync flag --- packages/hoppscotch-common/src/platform/auth.ts | 1 + packages/hoppscotch-selfhost-web/src/lib/sync/index.ts | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/hoppscotch-common/src/platform/auth.ts b/packages/hoppscotch-common/src/platform/auth.ts index 152ba63f..585afb76 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 3581daf4..812093ea 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 = >(