Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(note_info): fixed note types do not have icon
Elian Doran2eaa4ef20610
diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.tsindex 0f6df098a5..cd255b72a8 100644--- a/apps/client/src/entities/fnote.ts+++ b/apps/client/src/entities/fnote.ts@@ -1,17 +1,17 @@-import server from "../services/server.js";-import noteAttributeCache from "../services/note_attribute_cache.js";-import protectedSessionHolder from "../services/protected_session_holder.js";import cssClassManager from "../services/css_class_manager.js";import type { Froca } from "../services/froca-interface.js";-import type FAttachment from "./fattachment.js";-import type { default as FAttribute, AttributeType } from "./fattribute.js";-import utils from "../services/utils.js";+import noteAttributeCache from "../services/note_attribute_cache.js";+import protectedSessionHolder from "../services/protected_session_holder.js";import search from "../services/search.js";+import server from "../services/server.js";+import utils from "../services/utils.js";+import type FAttachment from "./fattachment.js";+import type { AttributeType,default as FAttribute } from "./fattribute.js";const LABEL = "label";const RELATION = "relation";-const NOTE_TYPE_ICONS = {+export const NOTE_TYPE_ICONS = {file: "bx bx-file",image: "bx bx-image",code: "bx bx-code",@@ -268,13 +268,13 @@ export default class FNote {}}return results;- } else {- return this.children;- }+ }+ return this.children;+}async getSubtreeNoteIds(includeArchived = false) {- let noteIds: (string | string[])[] = [];+ const noteIds: (string | string[])[] = [];for (const child of await this.getChildNotes()) {if (child.isArchived && !includeArchived) continue;@@ -471,9 +471,9 @@ export default class FNote {return a.isHidden ? 1 : -1;} else if (a.isSearch !== b.isSearch) {return a.isSearch ? 1 : -1;- } else {- return a.notePath.length - b.notePath.length;- }+ }+ return a.notePath.length - b.notePath.length;+});return notePaths;@@ -597,14 +597,14 @@ export default class FNote {} else if (this.type === "text") {if (this.isFolder()) {return "bx bx-folder";- } else {- return "bx bx-note";- }+ }+ return "bx bx-note";+} else if (this.type === "code" && this.mime.startsWith("text/x-sql")) {return "bx bx-data";- } else {- return NOTE_TYPE_ICONS[this.type];- }+ }+ return NOTE_TYPE_ICONS[this.type];+}getColorClass() {@@ -617,7 +617,7 @@ export default class FNote {}getFilteredChildBranches() {- let childBranches = this.getChildBranches();+ const childBranches = this.getChildBranches();if (!childBranches) {console.error(`No children for '${this.noteId}'. This shouldn't happen.`);@@ -811,9 +811,9 @@ export default class FNote {return this.getLabelValue(nameWithPrefix.substring(1));} else if (nameWithPrefix.startsWith("~")) {return this.getRelationValue(nameWithPrefix.substring(1));- } else {- return this.getLabelValue(nameWithPrefix);- }+ }+ return this.getLabelValue(nameWithPrefix);+}/**@@ -878,10 +878,10 @@ export default class FNote {promotedAttrs.sort((a, b) => {if (a.noteId === b.noteId) {return a.position < b.position ? -1 : 1;- } else {- // inherited promoted attributes should stay grouped: https://github.com/zadam/trilium/issues/3761- return a.noteId < b.noteId ? -1 : 1;- }+ }+ // inherited promoted attributes should stay grouped: https://github.com/zadam/trilium/issues/3761+ return a.noteId < b.noteId ? -1 : 1;+});return promotedAttrs;diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsxindex 2f53f6b89b..d12e92099c 100644--- a/apps/client/src/widgets/layout/StatusBar.tsx+++ b/apps/client/src/widgets/layout/StatusBar.tsx@@ -9,7 +9,7 @@ import { useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";import { CommandNames } from "../../components/app_context";import NoteContext from "../../components/note_context";-import FNote from "../../entities/fnote";+import FNote, { NOTE_TYPE_ICONS } from "../../entities/fnote";import attributes from "../../services/attributes";import { t } from "../../services/i18n";import { ViewScope } from "../../services/link";@@ -220,10 +220,10 @@ export function NoteInfoBadge({ note, setSimilarNotesShown }: NoteInfoContext) {const dropdownRef = useRef<BootstrapDropdown>(null);const { metadata, ...sizeProps } = useNoteMetadata(note);const [ originalFileName ] = useNoteLabel(note, "originalFileName");- const currentNoteType = useNoteProperty(note, "type");- const currentNoteTypeData = useMemo(() => NOTE_TYPES.find(t => t.type === currentNoteType), [ currentNoteType ]);+ const noteType = useNoteProperty(note, "type");+ const noteTypeMapping = useMemo(() => NOTE_TYPES.find(t => t.type === noteType), [ noteType ]);- return (note && currentNoteTypeData &&+ return (note && noteType && noteTypeMapping &&<StatusBarDropdownicon="bx bx-info-circle"title={t("status_bar.note_info_title")}@@ -235,7 +235,7 @@ export function NoteInfoBadge({ note, setSimilarNotesShown }: NoteInfoContext) {{originalFileName && <NoteInfoValue text={t("file_properties.original_file_name")} value={originalFileName} />}<NoteInfoValue text={t("note_info_widget.created")} value={formatDateTime(metadata?.dateCreated)} /><NoteInfoValue text={t("note_info_widget.modified")} value={formatDateTime(metadata?.dateModified)} />- <NoteInfoValue text={t("note_info_widget.type")} value={<><Icon icon={`bx ${currentNoteTypeData.icon}`}/>{" "}{currentNoteTypeData?.title}</>} />+ <NoteInfoValue text={t("note_info_widget.type")} value={<><Icon icon={`bx ${noteTypeMapping.icon ?? NOTE_TYPE_ICONS[noteType]}`}/>{" "}{noteTypeMapping?.title}</>} />{note.mime && <NoteInfoValue text={t("note_info_widget.mime")} value={note.mime} />}<NoteInfoValue text={t("note_info_widget.note_id")} value={<code>{note.noteId}</code>} /><NoteInfoValue text={t("note_info_widget.note_size")} title={t("note_info_widget.note_size_info")} value={<NoteSizeWidget {...sizeProps} />} />