diff --git a/packages/lib/services/noteList/renderTemplate.ts b/packages/lib/services/noteList/renderTemplate.ts index 8389be6f5..e9953eda7 100644 --- a/packages/lib/services/noteList/renderTemplate.ts +++ b/packages/lib/services/noteList/renderTemplate.ts @@ -10,6 +10,11 @@ interface Cell { contentHtml: ()=> string; } +const valueToString = (value: any) => { + if (value === undefined || value === null) return ''; + return value.toString(); +}; + export default (columns: NoteListColumns, itemTemplate: string, itemValueTemplates: ListRendererItemValueTemplates, view: RenderNoteView) => { // `note.title` is special and has already been rendered to HTML at this point, so we need // to ensure the string is not going to be escaped. @@ -36,7 +41,7 @@ export default (columns: NoteListColumns, itemTemplate: string, itemValueTemplat if (itemValueTemplates[name]) { return Mustache.render(itemValueTemplates[name], view); } - return ['note.titleHtml', 'note.title'].includes(name) ? this.value : escapeHtml(this.value); + return ['note.titleHtml', 'note.title'].includes(name) ? this.value : escapeHtml(valueToString(this.value)); }, }); } diff --git a/packages/lib/services/noteList/renderViewProps.ts b/packages/lib/services/noteList/renderViewProps.ts index 0a71b88c9..deb5097cf 100644 --- a/packages/lib/services/noteList/renderViewProps.ts +++ b/packages/lib/services/noteList/renderViewProps.ts @@ -12,13 +12,14 @@ export interface RenderViewPropsOptions { noteTitleHtml: string; } -const renderViewProp = (name: ListRendererDependency, value: any, options: RenderViewPropsOptions) => { +const renderViewProp = (name: ListRendererDependency, value: any, options: RenderViewPropsOptions): string => { const renderers: Partial string>> = { 'note.user_updated_time': () => time.formatMsToLocal(value), 'note.user_created_time': () => time.formatMsToLocal(value), 'note.updated_time': () => time.formatMsToLocal(value), 'note.created_time': () => time.formatMsToLocal(value), 'note.todo_completed': () => value ? time.formatMsToLocal(value) : '', + 'note.todo_due': () => value ? time.formatMsToLocal(value) : '', 'note.tags': () => value ? value.map((t: TagEntity) => t.title).join(', ') : '', 'note.title': () => options.noteTitleHtml, };