Skip to content

Commit 893d2b6

Browse files
committed
cleanup some hooks
1 parent 044af1e commit 893d2b6

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

apps/dashboard/hooks/use-device-sessions.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ interface DeviceSessionDetails {
1717
}
1818

1919
export interface DeviceSessionEntry {
20-
// Exporting for use in TopHeader
2120
session: DeviceSessionDetails;
2221
user?: {
2322
email?: string;
2423
name?: string;
25-
// other user properties from auth
2624
};
2725
sessionToken: string;
2826
isCurrent: boolean;
@@ -73,9 +71,6 @@ export function useDeviceSessions() {
7371
} catch (err: any) {
7472
const errorMessage = err.message || 'Failed to fetch sessions.';
7573
setError(errorMessage);
76-
// Toasting errors here might be too aggressive if the hook is used in a non-UI critical way
77-
// Consider letting the component using the hook decide on toast notifications
78-
// toast.error(errorMessage);
7974
} finally {
8075
setIsLoading(false);
8176
}
@@ -94,7 +89,6 @@ export function useDeviceSessions() {
9489
}
9590
toast.success('Session switched successfully. Reloading...');
9691
window.location.reload();
97-
// No need to call fetchSessions() here as the page reloads
9892
return { success: true };
9993
} catch (err: any) {
10094
toast.error(err.message || 'Failed to switch session.');
@@ -115,7 +109,7 @@ export function useDeviceSessions() {
115109
throw new Error(result.error.message);
116110
}
117111
toast.success('Session revoked successfully.');
118-
fetchSessions(); // Refresh the list after revoking
112+
fetchSessions();
119113
return { success: true };
120114
} catch (err: any) {
121115
toast.error(err.message || 'Failed to revoke session.');
@@ -133,7 +127,7 @@ export function useDeviceSessions() {
133127
isLoading,
134128
error,
135129
operatingSession,
136-
fetchSessions, // Expose fetchSessions if manual refresh is needed
130+
fetchSessions,
137131
setActiveSession,
138132
revokeSession,
139133
};

apps/dashboard/hooks/use-domain-info.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,21 @@ interface BatchDomainRankResponse {
1919
data: Record<string, DomainRankData | null>;
2020
}
2121

22-
const CACHE_TIME = 60 * 60 * 1000; // 1 hour
23-
const STALE_TIME = 30 * 60 * 1000; // 30 minutes
22+
const CACHE_TIME = 60 * 60 * 1000;
23+
const STALE_TIME = 30 * 60 * 1000;
2424

2525
const queryOptions = {
2626
staleTime: STALE_TIME,
2727
gcTime: CACHE_TIME + 5 * 60 * 1000,
2828
refetchOnWindowFocus: false,
2929
refetchOnMount: true,
3030
retry: (failureCount: number, error: Error) => {
31-
// Don't retry on 4xx errors except 408 (timeout)
3231
if (
3332
error.message.includes('HTTP 4') &&
3433
!error.message.includes('HTTP 408')
3534
) {
3635
return false;
3736
}
38-
// Retry up to 3 times for other errors
3937
return failureCount < 3;
4038
},
4139
retryDelay: (attemptIndex: number) =>
@@ -84,32 +82,25 @@ export function useDomainRanks() {
8482
};
8583

8684
return {
87-
// Data
8885
ranks: query.data?.data ?? {},
8986

90-
// Loading states
9187
isLoading: query.isLoading,
9288
isFetching: query.isFetching,
9389
isRefetching: query.isRefetching,
9490

95-
// Error states
9691
isError: query.isError,
9792
error: query.error,
9893

99-
// Status
10094
status: query.status,
10195
fetchStatus: query.fetchStatus,
10296

103-
// Actions
10497
refetch: query.refetch,
10598
invalidateAndRefetch,
10699
forceRefresh,
107100

108-
// Timestamps
109101
dataUpdatedAt: query.dataUpdatedAt,
110102
errorUpdatedAt: query.errorUpdatedAt,
111103

112-
// Helper functions
113104
isStale: query.isStale,
114105
isPending: query.isPending,
115106
};

0 commit comments

Comments
 (0)