pages
This commit is contained in:
parent
4cb4f563c8
commit
c2469ab000
@ -78,15 +78,20 @@ export const NotesView: React.FC<NotesViewProps> = ({
|
||||
return [...notes].sort((a, b) => {
|
||||
if (currentFolder === 'Diary' || currentFolder === 'Health') {
|
||||
// For Diary and Health, sort by date in title first
|
||||
const dateA = a.title.match(/^(\d{4}-\d{2}-\d{2})/);
|
||||
const dateB = b.title.match(/^(\d{4}-\d{2}-\d{2})/);
|
||||
const dateA = a.title?.match(/^(\d{4}-\d{2}-\d{2})/);
|
||||
const dateB = b.title?.match(/^(\d{4}-\d{2}-\d{2})/);
|
||||
|
||||
if (dateA && dateB) {
|
||||
return new Date(dateB[1]).getTime() - new Date(dateA[1]).getTime();
|
||||
}
|
||||
// If one has a date and the other doesn't, prioritize the one with date
|
||||
if (dateA && !dateB) return -1;
|
||||
if (!dateA && dateB) return 1;
|
||||
}
|
||||
// For all folders, sort by lastModified date
|
||||
return new Date(b.lastModified).getTime() - new Date(a.lastModified).getTime();
|
||||
const timeA = a.lastModified ? new Date(a.lastModified).getTime() : 0;
|
||||
const timeB = b.lastModified ? new Date(b.lastModified).getTime() : 0;
|
||||
return timeB - timeA;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user