mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat(core): remember backlink open/close state (#9073)
fix AF-1850, AF-1883
This commit is contained in:
@@ -1,17 +1,35 @@
|
||||
export { GlobalCache, GlobalState } from './providers/global';
|
||||
export { GlobalCacheService, GlobalStateService } from './services/global';
|
||||
export {
|
||||
GlobalCache,
|
||||
GlobalSessionState,
|
||||
GlobalState,
|
||||
} from './providers/global';
|
||||
export {
|
||||
GlobalCacheService,
|
||||
GlobalSessionStateService,
|
||||
GlobalStateService,
|
||||
} from './services/global';
|
||||
|
||||
import type { Framework } from '../../framework';
|
||||
import { MemoryMemento } from '../../storage';
|
||||
import { GlobalCache, GlobalState } from './providers/global';
|
||||
import { GlobalCacheService, GlobalStateService } from './services/global';
|
||||
import {
|
||||
GlobalCache,
|
||||
GlobalSessionState,
|
||||
GlobalState,
|
||||
} from './providers/global';
|
||||
import {
|
||||
GlobalCacheService,
|
||||
GlobalSessionStateService,
|
||||
GlobalStateService,
|
||||
} from './services/global';
|
||||
|
||||
export const configureGlobalStorageModule = (framework: Framework) => {
|
||||
framework.service(GlobalStateService, [GlobalState]);
|
||||
framework.service(GlobalCacheService, [GlobalCache]);
|
||||
framework.service(GlobalSessionStateService, [GlobalSessionState]);
|
||||
};
|
||||
|
||||
export const configureTestingGlobalStorage = (framework: Framework) => {
|
||||
framework.impl(GlobalCache, MemoryMemento);
|
||||
framework.impl(GlobalState, MemoryMemento);
|
||||
framework.impl(GlobalSessionState, MemoryMemento);
|
||||
};
|
||||
|
||||
@@ -16,5 +16,13 @@ export const GlobalState = createIdentifier<GlobalState>('GlobalState');
|
||||
* Cache may be deleted from time to time, business logic should not rely on cache.
|
||||
*/
|
||||
export interface GlobalCache extends Memento {}
|
||||
|
||||
export const GlobalCache = createIdentifier<GlobalCache>('GlobalCache');
|
||||
|
||||
/**
|
||||
* A memento object that stores session state.
|
||||
*
|
||||
* Session state is not persisted, it will be cleared when the application is closed. (thinking about sessionStorage)
|
||||
*/
|
||||
export interface GlobalSessionState extends Memento {}
|
||||
export const GlobalSessionState =
|
||||
createIdentifier<GlobalSessionState>('GlobalSessionState');
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { Service } from '../../../framework';
|
||||
import type { GlobalCache, GlobalState } from '../providers/global';
|
||||
import type {
|
||||
GlobalCache,
|
||||
GlobalSessionState,
|
||||
GlobalState,
|
||||
} from '../providers/global';
|
||||
|
||||
export class GlobalStateService extends Service {
|
||||
constructor(public readonly globalState: GlobalState) {
|
||||
@@ -12,3 +16,9 @@ export class GlobalCacheService extends Service {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
export class GlobalSessionStateService extends Service {
|
||||
constructor(public readonly globalSessionState: GlobalSessionState) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user