mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 18:49:11 +03:00
Merge pull request #4625 from gitbutlerapp/make-branch-listing-more-reactive
feat: Integrate BranchListingService for better branch management
This commit is contained in:
commit
91c2e9fec7
@ -2,6 +2,7 @@ import { invoke } from '$lib/backend/ipc';
|
||||
import { Branch, BranchData } from '$lib/vbranches/types';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { BranchListingService } from '$lib/branches/branchListing';
|
||||
import type { ProjectMetrics } from '$lib/metrics/projectMetrics';
|
||||
|
||||
export class RemoteBranchService {
|
||||
@ -12,6 +13,7 @@ export class RemoteBranchService {
|
||||
|
||||
constructor(
|
||||
private projectId: string,
|
||||
private branchListingService: BranchListingService,
|
||||
private projectMetrics?: ProjectMetrics
|
||||
) {}
|
||||
|
||||
@ -25,6 +27,8 @@ export class RemoteBranchService {
|
||||
this.branches.set(remoteBranches);
|
||||
} catch (err: any) {
|
||||
this.error.set(err);
|
||||
} finally {
|
||||
this.branchListingService.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import { invoke, listen } from '$lib/backend/ipc';
|
||||
import { RemoteBranchService } from '$lib/stores/remoteBranches';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { BranchListingService } from '$lib/branches/branchListing';
|
||||
import type { ProjectMetrics } from '$lib/metrics/projectMetrics';
|
||||
|
||||
export class VirtualBranchService {
|
||||
@ -21,7 +22,8 @@ export class VirtualBranchService {
|
||||
constructor(
|
||||
private projectId: string,
|
||||
private projectMetrics: ProjectMetrics,
|
||||
private remoteBranchService: RemoteBranchService
|
||||
private remoteBranchService: RemoteBranchService,
|
||||
private branchListingService: BranchListingService
|
||||
) {}
|
||||
|
||||
async refresh() {
|
||||
@ -69,6 +71,8 @@ export class VirtualBranchService {
|
||||
this.branches.set(branches);
|
||||
this.branchesError.set(undefined);
|
||||
this.logMetrics(branches);
|
||||
|
||||
this.branchListingService.refresh();
|
||||
}
|
||||
|
||||
private async listVirtualBranches(): Promise<VirtualBranch[]> {
|
||||
|
@ -56,7 +56,6 @@
|
||||
const accessToken = $derived($user?.github_access_token);
|
||||
const baseError = $derived(baseBranchService.error);
|
||||
const projectError = $derived(projectService.error);
|
||||
const branchListingService = $derived(new BranchListingService(projectId));
|
||||
|
||||
$effect.pre(() => {
|
||||
setContext(HistoryService, data.historyService);
|
||||
@ -69,7 +68,7 @@
|
||||
setContext(CommitDragActionsFactory, data.commitDragActionsFactory);
|
||||
setContext(ReorderDropzoneManagerFactory, data.reorderDropzoneManagerFactory);
|
||||
setContext(RemoteBranchService, data.remoteBranchService);
|
||||
setContext(BranchListingService, branchListingService);
|
||||
setContext(BranchListingService, data.branchListingService);
|
||||
});
|
||||
|
||||
let intervalId: any;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { invoke } from '$lib/backend/ipc';
|
||||
import { BaseBranchService } from '$lib/baseBranch/baseBranchService';
|
||||
import { BranchListingService } from '$lib/branches/branchListing';
|
||||
import { BranchDragActionsFactory } from '$lib/branches/dragActions.js';
|
||||
import { CommitDragActionsFactory } from '$lib/commits/dragActions.js';
|
||||
import { ReorderDropzoneManagerFactory } from '$lib/dragging/reorderDropzoneManager';
|
||||
@ -47,9 +48,20 @@ export const load: LayoutLoad = async ({ params, parent }) => {
|
||||
|
||||
const historyService = new HistoryService(projectId);
|
||||
const baseBranchService = new BaseBranchService(projectId);
|
||||
const remoteBranchService = new RemoteBranchService(projectId, projectMetrics);
|
||||
|
||||
const vbranchService = new VirtualBranchService(projectId, projectMetrics, remoteBranchService);
|
||||
const branchListingService = new BranchListingService(projectId);
|
||||
const remoteBranchService = new RemoteBranchService(
|
||||
projectId,
|
||||
branchListingService,
|
||||
projectMetrics
|
||||
);
|
||||
|
||||
const vbranchService = new VirtualBranchService(
|
||||
projectId,
|
||||
projectMetrics,
|
||||
remoteBranchService,
|
||||
branchListingService
|
||||
);
|
||||
|
||||
const branchController = new BranchController(
|
||||
projectId,
|
||||
@ -78,6 +90,7 @@ export const load: LayoutLoad = async ({ params, parent }) => {
|
||||
// These observables are provided for convenience
|
||||
branchDragActionsFactory,
|
||||
commitDragActionsFactory,
|
||||
reorderDropzoneManagerFactory
|
||||
reorderDropzoneManagerFactory,
|
||||
branchListingService
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user