mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import FlexContainer from "./containers/flex_container.js";
|
|
import OpenNoteButtonWidget from "./buttons/open_note_button_widget.js";
|
|
import BookmarkFolderWidget from "./buttons/bookmark_folder.js";
|
|
import froca from "../services/froca.js";
|
|
|
|
export default class BookmarkButtons extends FlexContainer {
|
|
constructor() {
|
|
super("column");
|
|
|
|
this.contentSized();
|
|
}
|
|
|
|
async refresh() {
|
|
this.$widget.empty();
|
|
this.children = [];
|
|
this.noteIds = [];
|
|
|
|
const bookmarkParentNote = await froca.getNote('lbBookmarks');
|
|
|
|
for (const note of await bookmarkParentNote.getChildNotes()) {
|
|
this.noteIds.push(note.noteId);
|
|
|
|
const buttonWidget = note.hasLabel("bookmarkFolder")
|
|
? new BookmarkFolderWidget(note)
|
|
: new OpenNoteButtonWidget(note)
|
|
.class("launcher-button");
|
|
|
|
this.child(buttonWidget);
|
|
|
|
this.$widget.append(buttonWidget.render());
|
|
|
|
buttonWidget.refreshIcon();
|
|
}
|
|
}
|
|
|
|
initialRenderCompleteEvent() {
|
|
this.refresh();
|
|
}
|
|
|
|
entitiesReloadedEvent({loadResults}) {
|
|
if (loadResults.getBranches().find(branch => branch.parentNoteId === 'lbBookmarks')) {
|
|
this.refresh();
|
|
}
|
|
|
|
if (loadResults.getAttributes().find(attr => attr.type === 'label'
|
|
&& ['iconClass', 'workspaceIconClass'].includes(attr.name)
|
|
&& this.noteIds.includes(attr.noteId))
|
|
) {
|
|
this.refresh();
|
|
}
|
|
}
|
|
}
|