mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-26 19:15:25 +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 BranchListingSidebarEntry from '$lib/navigation/BranchListingSidebarEntry.svelte';
|
||||||
import PullRequestSidebarEntry from '$lib/navigation/PullRequestSidebarEntry.svelte';
|
import PullRequestSidebarEntry from '$lib/navigation/PullRequestSidebarEntry.svelte';
|
||||||
import {
|
import {
|
||||||
|
getEntryName,
|
||||||
getEntryUpdatedDate,
|
getEntryUpdatedDate,
|
||||||
getEntryWorkspaceStatus,
|
getEntryWorkspaceStatus,
|
||||||
type SidebarEntrySubject
|
type SidebarEntrySubject
|
||||||
@ -49,7 +50,12 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
output.sort((a, b) => {
|
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;
|
sidebarEntries = output;
|
||||||
|
@ -15,6 +15,10 @@ export function getEntryUpdatedDate(entry: SidebarEntrySubject) {
|
|||||||
return entry.type === 'branchListing' ? entry.subject.updatedAt : entry.subject.modifiedAt;
|
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) {
|
export function getEntryWorkspaceStatus(entry: SidebarEntrySubject) {
|
||||||
return entry.type === 'branchListing' ? entry.subject.virtualBranch?.inWorkspace : undefined;
|
return entry.type === 'branchListing' ? entry.subject.virtualBranch?.inWorkspace : undefined;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user