Keep graph query label after 401 error for post-login data reload

This commit is contained in:
yangdx
2025-04-05 12:05:37 +08:00
parent eb2fb7b7ea
commit cc2d604782
2 changed files with 14 additions and 6 deletions

View File

@@ -342,15 +342,23 @@ const useLightrangeGraph = () => {
// Still mark graph as empty for other logic // Still mark graph as empty for other logic
state.setGraphIsEmpty(true); state.setGraphIsEmpty(true);
// Only clear current label if it's not already empty // Check if the empty graph is due to 401 authentication error
if (currentQueryLabel) { const errorMessage = useBackendState.getState().message;
const isAuthError = errorMessage && errorMessage.includes('Authentication required');
// Only clear queryLabel if it's not an auth error and current label is not empty
if (!isAuthError && currentQueryLabel) {
useSettingsStore.getState().setQueryLabel(''); useSettingsStore.getState().setQueryLabel('');
} }
// Clear last successful query label to ensure labels are fetched next time // Only clear last successful query label if it's not an auth error
if (!isAuthError) {
state.setLastSuccessfulQueryLabel(''); state.setLastSuccessfulQueryLabel('');
} else {
console.log('Keep queryLabel for post-login reload');
}
console.log('Graph data is empty, created graph with empty graph node'); console.log(`Graph data is empty, created graph with empty graph node. Auth error: ${isAuthError}`);
} else { } else {
// Create and set new graph // Create and set new graph
const newSigmaGraph = createSigmaGraph(data); const newSigmaGraph = createSigmaGraph(data);

View File

@@ -32,7 +32,7 @@ class NavigationService {
// Reset backend state // Reset backend state
useBackendState.getState().clear(); useBackendState.getState().clear();
// Reset retrieval history while preserving other user preferences // Reset retrieval history message while preserving other user preferences
useSettingsStore.getState().setRetrievalHistory([]); useSettingsStore.getState().setRetrievalHistory([]);
// Clear authentication state // Clear authentication state