Skip to content

Commit

Permalink
Desktop: Fixed rendering of alarm time in detailed note list
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Apr 5, 2024
1 parent 660ebcf commit 5b4477f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/lib/services/noteList/renderTemplate.ts
Expand Up @@ -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.
Expand All @@ -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));
},
});
}
Expand Down
3 changes: 2 additions & 1 deletion packages/lib/services/noteList/renderViewProps.ts
Expand Up @@ -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<Record<ListRendererDependency, ()=> 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,
};
Expand Down

0 comments on commit 5b4477f

Please sign in to comment.