fix(web): prevent UI flash by preserving user state in fetchMe and removing CSS pulse
This commit is contained in:
@@ -45,7 +45,7 @@ export function VersionNotifier() {
|
||||
if (!updateAvailable) return null;
|
||||
|
||||
return (
|
||||
<div className="bg-gb-accent text-gb-bg-h px-4 py-2 text-xs font-semibold flex items-center justify-between shadow-lg z-50 animate-pulse">
|
||||
<div className="bg-gb-accent text-gb-bg-h px-4 py-2 text-xs font-semibold flex items-center justify-between shadow-lg z-50">
|
||||
<span>🚀 A new update is available! ({serverVersion})</span>
|
||||
<button
|
||||
onClick={handleReload}
|
||||
|
||||
@@ -84,7 +84,7 @@ function autoSubscribePush() {
|
||||
});
|
||||
}
|
||||
|
||||
export const useAuthStore = create<AuthState>((set) => ({
|
||||
export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
user: null,
|
||||
isAuthenticated: false,
|
||||
isLoading: false,
|
||||
@@ -146,7 +146,9 @@ export const useAuthStore = create<AuthState>((set) => ({
|
||||
},
|
||||
|
||||
fetchMe: async () => {
|
||||
set({ isLoading: true, error: null });
|
||||
if (!get().user) {
|
||||
set({ isLoading: true, error: null });
|
||||
}
|
||||
try {
|
||||
const user = await api.get<User>(`/auth/me?t=${Date.now()}`);
|
||||
set({ user, isAuthenticated: true, isLoading: false });
|
||||
|
||||
@@ -125,7 +125,6 @@ export const useWebSocketStore = create<WebSocketState>((set, get) => ({
|
||||
|
||||
if (data.type === 'error') {
|
||||
console.error('ws error:', data);
|
||||
useAuthStore.getState().fetchMe();
|
||||
socket.close();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user