Skip to content
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 @@ -21,6 +21,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Fixed
- Fixed a bug that lead to trees being dropped when merging to trees together. [#8359](https://github.com/scalableminds/webknossos/pull/8359)
- Fixed that the onboarding screen incorrectly appeared when a certain request failed. [#8356](https://github.com/scalableminds/webknossos/pull/8356)
- Fixed the segment registering in coarser mags for non-mag-aligned bounding boxes. [#8364](https://github.com/scalableminds/webknossos/pull/8364)

### Removed
Expand Down
36 changes: 27 additions & 9 deletions frontend/javascripts/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const localStoragePersister = createSyncStoragePersister({
key: "query-cache-v3",
});

async function loadActiveUser() {
async function tryToLoadActiveUser() {
// Try to retrieve the currently active user if logged in
try {
const user = await getActiveUser({
Expand All @@ -73,12 +73,8 @@ async function loadActiveUser() {

async function loadHasOrganizations() {
// Check whether any organizations exist
try {
const hasOrganizations = await checkAnyOrganizationExists();
Store.dispatch(setHasOrganizationsAction(hasOrganizations));
} catch (_e) {
// pass
}
const hasOrganizations = await checkAnyOrganizationExists();
Store.dispatch(setHasOrganizationsAction(hasOrganizations));
}

async function loadOrganization() {
Expand All @@ -97,10 +93,32 @@ document.addEventListener("DOMContentLoaded", async () => {
});
message.config({ top: 30 });
checkBrowserFeatures();
await Promise.all([loadFeatureToggles(), loadActiveUser(), loadHasOrganizations()]);
await Promise.all([loadOrganization()]);
const containerElement = document.getElementById("main-container");

try {
await Promise.all([
loadFeatureToggles(),
// This function call cannot error as it has a try-catch built-in
tryToLoadActiveUser(),
// *Don't* ignore errors in this request. We only want
// to show an onboarding screen if the back-end replied
// with hasOrganizations==true.
loadHasOrganizations(),
]);
await loadOrganization();
} catch (e) {
console.error("Failed to load WEBKNOSSOS due to the following error", e);
if (containerElement) {
const react_root = createRoot(containerElement);
react_root.render(
<p style={{ margin: 20, marginTop: -20 }}>
Failed to load WEBKNOSSOS. Please try again or check the console for details.
</p>,
);
}
return;
}

if (containerElement) {
const react_root = createRoot(containerElement);
react_root.render(
Expand Down