Merge pull request #5167 from gitbutlerapp/default-target-on-fresh-install

fix: Swallow the default target not found
This commit is contained in:
Esteban Vega 2024-10-16 15:49:35 +02:00 committed by GitHub
commit 05e812ca88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -1,7 +1,7 @@
// Class transformers will bust a gut if this isn't imported first
import 'reflect-metadata';
import { invoke } from '$lib/backend/ipc';
import { Code, invoke } from '$lib/backend/ipc';
import {
getEntryName,
getEntryUpdatedDate,
@ -33,8 +33,15 @@ export class BranchListingService {
}
private async list(filter: BranchListingFilter | undefined = undefined) {
const entries = await invoke<any[]>('list_branches', { projectId: this.projectId, filter });
return plainToInstance(BranchListing, entries);
try {
const entries = await invoke<any[]>('list_branches', { projectId: this.projectId, filter });
return plainToInstance(BranchListing, entries);
} catch (error: any) {
if (error.code === Code.DefaultTargetNotFound) {
// Swallow this error since user should be taken to project setup page
return undefined;
}
}
}
private branchListingDetails = new Map<string, Writable<BranchListingDetails | undefined>>();

View File

@ -1,4 +1,4 @@
import { invoke } from '$lib/backend/ipc';
import { Code, invoke } from '$lib/backend/ipc';
import { Branch, BranchData } from '$lib/vbranches/types';
import { plainToInstance } from 'class-transformer';
import { writable } from 'svelte/store';
@ -26,6 +26,10 @@ export class RemoteBranchService {
this.projectMetrics?.setMetric('normal_branch_count', remoteBranches.length);
this.branches.set(remoteBranches);
} catch (err: any) {
if (err.code === Code.DefaultTargetNotFound) {
// Swallow this error since user should be taken to project setup page
return;
}
this.error.set(err);
} finally {
this.branchListingService.refresh();