mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 01:36:30 +02:00
feat: enhance ElectricProvider and Tooltip components for improved user experience
- Updated ElectricProvider to check for user authentication via bearer token before rendering, preventing unnecessary loading screens for unauthenticated users. - Modified TooltipProvider to include a new disableHoverableContent prop, enhancing tooltip behavior and usability.
This commit is contained in:
parent
a51fe2ee69
commit
bba3cb1cf9
2 changed files with 9 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
|||
import { useAtomValue } from "jotai";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { currentUserAtom } from "@/atoms/user/user-query.atoms";
|
||||
import { getBearerToken } from "@/lib/auth-utils";
|
||||
import {
|
||||
cleanupElectric,
|
||||
type ElectricClient,
|
||||
|
|
@ -105,9 +106,13 @@ export function ElectricProvider({ children }: ElectricProviderProps) {
|
|||
};
|
||||
}, [user?.id, isUserLoaded, electricClient]);
|
||||
|
||||
// Check if user is authenticated first (has bearer token)
|
||||
// This prevents showing loading screen for unauthenticated users on homepage
|
||||
const hasToken = typeof window !== "undefined" && !!getBearerToken();
|
||||
|
||||
// For non-authenticated pages (like landing page), render immediately with null context
|
||||
// Also render immediately if user query failed (e.g., token expired)
|
||||
if (!isUserLoaded || !user?.id || isUserError) {
|
||||
if (!hasToken || !isUserLoaded || !user?.id || isUserError) {
|
||||
return <ElectricContext.Provider value={null}>{children}</ElectricContext.Provider>;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue