mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-09 05:58:40 +03:00
branches grouping update
This commit is contained in:
parent
440a4f7b80
commit
96a399bc92
@ -5,7 +5,11 @@
|
||||
import { getGitHostListingService } from '$lib/gitHost/interface/gitHostListingService';
|
||||
import BranchListingSidebarEntry from '$lib/navigation/BranchListingSidebarEntry.svelte';
|
||||
import PullRequestSidebarEntry from '$lib/navigation/PullRequestSidebarEntry.svelte';
|
||||
import { getEntryUpdatedDate, type SidebarEntrySubject } from '$lib/navigation/types';
|
||||
import {
|
||||
getEntryUpdatedDate,
|
||||
getEntryWorkspaceStatus,
|
||||
type SidebarEntrySubject
|
||||
} from '$lib/navigation/types';
|
||||
import { persisted } from '$lib/persisted/persisted';
|
||||
import ScrollableContainer from '$lib/shared/ScrollableContainer.svelte';
|
||||
import { getContext } from '$lib/utils/context';
|
||||
@ -53,8 +57,12 @@
|
||||
|
||||
const oneDay = 1000 * 60 * 60 * 24;
|
||||
|
||||
function groupByDate(branches: SidebarEntrySubject[]) {
|
||||
const grouped: Record<'today' | 'yesterday' | 'lastWeek' | 'older', SidebarEntrySubject[]> = {
|
||||
function groupBranches(branches: SidebarEntrySubject[]) {
|
||||
const grouped: Record<
|
||||
'applied' | 'today' | 'yesterday' | 'lastWeek' | 'older',
|
||||
SidebarEntrySubject[]
|
||||
> = {
|
||||
applied: [],
|
||||
today: [],
|
||||
yesterday: [],
|
||||
lastWeek: [],
|
||||
@ -71,7 +79,9 @@
|
||||
|
||||
const msSinceLastCommit = now - getEntryUpdatedDate(b).getTime();
|
||||
|
||||
if (msSinceLastCommit < oneDay) {
|
||||
if (getEntryWorkspaceStatus(b)) {
|
||||
grouped.applied.push(b);
|
||||
} else if (msSinceLastCommit < oneDay) {
|
||||
grouped.today.push(b);
|
||||
} else if (msSinceLastCommit < 2 * oneDay) {
|
||||
grouped.yesterday.push(b);
|
||||
@ -145,7 +155,7 @@
|
||||
return filtered;
|
||||
}
|
||||
});
|
||||
const groupedBranches = $derived(groupByDate(searchedBranches));
|
||||
const groupedBranches = $derived(groupBranches(searchedBranches));
|
||||
|
||||
function handleSearchKeyDown(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') {
|
||||
@ -242,6 +252,7 @@
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
{@render branchGroup({ title: 'Applied', children: groupedBranches.applied })}
|
||||
{@render branchGroup({ title: 'Today', children: groupedBranches.today })}
|
||||
{@render branchGroup({ title: 'Yesterday', children: groupedBranches.yesterday })}
|
||||
{@render branchGroup({ title: 'Last week', children: groupedBranches.lastWeek })}
|
||||
|
@ -14,3 +14,7 @@ export type SidebarEntrySubject =
|
||||
export function getEntryUpdatedDate(entry: SidebarEntrySubject) {
|
||||
return entry.type === 'branchListing' ? entry.subject.updatedAt : entry.subject.modifiedAt;
|
||||
}
|
||||
|
||||
export function getEntryWorkspaceStatus(entry: SidebarEntrySubject) {
|
||||
return entry.type === 'branchListing' ? entry.subject.virtualBranch?.inWorkspace : undefined;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user