mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-03 23:18:26 +03:00
subscribe to fetch events
This commit is contained in:
parent
f83df47b77
commit
ef5ce12fb5
10
src/lib/api/ipc/git/fetches.ts
Normal file
10
src/lib/api/ipc/git/fetches.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { listen } from '$lib/ipc';
|
||||
|
||||
export function subscribe(
|
||||
params: { projectId: string },
|
||||
callback: (params: { projectId: string }) => Promise<void> | void
|
||||
) {
|
||||
return listen<{ head: string }>(`project://${params.projectId}/git/fetch`, (event) =>
|
||||
callback({ ...params, ...event.payload })
|
||||
);
|
||||
}
|
@ -5,6 +5,7 @@ export type { Activity } from './activities';
|
||||
export * as heads from './heads';
|
||||
export * as diffs from './diffs';
|
||||
export * as indexes from './indexes';
|
||||
export * as fetches from './fetches';
|
||||
|
||||
import { invoke } from '$lib/ipc';
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { invoke } from '$lib/ipc';
|
||||
import { git } from '$lib/api/ipc';
|
||||
import type { BranchData } from './types';
|
||||
import { writable, type Loadable } from 'svelte-loadable-store';
|
||||
import { error } from '$lib/toasts';
|
||||
@ -30,11 +31,11 @@ export function getRemoteBranches(
|
||||
|
||||
function createWriteable(projectId: string) {
|
||||
return writable(getRemoteBranchesData(projectId), (set) => {
|
||||
setInterval(() => {
|
||||
git.fetches.subscribe({ projectId }, () => {
|
||||
getRemoteBranchesData(projectId).then((branches) => {
|
||||
set(sortBranchData(branches));
|
||||
});
|
||||
}, 60000); // poll since we don't have a way to subscribe to changes
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user