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