added today launcher

This commit is contained in:
zadam 2022-12-18 23:25:35 +01:00
parent 5fca606730
commit e41104208a
4 changed files with 22 additions and 2 deletions

View file

@ -32,12 +32,13 @@ export default class NoteLauncher extends AbstractLauncher {
}
async launch(evt) {
const targetNoteId = this.getTargetNoteId();
// await because subclass overrides can be async
const targetNoteId = await this.getTargetNoteId();
if (!targetNoteId) {
return;
}
const hoistedNoteId = this.getHoistedNoteId();
const hoistedNoteId = await this.getHoistedNoteId();
if (!evt) {
// keyboard shortcut

View file

@ -0,0 +1,15 @@
import NoteLauncher from "./note_launcher.js";
import dateNotesService from "../../../services/date_notes.js";
import appContext from "../../../components/app_context.js";
export default class TodayLauncher extends NoteLauncher {
async getTargetNoteId() {
const todayNote = await dateNotesService.getTodayNote();
return todayNote.noteId;
}
getHoistedNoteId() {
return appContext.tabManager.getActiveContext().hoistedNoteId;
}
}

View file

@ -10,6 +10,7 @@ import NoteLauncher from "../buttons/launcher/note_launcher.js";
import ScriptLauncher from "../buttons/launcher/script_launcher.js";
import CommandButtonWidget from "../buttons/command_button.js";
import utils from "../../services/utils.js";
import TodayLauncher from "../buttons/launcher/today_launcher.js";
export default class LauncherWidget extends BasicWidget {
constructor() {
@ -101,6 +102,8 @@ export default class LauncherWidget extends BasicWidget {
return new BackInHistoryButtonWidget();
} else if (builtinWidget === 'forwardInHistoryButton') {
return new ForwardInHistoryButtonWidget();
} else if (builtinWidget === 'todayInJournal') {
return new TodayLauncher(note);
} else {
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
}

View file

@ -192,6 +192,7 @@ const HIDDEN_SUBTREE_DEFINITION = {
] },
{ id: 'lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" },
{ id: 'lbBookmarks', title: 'Bookmarks', type: 'launcher', builtinWidget: 'bookmarks', icon: 'bx bx-bookmark' },
{ id: 'lbToday', title: "Open Today's Journal Note", type: 'launcher', builtinWidget: 'todayInJournal', icon: 'bx bx-calendar-star' },
{ id: 'lbSpacer2', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "0", growthFactor: "1" },
{ id: 'lbProtectedSession', title: 'Protected Session', type: 'launcher', builtinWidget: 'protectedSession', icon: 'bx bx bx-shield-quarter' },
{ id: 'lbSyncStatus', title: 'Sync Status', type: 'launcher', builtinWidget: 'syncStatus', icon: 'bx bx-wifi' }