fix(core): local workspace collections (#4378)

This commit is contained in:
Alex Yang
2023-09-15 02:19:22 -07:00
committed by GitHub
parent eea38a08c5
commit c41c3c81c8
3 changed files with 29 additions and 11 deletions

View File

@@ -1,4 +0,0 @@
// todo
export function useLocationTitle(): string {
return 'AFFiNE';
}

View File

@@ -93,14 +93,15 @@ const pageCollectionBaseAtom = atomWithObservable<Collection[]>(get => {
// initial value
subscriber.next([]);
if (useLocalStorage) {
getCollections(localCRUD).then(collections => {
subscriber.next(collections);
});
const fn = () => {
getCollections(localCRUD).then(collections => {
subscriber.next(collections);
getCollections(localCRUD).then(async collections => {
const workspaceId = (await currentWorkspacePromise).id;
subscriber.next(
collections.filter(c => c.workspaceId === workspaceId)
);
});
};
fn();
callbackSet.add(fn);
return () => {
callbackSet.delete(fn);