fix: options-ui convert to switch-case

This commit is contained in:
Michal Szczepanski 2024-05-01 01:45:02 +02:00
parent 51c18444eb
commit 50df558756
2 changed files with 38 additions and 14 deletions

View File

@ -1,3 +1,19 @@
/*
* This file is part of the pinmenote-extension distribution (https://github.com/pinmenote/pinmenote-extension).
* Copyright (c) 2024 Michal Szczepanski.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {BrowserStorage} from "@pinmenote/browser-api"; import {BrowserStorage} from "@pinmenote/browser-api";
import {SegmentData, SegmentPage, SegmentType} from "@pinmenote/page-compute"; import {SegmentData, SegmentPage, SegmentType} from "@pinmenote/page-compute";
import {fnConsoleLog} from "../../../../common/fn/fn-console"; import {fnConsoleLog} from "../../../../common/fn/fn-console";

View File

@ -74,20 +74,28 @@ const OptionsUI: FunctionComponent = () => {
const handleHashChange = async () => { const handleHashChange = async () => {
const view = getView(); const view = getView();
setCurrentView(view); setCurrentView(view);
if (view === CurrentView.OBJ_DETAILS) { switch (view) {
await renderDetails(); case CurrentView.OBJ_DETAILS: {
} else if (view === CurrentView.PDF_DETAILS) { await renderDetails();
setShowPreview(false); break
setShowPdfPreview(true); }
} else if (view === CurrentView.SETTINGS) { case CurrentView.PDF_DETAILS: {
setShowDrawer(false); setShowPreview(false);
} else if (view === CurrentView.STORAGE) { setShowPdfPreview(true);
setShowDrawer(false); break
} else { }
setShowPreview(false); case CurrentView.SETTINGS:
setShowPdfPreview(false); case CurrentView.STORAGE: {
if (!SettingsStore.settings?.interface) return; setShowDrawer(false);
setShowDrawer(!!SettingsStore.settings.interface.optionsDrawerOpen); break;
}
default: {
setShowPreview(false);
setShowPdfPreview(false);
if (!SettingsStore.settings?.interface) return;
setShowDrawer(!!SettingsStore.settings.interface.optionsDrawerOpen);
break
}
} }
}; };