mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-30 05:13:06 +03:00
feat(mobile): doc property journal duplicated action (#8820)
This commit is contained in:
parent
c408d73257
commit
a6232849e3
@ -1,4 +1,5 @@
|
||||
import { Checkbox, DatePicker, Menu, PropertyValue } from '@affine/component';
|
||||
import { MobileJournalConflictList } from '@affine/core/mobile/pages/workspace/detail/menu/journal-conflicts';
|
||||
import { JournalService } from '@affine/core/modules/journal';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { ViewService } from '@affine/core/modules/workbench/services/view';
|
||||
@ -15,6 +16,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import * as styles from './journal.css';
|
||||
import type { PropertyValueProps } from './types';
|
||||
|
||||
const stopPropagation = (e: React.MouseEvent) => e.stopPropagation();
|
||||
export const JournalValue = ({ onChange }: PropertyValueProps) => {
|
||||
const t = useI18n();
|
||||
|
||||
@ -75,10 +77,6 @@ export const JournalValue = ({ onChange }: PropertyValueProps) => {
|
||||
|
||||
const handleOpenDuplicate = useCallback(
|
||||
(e: React.MouseEvent) => {
|
||||
// todo: open duplicate dialog for mobile
|
||||
if (BUILD_CONFIG.isMobileEdition) {
|
||||
return;
|
||||
}
|
||||
e.stopPropagation();
|
||||
workbench.openSidebar();
|
||||
view.activeSidebarTab('journal');
|
||||
@ -141,13 +139,25 @@ export const JournalValue = ({ onChange }: PropertyValueProps) => {
|
||||
) : null}
|
||||
|
||||
{checked && conflict ? (
|
||||
<div
|
||||
data-testid="conflict-tag"
|
||||
className={styles.duplicateTag}
|
||||
onClick={handleOpenDuplicate}
|
||||
>
|
||||
{t['com.affine.page-properties.property.journal-duplicated']()}
|
||||
</div>
|
||||
BUILD_CONFIG.isMobileEdition ? (
|
||||
<Menu items={<MobileJournalConflictList date={selectedDate} />}>
|
||||
<div
|
||||
data-testid="conflict-tag"
|
||||
className={styles.duplicateTag}
|
||||
onClick={stopPropagation}
|
||||
>
|
||||
{t['com.affine.page-properties.property.journal-duplicated']()}
|
||||
</div>
|
||||
</Menu>
|
||||
) : (
|
||||
<div
|
||||
data-testid="conflict-tag"
|
||||
className={styles.duplicateTag}
|
||||
onClick={handleOpenDuplicate}
|
||||
>
|
||||
{t['com.affine.page-properties.property.journal-duplicated']()}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
</div>
|
||||
</PropertyValue>
|
||||
|
@ -112,6 +112,23 @@ const ConflictList = ({ docRecords }: { docRecords: DocRecord[] }) => {
|
||||
));
|
||||
};
|
||||
|
||||
export const MobileJournalConflictList = ({ date }: { date: string }) => {
|
||||
const docRecordList = useService(DocsService).list;
|
||||
const journalService = useService(JournalService);
|
||||
const docs = useLiveData(
|
||||
useMemo(() => journalService.journalsByDate$(date), [journalService, date])
|
||||
);
|
||||
const docRecords = useLiveData(
|
||||
docRecordList.docs$.map(records =>
|
||||
records.filter(v => {
|
||||
return docs.some(doc => doc.id === v.id);
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return <ConflictList docRecords={docRecords} />;
|
||||
};
|
||||
|
||||
const ConflictListMenuItem = ({ docRecords }: { docRecords: DocRecord[] }) => {
|
||||
const t = useI18n();
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user