mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 14:55:50 +01:00
refactor(client): use switch instead of chained-if
This commit is contained in:
@@ -86,28 +86,28 @@ export default class LauncherWidget extends BasicWidget {
|
|||||||
|
|
||||||
initBuiltinWidget(note) {
|
initBuiltinWidget(note) {
|
||||||
const builtinWidget = note.getLabelValue("builtinWidget");
|
const builtinWidget = note.getLabelValue("builtinWidget");
|
||||||
|
switch (builtinWidget) {
|
||||||
if (builtinWidget === 'calendar') {
|
case "calendar":
|
||||||
return new CalendarWidget(note.title, note.getIcon());
|
return new CalendarWidget(note.title, note.getIcon());
|
||||||
} else if (builtinWidget === 'spacer') {
|
case "spacer":
|
||||||
// || has to be inside since 0 is a valid value
|
// || has to be inside since 0 is a valid value
|
||||||
const baseSize = parseInt(note.getLabelValue("baseSize") || "40");
|
const baseSize = parseInt(note.getLabelValue("baseSize") || "40");
|
||||||
const growthFactor = parseInt(note.getLabelValue("growthFactor") || "100");
|
const growthFactor = parseInt(note.getLabelValue("growthFactor") || "100");
|
||||||
|
|
||||||
return new SpacerWidget(baseSize, growthFactor);
|
return new SpacerWidget(baseSize, growthFactor);
|
||||||
} else if (builtinWidget === 'bookmarks') {
|
case "bookmarks":
|
||||||
return new BookmarkButtons();
|
return new BookmarkButtons();
|
||||||
} else if (builtinWidget === 'protectedSession') {
|
case "protectedSession":
|
||||||
return new ProtectedSessionStatusWidget();
|
return new ProtectedSessionStatusWidget();
|
||||||
} else if (builtinWidget === 'syncStatus') {
|
case "syncStatus":
|
||||||
return new SyncStatusWidget();
|
return new SyncStatusWidget();
|
||||||
} else if (builtinWidget === 'backInHistoryButton') {
|
case "backInHistoryButton":
|
||||||
return new HistoryNavigationButton(note, "backInNoteHistory");
|
return new HistoryNavigationButton(note, "backInNoteHistory");
|
||||||
} else if (builtinWidget === 'forwardInHistoryButton') {
|
case "forwardInHistoryButton":
|
||||||
return new HistoryNavigationButton(note, "forwardInNoteHistory");
|
return new HistoryNavigationButton(note, "forwardInNoteHistory");
|
||||||
} else if (builtinWidget === 'todayInJournal') {
|
case "todayInJournal":
|
||||||
return new TodayLauncher(note);
|
return new TodayLauncher(note);
|
||||||
} else {
|
default:
|
||||||
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
|
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user