diff --git a/lib/core/sorting_mode.dart b/lib/core/sorting_mode.dart index 46ee0778..77495064 100644 --- a/lib/core/sorting_mode.dart +++ b/lib/core/sorting_mode.dart @@ -48,16 +48,15 @@ class SortingMode { return ""; } + // vHanda FIXME: The modified and created should come from Git if not present in the document NoteSortingFunction sortingFunction() { switch (_str) { case "Created": return (Note a, Note b) { - // vHanda FIXME: We should use when the file was created in the FS, but that doesn't - // seem to be acessible via dart - var aDt = a.created ?? a.fileLastModified; - var bDt = b.created ?? b.fileLastModified; + var aDt = a.created; + var bDt = b.created; if (aDt == null && bDt != null) { - return -1; + return 1; } if (aDt != null && bDt == null) { return -1; @@ -71,10 +70,10 @@ class SortingMode { case "Modified": default: return (Note a, Note b) { - var aDt = a.modified ?? a.fileLastModified; - var bDt = b.modified ?? b.fileLastModified; + var aDt = a.modified; + var bDt = b.modified; if (aDt == null && bDt != null) { - return -1; + return 1; } if (aDt != null && bDt == null) { return -1; @@ -82,9 +81,6 @@ class SortingMode { if (bDt == null || aDt == null) { return 0; } - if (bDt == null || aDt == null) { - return 0; - } return bDt.compareTo(aDt); }; } diff --git a/lib/widgets/journal_list.dart b/lib/widgets/journal_list.dart index 3ab4d568..50168f93 100644 --- a/lib/widgets/journal_list.dart +++ b/lib/widgets/journal_list.dart @@ -1,5 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:gitjournal/core/sorting_mode.dart'; +import 'package:gitjournal/settings.dart'; import 'package:intl/intl.dart'; import 'package:gitjournal/core/note.dart'; import 'package:gitjournal/core/notes_folder.dart'; @@ -147,7 +149,12 @@ class _JournalListState extends State { var title = note.canHaveMetadata ? note.title : note.fileName; Widget titleWidget = Text(title, style: textTheme.title); if (title.isEmpty) { - var date = note.modified ?? note.created ?? note.fileLastModified; + DateTime date; + if (Settings.instance.sortingMode == SortingMode.Modified) { + date = note.modified; + } else if (Settings.instance.sortingMode == SortingMode.Created) { + date = note.created; + } if (date != null) { var formatter = DateFormat('dd MMM, yyyy '); var dateStr = formatter.format(date);