Keep graph query label after 401 error for post-login data reload
This commit is contained in:
@@ -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);
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user