mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 10:31:50 +08:00
Revert "fix(core): make all docs journal judgement reactive (#9290)"
This reverts commit 727f21d78f.
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import { DocsService } from '@affine/core/modules/doc';
|
import { DocsService } from '@affine/core/modules/doc';
|
||||||
import { JournalService } from '@affine/core/modules/journal';
|
|
||||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||||
import type { DocCollection, DocMeta } from '@blocksuite/affine/store';
|
import type { DocCollection, DocMeta } from '@blocksuite/affine/store';
|
||||||
import { LiveData, useLiveData, useService } from '@toeverything/infra';
|
import { useService } from '@toeverything/infra';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { useAsyncCallback } from './affine-async-hooks';
|
import { useAsyncCallback } from './affine-async-hooks';
|
||||||
import { useAllBlockSuiteDocMeta } from './use-all-block-suite-page-meta';
|
import { useAllBlockSuiteDocMeta } from './use-all-block-suite-page-meta';
|
||||||
|
import { useJournalInfoHelper } from './use-journal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get pageMetas excluding journal pages without updatedDate
|
* Get pageMetas excluding journal pages without updatedDate
|
||||||
@@ -15,26 +15,13 @@ import { useAllBlockSuiteDocMeta } from './use-all-block-suite-page-meta';
|
|||||||
*/
|
*/
|
||||||
export function useBlockSuiteDocMeta(docCollection: DocCollection) {
|
export function useBlockSuiteDocMeta(docCollection: DocCollection) {
|
||||||
const pageMetas = useAllBlockSuiteDocMeta(docCollection);
|
const pageMetas = useAllBlockSuiteDocMeta(docCollection);
|
||||||
const journalService = useService(JournalService);
|
const { isPageJournal } = useJournalInfoHelper();
|
||||||
|
|
||||||
const journalIds = useLiveData(
|
|
||||||
useMemo(
|
|
||||||
() =>
|
|
||||||
LiveData.computed(get =>
|
|
||||||
pageMetas
|
|
||||||
.map(meta => meta.id)
|
|
||||||
.filter(id => !!get(journalService.journalDate$(id)))
|
|
||||||
),
|
|
||||||
[pageMetas, journalService]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() =>
|
() =>
|
||||||
pageMetas.filter(
|
pageMetas.filter(
|
||||||
pageMeta => !journalIds.includes(pageMeta.id) || !!pageMeta.updatedDate
|
pageMeta => !isPageJournal(pageMeta.id) || !!pageMeta.updatedDate
|
||||||
),
|
),
|
||||||
[journalIds, pageMetas]
|
[isPageJournal, pageMetas]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable unicorn/prefer-dom-node-dataset */
|
||||||
import { test } from '@affine-test/kit/playwright';
|
import { test } from '@affine-test/kit/playwright';
|
||||||
import {
|
import {
|
||||||
changeFilter,
|
changeFilter,
|
||||||
@@ -19,12 +20,7 @@ import {
|
|||||||
getBlockSuiteEditorTitle,
|
getBlockSuiteEditorTitle,
|
||||||
waitForAllPagesLoad,
|
waitForAllPagesLoad,
|
||||||
waitForEditorLoad,
|
waitForEditorLoad,
|
||||||
waitForEmptyEditor,
|
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import {
|
|
||||||
ensurePagePropertiesVisible,
|
|
||||||
togglePropertyListVisibility,
|
|
||||||
} from '@affine-test/kit/utils/properties';
|
|
||||||
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
|
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
@@ -290,12 +286,10 @@ test('select a group of items by clicking "Select All" in group header', async (
|
|||||||
|
|
||||||
const selectedItemCount = await page
|
const selectedItemCount = await page
|
||||||
.locator('[data-testid="page-list-group-header"]')
|
.locator('[data-testid="page-list-group-header"]')
|
||||||
// oxlint-disable-next-line
|
|
||||||
.getAttribute('data-group-selected-items-count');
|
.getAttribute('data-group-selected-items-count');
|
||||||
|
|
||||||
const selectedGroupItemTotalCount = await page
|
const selectedGroupItemTotalCount = await page
|
||||||
.locator('[data-testid="page-list-group-header"]')
|
.locator('[data-testid="page-list-group-header"]')
|
||||||
// oxlint-disable-next-line
|
|
||||||
.getAttribute('data-group-items-count');
|
.getAttribute('data-group-items-count');
|
||||||
expect(selectedItemCount).toBe(selectedGroupItemTotalCount);
|
expect(selectedItemCount).toBe(selectedGroupItemTotalCount);
|
||||||
|
|
||||||
@@ -463,29 +457,3 @@ test('create a tag and delete it', async ({ page }) => {
|
|||||||
const newCell = page.getByTestId('tag-list-item').getByText('test-tag');
|
const newCell = page.getByTestId('tag-list-item').getByText('test-tag');
|
||||||
await expect(newCell).not.toBeVisible();
|
await expect(newCell).not.toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create a empty page and turn it into journal, should disappear in all docs', async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
await openHomePage(page);
|
|
||||||
await waitForEditorLoad(page);
|
|
||||||
await clickNewPageButton(page);
|
|
||||||
await clickSideBarAllPageButton(page);
|
|
||||||
const docItem = page
|
|
||||||
.locator('[data-testid="page-list-item-title-text"]')
|
|
||||||
.first();
|
|
||||||
const docTitle = await docItem.textContent();
|
|
||||||
await expect(docTitle).toBe('Untitled');
|
|
||||||
// open and turn it into journal
|
|
||||||
await docItem.click();
|
|
||||||
await waitForEmptyEditor(page);
|
|
||||||
await ensurePagePropertiesVisible(page);
|
|
||||||
await togglePropertyListVisibility(page);
|
|
||||||
const journalProperty = page.locator('[data-info-id="journal"]').first();
|
|
||||||
await journalProperty.locator('[data-property-value="true"]').click();
|
|
||||||
// back to all docs, the journal page should disappear
|
|
||||||
await clickSideBarAllPageButton(page);
|
|
||||||
await waitForAllPagesLoad(page);
|
|
||||||
const newDocTitle = await docItem.textContent();
|
|
||||||
await expect(newDocTitle).not.toBe(docTitle);
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user