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