mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-23 17:43:47 +03:00
when navigating to project page, check if cloud data is up to date
This commit is contained in:
parent
3b3aeb8bb6
commit
4afa457baa
@ -2,7 +2,7 @@
|
||||
import { stores, log, toasts } from '$lib';
|
||||
import { CloudApi, type Project } from '$lib/api';
|
||||
import { Login, Checkbox } from '$lib/components';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
|
||||
export let project: Project;
|
||||
const user = stores.user;
|
||||
@ -12,6 +12,15 @@
|
||||
updated: Project;
|
||||
}>();
|
||||
|
||||
onMount(async () => {
|
||||
if (!project.api) return;
|
||||
const u = await user.load();
|
||||
if (!u) return;
|
||||
const cloudProject = await cloud.projects.get(u.access_token, project.api.repository_id);
|
||||
if (cloudProject === project.api) return;
|
||||
dispatch('updated', { ...project, api: { ...cloudProject, sync: project.api.sync } });
|
||||
});
|
||||
|
||||
const onSyncChange = async (event: Event) => {
|
||||
if ($user === null) return;
|
||||
|
||||
@ -26,7 +35,6 @@
|
||||
description: project.description,
|
||||
uid: project.id
|
||||
}));
|
||||
|
||||
dispatch('updated', { ...project, api: { ...cloudProject, sync } });
|
||||
} catch (error) {
|
||||
log.error(`Failed to update project sync status: ${error}`);
|
||||
|
Loading…
Reference in New Issue
Block a user