diff --git a/packages/frontend/src/stores/localRepositories.ts b/packages/frontend/src/stores/localRepositories.ts index 88688769d..fc5deec3a 100644 --- a/packages/frontend/src/stores/localRepositories.ts +++ b/packages/frontend/src/stores/localRepositories.ts @@ -1,18 +1,11 @@ import type { Readable } from 'svelte/store'; -import { readable } from 'svelte/store'; import { MSG_LOCAL_REPOSITORY_UPDATE } from '@shared/Messages'; -import { rpcBrowser, studioClient } from '/@/utils/client'; +import { studioClient } from '/@/utils/client'; import type { LocalRepository } from '@shared/src/models/ILocalRepository'; +import { RPCReadable } from '/@/stores/rpcReadable'; -export const localRepositories: Readable = readable([], set => { - const sub = rpcBrowser.subscribe(MSG_LOCAL_REPOSITORY_UPDATE, msg => { - set(msg); - }); - // Initialize the store manually - studioClient.getLocalRepositories().then(state => { - set(state); - }); - return () => { - sub.unsubscribe(); - }; -}); +export const localRepositories: Readable = RPCReadable( + [], + [MSG_LOCAL_REPOSITORY_UPDATE], + studioClient.getLocalRepositories, +);