import { t } from "../services/i18n.js"; import NoteContextAwareWidget from "./note_context_aware_widget.js"; import NoteListRenderer from "../services/note_list_renderer.js"; const TPL = `
`; export default class SearchResultWidget extends NoteContextAwareWidget { isEnabled() { return super.isEnabled() && this.note.type === "search"; } doRender() { this.$widget = $(TPL); this.contentSized(); this.$content = this.$widget.find(".search-result-widget-content"); this.$noResults = this.$widget.find(".search-no-results"); this.$notExecutedYet = this.$widget.find(".search-not-executed-yet"); } async refreshWithNote(note) { this.$content.empty(); this.$noResults.toggle(note.getChildNoteIds().length === 0 && !!note.searchResultsLoaded); this.$notExecutedYet.toggle(!note.searchResultsLoaded); const noteListRenderer = new NoteListRenderer(this.$content, note, note.getChildNoteIds(), true); await noteListRenderer.renderList(); } searchRefreshedEvent({ ntxId }) { if (!this.isNoteContext(ntxId)) { return; } this.refresh(); } notesReloadedEvent({ noteIds }) { if (noteIds.includes(this.noteId)) { this.refresh(); } } }