+
+ 🎉 New Update Available
+ A new version of the app is ready.
+
+
+
+
+
+
+ `;
+
+ document.body.appendChild(notification);
+
+ // Auto-remove after 30 seconds
+ setTimeout(() => {
+ if (notification.parentElement) {
+ notification.style.animation = "slideIn 0.3s ease-out reverse";
+ setTimeout(() => notification.remove(), 300);
+ }
+ }, 30000);
+}
+
+/**
+ * Start monitoring for new deployments
+ */
+export function startDeploymentMonitoring(): void {
+ if (typeof window === "undefined") return;
+
+ // Store initial version
+ const initialVersion = getCurrentVersionHash();
+ sessionStorage.setItem(VERSION_STORAGE_KEY, initialVersion);
+
+ // Periodic version check
+ const intervalId = setInterval(async () => {
+ const hasNewVersion = await checkForNewVersion();
+ if (hasNewVersion) {
+ showUpdateNotification();
+ }
+ }, VERSION_CHECK_INTERVAL);
+
+ // Check on visibility change (user returns to tab)
+ const handleVisibilityChange = async () => {
+ if (document.visibilityState === "visible") {
+ const hasNewVersion = await checkForNewVersion();
+ if (hasNewVersion) {
+ showUpdateNotification();
+ }
+ }
+ };
+
+ document.addEventListener("visibilitychange", handleVisibilityChange);
+
+ // Cleanup function
+ if (typeof window !== "undefined") {
+ (window as any).__cleanupDeploymentMonitoring = () => {
+ clearInterval(intervalId);
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
+ };
+ }
+}
diff --git a/src/lib/token-refresh.ts b/src/lib/token-refresh.ts
index 3248a5b..14811c5 100644
--- a/src/lib/token-refresh.ts
+++ b/src/lib/token-refresh.ts
@@ -211,9 +211,14 @@ class TokenRefreshManager {
`[Token Refresh] Using rememberMe: ${rememberMe} (from refresh token cookie existence)`
);
- const result = await api.auth.refreshToken.mutate({
- rememberMe
- });
+ const result = await Promise.race([
+ api.auth.refreshToken.mutate({
+ rememberMe
+ }),
+ new Promise