mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 18:49:11 +03:00
Make branch listing sort more stable
This commit is contained in:
parent
565c5c218f
commit
d8d44f8c56
@ -6,6 +6,7 @@
|
||||
import BranchListingSidebarEntry from '$lib/navigation/BranchListingSidebarEntry.svelte';
|
||||
import PullRequestSidebarEntry from '$lib/navigation/PullRequestSidebarEntry.svelte';
|
||||
import {
|
||||
getEntryName,
|
||||
getEntryUpdatedDate,
|
||||
getEntryWorkspaceStatus,
|
||||
type SidebarEntrySubject
|
||||
@ -49,7 +50,12 @@
|
||||
);
|
||||
|
||||
output.sort((a, b) => {
|
||||
return getEntryUpdatedDate(b).getTime() - getEntryUpdatedDate(a).getTime();
|
||||
const timeDifference = getEntryUpdatedDate(b).getTime() - getEntryUpdatedDate(a).getTime();
|
||||
if (timeDifference !== 0) {
|
||||
return timeDifference;
|
||||
}
|
||||
|
||||
return getEntryName(a).localeCompare(getEntryName(b));
|
||||
});
|
||||
|
||||
sidebarEntries = output;
|
||||
|
@ -15,6 +15,10 @@ export function getEntryUpdatedDate(entry: SidebarEntrySubject) {
|
||||
return entry.type === 'branchListing' ? entry.subject.updatedAt : entry.subject.modifiedAt;
|
||||
}
|
||||
|
||||
export function getEntryName(entry: SidebarEntrySubject) {
|
||||
return entry.type === 'branchListing' ? entry.subject.name : entry.subject.title;
|
||||
}
|
||||
|
||||
export function getEntryWorkspaceStatus(entry: SidebarEntrySubject) {
|
||||
return entry.type === 'branchListing' ? entry.subject.virtualBranch?.inWorkspace : undefined;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user