Skip to content

Commit 8851780

Browse files
committed
Fix bug related to switching from integration branch
- value of projects store should never be undefined
1 parent d9f314f commit 8851780

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

app/src/lib/backend/projects.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { persisted } from '$lib/persisted/persisted';
44
import * as toasts from '$lib/utils/toasts';
55
import { open } from '@tauri-apps/api/dialog';
66
import { plainToInstance } from 'class-transformer';
7-
import { derived, get, writable } from 'svelte/store';
7+
import { get, writable } from 'svelte/store';
88
import type { HttpClient } from './httpClient';
99
import { goto } from '$app/navigation';
1010

@@ -44,7 +44,7 @@ export type CloudProject = {
4444

4545
export class ProjectService {
4646
private persistedId = persisted<string | undefined>(undefined, 'lastProject');
47-
private _projects = writable<Project[]>(undefined, (set) => {
47+
readonly projects = writable<Project[]>([], (set) => {
4848
this.loadAll()
4949
.then((projects) => {
5050
this.error.set(undefined);
@@ -55,7 +55,6 @@ export class ProjectService {
5555
showError('Failed to load projects', err);
5656
});
5757
});
58-
readonly projects = derived(this._projects, (value) => value); // public & readonly
5958
readonly error = writable();
6059

6160
constructor(
@@ -68,7 +67,7 @@ export class ProjectService {
6867
}
6968

7069
async reload(): Promise<void> {
71-
this._projects.set(await this.loadAll());
70+
this.projects.set(await this.loadAll());
7271
}
7372

7473
async getProject(projectId: string) {

app/src/lib/components/ProjectSwitcher.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
title: string;
1616
};
1717
18-
const mappedProjects = derived(projectService.projects, ($projects) =>
19-
$projects.map((project) => ({
18+
const mappedProjects = derived(projectService.projects, (projects) =>
19+
projects.map((project) => ({
2020
id: project.id,
2121
title: project.title
2222
}))

0 commit comments

Comments
 (0)