diff options
| author | MaheshtheDev <[email protected]> | 2025-09-24 21:02:05 +0000 |
|---|---|---|
| committer | MaheshtheDev <[email protected]> | 2025-09-24 21:02:05 +0000 |
| commit | 7e8b65b36dce243babeefe27ef1739cb4c495beb (patch) | |
| tree | ab0276e15d84398e92dc9a39071a6ecd0645175f /apps/browser-extension/utils/query-hooks.ts | |
| parent | fix(pricing): update the new pricing limits on pro plan (#439) (diff) | |
| download | archived-supermemory-7e8b65b36dce243babeefe27ef1739cb4c495beb.tar.xz archived-supermemory-7e8b65b36dce243babeefe27ef1739cb4c495beb.zip | |
feat(extension): Auto Logout when token is invalidated, Account Section (#438)
## Changes:
- Added token validation logic that checks if the current auth token is still valid
- Implemented automatic logout when token is invalidated with appropriate user feedback
- Added an Account section in the popup that displays the user's email
- Improved error toast messages with clearer formatting and helper text

Diffstat (limited to 'apps/browser-extension/utils/query-hooks.ts')
| -rw-r--r-- | apps/browser-extension/utils/query-hooks.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/apps/browser-extension/utils/query-hooks.ts b/apps/browser-extension/utils/query-hooks.ts index 721a68ad..5c7cfc21 100644 --- a/apps/browser-extension/utils/query-hooks.ts +++ b/apps/browser-extension/utils/query-hooks.ts @@ -5,6 +5,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" import { fetchProjects, getDefaultProject, + getUserData, saveMemory, searchMemories, setDefaultProject, @@ -15,6 +16,7 @@ import type { MemoryPayload } from "./types" export const queryKeys = { projects: ["projects"] as const, defaultProject: ["defaultProject"] as const, + userData: ["userData"] as const, } // Projects Query @@ -37,6 +39,16 @@ export function useDefaultProject(options?: { enabled?: boolean }) { }) } +// User Data Query +export function useUserData(options?: { enabled?: boolean }) { + return useQuery({ + queryKey: queryKeys.userData, + queryFn: getUserData, + staleTime: 5 * 60 * 1000, // 5 minutes + enabled: options?.enabled ?? true, + }) +} + // Set Default Project Mutation export function useSetDefaultProject() { const queryClient = useQueryClient() |