Skip to content

Commit

Permalink
fix: prettier
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 committed Feb 14, 2024
1 parent 93bb8df commit 6ceac8b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ test('should notify webview when register', () => {
const localRepositories = new LocalRepositoryRegistry({
postMessage: mocks.postMessageMock,
} as unknown as Webview);
localRepositories.register({path: 'random', recipeId: 'random'});
localRepositories.register({ path: 'random', recipeId: 'random' });
expect(mocks.postMessageMock).toHaveBeenNthCalledWith(1, {
id: MSG_LOCAL_REPOSITORY_UPDATE,
body: [{path: 'random', recipeId: 'random'}],
body: [{ path: 'random', recipeId: 'random' }],
});
});

test('should notify webview when unregister', () => {
const localRepositories = new LocalRepositoryRegistry({
postMessage: mocks.postMessageMock,
} as unknown as Webview);
localRepositories.register({path: 'random', recipeId: 'random'});
localRepositories.register({ path: 'random', recipeId: 'random' });
localRepositories.unregister('random');

expect(mocks.postMessageMock).toHaveBeenLastCalledWith({
Expand Down
14 changes: 8 additions & 6 deletions packages/backend/src/registries/LocalRepositoryRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ export class LocalRepositoryRegistry {
}

private notify() {
this.webview.postMessage({
id: MSG_LOCAL_REPOSITORY_UPDATE,
body: this.getLocalRepositories(),
}).catch((err: unknown) => {
console.error('Something went wrong while notifying local repositories update', err);
});
this.webview
.postMessage({
id: MSG_LOCAL_REPOSITORY_UPDATE,
body: this.getLocalRepositories(),
})
.catch((err: unknown) => {
console.error('Something went wrong while notifying local repositories update', err);
});
}
}
27 changes: 12 additions & 15 deletions packages/frontend/src/stores/localRepositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import { MSG_LOCAL_REPOSITORY_UPDATE, MSG_NEW_RECIPE_STATE } from '@shared/Messa
import { rpcBrowser, studioClient } from '/@/utils/client';
import type { LocalRepository } from '@shared/src/models/ILocalRepository';

export const localRepositories: Readable<LocalRepository[]> = readable<LocalRepository[]>(
[],
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<LocalRepository[]> = readable<LocalRepository[]>([], 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();
};
});

0 comments on commit 6ceac8b

Please sign in to comment.