fix high cpu usage

This commit is contained in:
Nikita Galaiko 2023-03-22 10:05:35 +01:00
parent fa3a6271f9
commit a5c8f02350
No known key found for this signature in database
GPG Key ID: EBAB54E845BA519D
2 changed files with 16 additions and 18 deletions

View File

@ -12,6 +12,9 @@
import { currentProject } from '$lib/current_project';
import type { Project } from '$lib/projects';
import toast from 'svelte-french-toast';
import type { Readable } from 'svelte/store';
export let projects: Readable<Project[]>;
let showPalette = <string | false>false;
let palette: HTMLElement;
@ -33,8 +36,6 @@
const switchBranch = (params: { projectId: string; branch: string }) =>
invoke<Array<string>>('git_switch_branch', params);
const listProjects = () => invoke<Project[]>('list_projects');
const commit = (params: {
projectId: string;
message: string;
@ -240,21 +241,19 @@
];
let switchCommands = [];
$: {
listProjects().then((projects) => {
switchCommands = [];
projects.forEach((p) => {
if (p.id !== $currentProject?.id) {
switchCommands.push({
text: p.title,
icon: ProjectIcon,
command: 'switch',
context: p.id
});
}
});
projects.subscribe((projects) => {
switchCommands = [];
projects.forEach((p) => {
if (p.id !== $currentProject?.id) {
switchCommands.push({
text: p.title,
icon: ProjectIcon,
command: 'switch',
context: p.id
});
}
});
}
});
let baseCommands = [{ text: 'Contact Us', key: 'E', icon: ContactIcon, command: 'contact' }];

View File

@ -8,7 +8,6 @@
import { writable } from 'svelte/store';
import Breadcrumbs from '$lib/components/Breadcrumbs.svelte';
import CommandPalette from '$lib/components/CommandPalette.svelte';
import { currentProject } from '$lib/current_project';
export let data: LayoutData;
const { user, posthog, projects } = data;
@ -46,5 +45,5 @@
<slot />
</div>
<Toaster />
<CommandPalette />
<CommandPalette {projects} />
</div>