mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
chore: rename AppSidebarLocalState to AppSidebarState
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Entity, LiveData } from '@toeverything/infra';
|
||||
import { map } from 'rxjs';
|
||||
|
||||
import type { AppSidebarLocalState } from '../providers/storage';
|
||||
import type { AppSidebarState } from '../providers/storage';
|
||||
|
||||
const isMobile = !BUILD_CONFIG.isElectron && window.innerWidth < 768;
|
||||
|
||||
@@ -11,19 +11,19 @@ enum APP_SIDEBAR_STATE {
|
||||
}
|
||||
|
||||
export class AppSidebar extends Entity {
|
||||
constructor(private readonly appSidebarLocalState: AppSidebarLocalState) {
|
||||
constructor(private readonly appSidebarState: AppSidebarState) {
|
||||
super();
|
||||
}
|
||||
|
||||
open$ = LiveData.from(
|
||||
this.appSidebarLocalState
|
||||
this.appSidebarState
|
||||
.watch<boolean>(APP_SIDEBAR_STATE.OPEN)
|
||||
.pipe(map(value => value ?? !isMobile)),
|
||||
!isMobile
|
||||
);
|
||||
|
||||
width$ = LiveData.from(
|
||||
this.appSidebarLocalState
|
||||
this.appSidebarState
|
||||
.watch<number>(APP_SIDEBAR_STATE.WIDTH)
|
||||
.pipe(map(value => value ?? 248)),
|
||||
248
|
||||
@@ -33,7 +33,7 @@ export class AppSidebar extends Entity {
|
||||
resizing$ = new LiveData<boolean>(false);
|
||||
|
||||
getCachedAppSidebarOpenState = () => {
|
||||
return this.appSidebarLocalState.get<boolean>(APP_SIDEBAR_STATE.OPEN);
|
||||
return this.appSidebarState.get<boolean>(APP_SIDEBAR_STATE.OPEN);
|
||||
};
|
||||
|
||||
toggleSidebar = () => {
|
||||
@@ -41,7 +41,7 @@ export class AppSidebar extends Entity {
|
||||
};
|
||||
|
||||
setOpen = (open: boolean) => {
|
||||
this.appSidebarLocalState.set(APP_SIDEBAR_STATE.OPEN, open);
|
||||
this.appSidebarState.set(APP_SIDEBAR_STATE.OPEN, open);
|
||||
if (!open && this.hoverFloating$.value) {
|
||||
const timeout = setTimeout(() => {
|
||||
this.setHoverFloating(false);
|
||||
@@ -66,6 +66,6 @@ export class AppSidebar extends Entity {
|
||||
};
|
||||
|
||||
setWidth = (width: number) => {
|
||||
this.appSidebarLocalState.set(APP_SIDEBAR_STATE.WIDTH, width);
|
||||
this.appSidebarState.set(APP_SIDEBAR_STATE.WIDTH, width);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import {
|
||||
wrapMemento,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
import type { AppSidebarLocalState } from '../providers/storage';
|
||||
import type { AppSidebarState } from '../providers/storage';
|
||||
|
||||
export class AppSidebarLocalStateImpl implements AppSidebarLocalState {
|
||||
export class AppSidebarStateImpl implements AppSidebarState {
|
||||
wrapped: Memento;
|
||||
constructor(globalState: GlobalState) {
|
||||
this.wrapped = wrapMemento(globalState, `app-sidebar-state:`);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { type Framework, GlobalState } from '@toeverything/infra';
|
||||
|
||||
import { AppSidebar } from './entities/app-sidebar';
|
||||
import { AppSidebarLocalStateImpl } from './impls/storage';
|
||||
import { AppSidebarLocalState } from './providers/storage';
|
||||
import { AppSidebarStateImpl } from './impls/storage';
|
||||
import { AppSidebarState } from './providers/storage';
|
||||
import { AppSidebarService } from './services/app-sidebar';
|
||||
|
||||
export * from './services/app-sidebar';
|
||||
@@ -10,6 +10,6 @@ export * from './services/app-sidebar';
|
||||
export function configureAppSidebarModule(framework: Framework) {
|
||||
framework
|
||||
.service(AppSidebarService)
|
||||
.entity(AppSidebar, [AppSidebarLocalState])
|
||||
.impl(AppSidebarLocalState, AppSidebarLocalStateImpl, [GlobalState]);
|
||||
.entity(AppSidebar, [AppSidebarState])
|
||||
.impl(AppSidebarState, AppSidebarStateImpl, [GlobalState]);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createIdentifier, type Memento } from '@toeverything/infra';
|
||||
|
||||
export interface AppSidebarLocalState extends Memento {}
|
||||
export interface AppSidebarState extends Memento {}
|
||||
|
||||
export const AppSidebarLocalState = createIdentifier<AppSidebarLocalState>(
|
||||
'AppSidebarLocalState'
|
||||
);
|
||||
export const AppSidebarState =
|
||||
createIdentifier<AppSidebarState>('AppSidebarState');
|
||||
|
||||
Reference in New Issue
Block a user