Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to root folder if current folder cannot be loaded #7669

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Added more documentation for N5 and Neuroglancer precomputed web upload. [#7622](https://github.com/scalableminds/webknossos/pull/7622)
- Added the config key `webKnossos.user.timeTrackingOnlyWithSignificantChanges`, which when set to `true` will only track time if the user has made significant changes to the annotation. [#7627](https://github.com/scalableminds/webknossos/pull/7627)
- Only display UI elements to launch background jobs if the (worker) backend actually supports them. [#7591](https://github.com/scalableminds/webknossos/pull/7591)
- If the current dataset folder in the dashboard cannot be found (e.g., because somebody else deleted it), the page navigates to the root folder automatically. [#7669](https://github.com/scalableminds/webknossos/pull/7669)

### Fixed
- Fixed rare SIGBUS crashes of the datastore module that were caused by memory mapping on unstable file systems. [#7528](https://github.com/scalableminds/webknossos/pull/7528)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function DatasetCollectionContextProvider({
const mostRecentlyUsedActiveFolderId = usePrevious(activeFolderId, true);
const [isChecking, setIsChecking] = useState(false);
const isMutating = useIsMutating() > 0;
const { data: folder } = useFolderQuery(activeFolderId);
const { data: folder, isError: didFolderLoadingError } = useFolderQuery(activeFolderId);

const [selectedDatasets, setSelectedDatasets] = useState<APIDatasetCompact[]>([]);
const [selectedFolder, setSelectedFolder] = useState<FolderItem | null>(null);
Expand All @@ -110,12 +110,16 @@ export default function DatasetCollectionContextProvider({
useEffect(() => {
// Persist last active folder to localStorage. We
// check folder against null to avoid that invalid ids are persisted.
if (activeFolderId != null && folder != null) {
if (activeFolderId != null && folder != null && !didFolderLoadingError) {
UserLocalStorage.setItem(ACTIVE_FOLDER_ID_STORAGE_KEY, activeFolderId);
} else {
UserLocalStorage.removeItem(ACTIVE_FOLDER_ID_STORAGE_KEY);
}
}, [folder, activeFolderId]);

if (didFolderLoadingError) {
setActiveFolderId(null);
}
}, [folder, activeFolderId, didFolderLoadingError]);

const folderHierarchyQuery = useFolderHierarchyQuery();
const datasetsInFolderQuery = useDatasetsInFolderQuery(
Expand Down
7 changes: 7 additions & 0 deletions frontend/javascripts/dashboard/dataset/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export function useFolderQuery(folderId: string | null) {
{
refetchOnWindowFocus: false,
enabled: folderId != null,
// Avoid default retry delay with exponential back-off
// to shorten the delay after which webKnossos will switch
// to the root folder.
// This is relevant for the case where the current folder
// does not exist, anymore (e.g., was deleted by somebody
// else).
retryDelay: 500,
},
);
}
Expand Down