mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(core): add default display preference (#12333)
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
import { LiveData } from '@toeverything/infra';
|
||||
import { uniq } from 'lodash-es';
|
||||
import { createContext } from 'react';
|
||||
|
||||
import type { ExplorerDisplayPreference } from './types';
|
||||
|
||||
const DefaultDisplayPreference: ExplorerDisplayPreference = {
|
||||
view: 'list',
|
||||
displayProperties: [
|
||||
'system:createdAt',
|
||||
'system:updatedAt',
|
||||
'system:createdBy',
|
||||
'system:tags',
|
||||
],
|
||||
showDocIcon: true,
|
||||
showDocPreview: true,
|
||||
quickFavorite: true,
|
||||
};
|
||||
|
||||
export type DocExplorerContextType = {
|
||||
groups$: LiveData<Array<{ key: string; items: string[] }>>;
|
||||
collapsedGroups$: LiveData<string[]>;
|
||||
@@ -23,9 +37,14 @@ export const DocExplorerContext = createContext<DocExplorerContextType>(
|
||||
export const createDocExplorerContext = (
|
||||
initialState?: ExplorerDisplayPreference
|
||||
) => {
|
||||
const displayPreference$ = new LiveData<ExplorerDisplayPreference>(
|
||||
initialState ?? {}
|
||||
);
|
||||
const displayPreference$ = new LiveData<ExplorerDisplayPreference>({
|
||||
...DefaultDisplayPreference,
|
||||
...initialState,
|
||||
displayProperties: uniq([
|
||||
...(DefaultDisplayPreference.displayProperties ?? []),
|
||||
...(initialState?.displayProperties ?? []),
|
||||
]),
|
||||
});
|
||||
return {
|
||||
groups$: new LiveData<Array<{ key: string; items: string[] }>>([]),
|
||||
collapsedGroups$: new LiveData<string[]>([]),
|
||||
|
||||
Reference in New Issue
Block a user