There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): local workspace collections (#4378)
Alex Yangc41c3c81c894
diff --git a/apps/core/src/hooks/use-location-title.ts b/apps/core/src/hooks/use-location-title.tsdeleted file mode 100644index 682cbcfcbc..0000000000--- a/apps/core/src/hooks/use-location-title.ts+++ /dev/null@@ -1,4 +0,0 @@-// todo-export function useLocationTitle(): string {- return 'AFFiNE';-}diff --git a/apps/core/src/utils/user-setting.ts b/apps/core/src/utils/user-setting.tsindex 8e4ced7f73..f53b5de0bd 100644--- a/apps/core/src/utils/user-setting.ts+++ b/apps/core/src/utils/user-setting.ts@@ -93,14 +93,15 @@ const pageCollectionBaseAtom = atomWithObservable<Collection[]>(get => {// initial valuesubscriber.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);diff --git a/tests/affine-local/e2e/local-first-collections-items.spec.ts b/tests/affine-local/e2e/local-first-collections-items.spec.tsindex 0066f4e477..301563d75e 100644--- a/tests/affine-local/e2e/local-first-collections-items.spec.ts+++ b/tests/affine-local/e2e/local-first-collections-items.spec.ts@@ -9,6 +9,8 @@ import {getBlockSuiteEditorTitle,waitForEditorLoad,} from '@affine-test/kit/utils/page-logic';+import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';+import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';import type { Page } from '@playwright/test';import { expect } from '@playwright/test';@@ -16,10 +18,13 @@ const createAndPinCollection = async (page: Page,options?: {collectionName?: string;+ skipInitialPage?: boolean;}) => {- await openHomePage(page);- await waitForEditorLoad(page);+ if (!options?.skipInitialPage) {+ await openHomePage(page);+ await waitForEditorLoad(page);+ }await clickNewPageButton(page);await getBlockSuiteEditorTitle(page).click();await getBlockSuiteEditorTitle(page).fill('test page');@@ -65,6 +70,22 @@ test('Show collections items in sidebar', async ({ page }) => {await deleteCollection.click();await page.waitForTimeout(50);expect(await items.count()).toBe(0);+ await createAndPinCollection(page, {+ skipInitialPage: true,+ });+ expect(await items.count()).toBe(1);++ await clickSideBarCurrentWorkspaceBanner(page);+ await createLocalWorkspace(+ {+ name: 'Test 1',+ },+ page+ );+ await waitForEditorLoad(page);+ expect(await items.count()).toBe(0);+ await clickSideBarCurrentWorkspaceBanner(page);+ await page.getByTestId('workspace-card').nth(0).click();});test('pin and unpin collection', async ({ page }) => {