fix: sort and double recent heading

This commit is contained in:
Matyáš Caras 2023-03-27 19:50:13 +02:00
parent 925174bcb6
commit f81b6556c4

View file

@ -37,21 +37,7 @@ class _HomeViewState extends State<HomeView> {
"You haven't opened anything recently, swipe right and start searching."),
)
]
: _recents
..insert(
0,
const Text(
"Recent pages",
style: PageStyles.h1,
),
)
..insert(
1,
const SizedBox(
height: 15,
),
),
),
: _recents),
),
),
);
@ -62,12 +48,20 @@ class _HomeViewState extends State<HomeView> {
if (recent.isEmpty) return;
recent.sort((a, b) => DateTime.fromMillisecondsSinceEpoch(a["date"])
.isAfter(DateTime.fromMillisecondsSinceEpoch(b["date"]))
? 1
? -1
: DateTime.fromMillisecondsSinceEpoch(a["date"]).isAtSameMomentAs(
DateTime.fromMillisecondsSinceEpoch(b["date"]))
? 0
: -1);
_recents = [];
: 1);
_recents = [
const Text(
"Recent pages",
style: PageStyles.h1,
),
const SizedBox(
height: 15,
),
];
for (var r in recent) {
if (!mounted) return;
_recents.add(