Skip to content

Commit

Permalink
Fix bug related to switching from integration branch
Browse files Browse the repository at this point in the history
- value of projects store should never be undefined
  • Loading branch information
mtsgrd committed Jun 30, 2024
1 parent 7073308 commit 0cd628c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions app/src/lib/backend/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { persisted } from '$lib/persisted/persisted';
import * as toasts from '$lib/utils/toasts';
import { open } from '@tauri-apps/api/dialog';
import { plainToInstance } from 'class-transformer';
import { derived, get, writable } from 'svelte/store';
import { get, writable } from 'svelte/store';
import type { HttpClient } from './httpClient';
import { goto } from '$app/navigation';

Expand Down Expand Up @@ -44,7 +44,7 @@ export type CloudProject = {

export class ProjectService {
private persistedId = persisted<string | undefined>(undefined, 'lastProject');
private _projects = writable<Project[]>(undefined, (set) => {
readonly projects = writable<Project[]>([], (set) => {
this.loadAll()
.then((projects) => {
this.error.set(undefined);
Expand All @@ -55,7 +55,6 @@ export class ProjectService {
showError('Failed to load projects', err);
});
});
readonly projects = derived(this._projects, (value) => value); // public & readonly
readonly error = writable();

constructor(
Expand All @@ -68,7 +67,7 @@ export class ProjectService {
}

async reload(): Promise<void> {
this._projects.set(await this.loadAll());
this.projects.set(await this.loadAll());
}

async getProject(projectId: string) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/lib/components/ProjectSwitcher.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
title: string;
};
const mappedProjects = derived(projectService.projects, ($projects) =>
$projects.map((project) => ({
const mappedProjects = derived(projectService.projects, (projects) =>
projects.map((project) => ({
id: project.id,
title: project.title
}))
Expand Down

0 comments on commit 0cd628c

Please sign in to comment.