Skip to content

Commit

Permalink
try to enforce currently fronting order
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaomiDEV committed Aug 5, 2024
1 parent 9153303 commit eb74fe2
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/views/options/FrontHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@
function getGrouped(entries: FrontingEntryComplete[]){
const map = new Map<string, FrontingEntryComplete[]>();
for(const entry of entries.sort((a, b) => b.startTime.getTime() - a.startTime.getTime())){
const key = entry.endTime ? dayjs(entry.startTime).startOf('day').toISOString() : "currentlyFronting";
for(const entry of entries.filter(x => !x.endTime).sort((a, b) => b.startTime.getTime() - a.startTime.getTime())){
const collection = map.get("currentlyFronting");
if(!collection)
map.set("currentlyFronting", [entry])
else
collection.push(entry)
}
for(const entry of entries.filter(x => x.endTime).sort((a, b) => b.startTime.getTime() - a.startTime.getTime())){
const key = dayjs(entry.startTime).startOf('day').toISOString();
const collection = map.get(key);
if(!collection)
Expand All @@ -48,7 +56,10 @@
collection.push(entry)
}
return map;
return [...map.entries()].sort((a, b) => {
if(a[0] === "currentlyFronting") return -1;
return dayjs(b[0]).valueOf() - dayjs(a[0]).valueOf()
});
}
function getAtDate(_date: string){
Expand All @@ -64,7 +75,10 @@
map.set(key, filteredFrontingEntries.value?.filter(x => x.endTime && dayjs(x.startTime).startOf('day').valueOf() === date.valueOf()) || []);
return map;
return [...map.entries()].sort((a, b) => {
if(a[0] === "currentlyFronting") return -1;
return dayjs(b[0]).valueOf() - dayjs(a[0]).valueOf()
});
}
</script>

Expand Down

0 comments on commit eb74fe2

Please sign in to comment.