aboutsummaryrefslogtreecommitdiff
path: root/packages/lib
diff options
context:
space:
mode:
authorAlex Foster <[email protected]>2025-08-25 17:37:14 -0400
committerGitHub <[email protected]>2025-08-25 14:37:14 -0700
commit8da19c977eefbfae280e912df507427083c28b0a (patch)
tree53bb68187567449f66a177e75be864cfe06868ed /packages/lib
parentfix: redeploy (diff)
downloadsupermemory-8da19c977eefbfae280e912df507427083c28b0a.tar.xz
supermemory-8da19c977eefbfae280e912df507427083c28b0a.zip
feat: add 'last used' badge to login page (#387)
Diffstat (limited to 'packages/lib')
-rw-r--r--packages/lib/auth-context.tsx34
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/lib/auth-context.tsx b/packages/lib/auth-context.tsx
index 5b2d58bc..66ff84bc 100644
--- a/packages/lib/auth-context.tsx
+++ b/packages/lib/auth-context.tsx
@@ -33,6 +33,40 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}
}, [session?.session.activeOrganizationId])
+ // When a session exists and there is a pending login method recorded,
+ // promote it to the last-used method (successful login) and clear pending.
+ useEffect(() => {
+ if (typeof window === "undefined") return
+ if (!session?.session) return
+
+ try {
+ const pendingMethod = localStorage.getItem(
+ "supermemory-pending-login-method",
+ )
+ const pendingTsRaw = localStorage.getItem(
+ "supermemory-pending-login-timestamp",
+ )
+
+ if (pendingMethod) {
+ const now = Date.now()
+ const ts = pendingTsRaw ? Number.parseInt(pendingTsRaw, 10) : NaN
+ const isFresh = Number.isFinite(ts) && now - ts < 10 * 60 * 1000 // 10 minutes TTL
+
+ if (isFresh) {
+ localStorage.setItem(
+ "supermemory-last-login-method",
+ pendingMethod,
+ )
+ }
+ }
+ } catch { }
+ // Always clear pending markers once a session is present
+ try {
+ localStorage.removeItem("supermemory-pending-login-method")
+ localStorage.removeItem("supermemory-pending-login-timestamp")
+ } catch { }
+ }, [session?.session])
+
const setActiveOrg = async (slug: string) => {
if (!slug) return