mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
35 lines
1014 B
TypeScript
35 lines
1014 B
TypeScript
import { atom } from 'jotai';
|
|
import { atomWithObservable } from 'jotai/utils';
|
|
import { atomWithStorage } from 'jotai/utils';
|
|
import { Observable } from 'rxjs';
|
|
|
|
export const APP_SIDEBAR_OPEN = 'app-sidebar-open';
|
|
export const appSidebarOpenAtom = atomWithStorage(
|
|
APP_SIDEBAR_OPEN,
|
|
undefined as boolean | undefined
|
|
);
|
|
export const appSidebarFloatingAtom = atom(false);
|
|
|
|
export const appSidebarResizingAtom = atom(false);
|
|
export const appSidebarWidthAtom = atomWithStorage(
|
|
'app-sidebar-width',
|
|
256 /* px */
|
|
);
|
|
|
|
export const updateAvailableAtom = atomWithObservable<boolean>(() => {
|
|
return new Observable<boolean>(subscriber => {
|
|
subscriber.next(false);
|
|
if (typeof window !== 'undefined') {
|
|
const isMacosDesktop = environment.isDesktop && environment.isMacOs;
|
|
if (isMacosDesktop) {
|
|
const dispose = window.events?.updater.onClientUpdateReady(() => {
|
|
subscriber.next(true);
|
|
});
|
|
return () => {
|
|
dispose?.();
|
|
};
|
|
}
|
|
}
|
|
});
|
|
});
|