feat: SNJS preferences

This commit is contained in:
Baptiste Grob
2020-12-10 14:58:00 +01:00
parent 993d241c72
commit aca5ad0dfa
9 changed files with 130 additions and 263 deletions

View File

@@ -19,20 +19,19 @@ import { action, makeObservable, observable } from 'mobx';
import { Bridge } from '@/services/bridge';
export enum AppStateEvent {
TagChanged = 1,
ActiveEditorChanged = 2,
PreferencesChanged = 3,
PanelResized = 4,
EditorFocused = 5,
BeganBackupDownload = 6,
EndedBackupDownload = 7,
WindowDidFocus = 9,
WindowDidBlur = 10,
TagChanged,
ActiveEditorChanged,
PanelResized,
EditorFocused,
BeganBackupDownload,
EndedBackupDownload,
WindowDidFocus,
WindowDidBlur,
};
export enum EventSource {
UserInteraction = 1,
Script = 2
UserInteraction,
Script,
};
type ObserverCallback = (event: AppStateEvent, data?: any) => Promise<void>
@@ -103,7 +102,6 @@ export class AppState {
rootScopeCleanup2: any;
onVisibilityChange: any;
selectedTag?: SNTag;
userPreferences?: SNUserPrefs;
multiEditorEnabled = false;
showBetaWarning = false;
readonly actionsMenu = new ActionsMenuState();
@@ -379,13 +377,6 @@ export class AppState {
return this.selectedTag;
}
setUserPreferences(preferences: SNUserPrefs) {
this.userPreferences = preferences;
this.notifyEvent(
AppStateEvent.PreferencesChanged
);
}
panelDidResize(name: string, collapsed: boolean) {
this.notifyEvent(
AppStateEvent.PanelResized,

View File

@@ -22,7 +22,6 @@ import {
NativeExtManager,
StatusManager,
ThemeManager,
PreferencesManager,
KeyboardManager
} from '@/services';
import { AppState } from '@/ui_models/app_state';
@@ -38,7 +37,6 @@ type WebServices = {
nativeExtService: NativeExtManager
statusManager: StatusManager
themeService: ThemeManager
prefsService: PreferencesManager
keyboardService: KeyboardManager
}
@@ -141,10 +139,6 @@ export class WebApplication extends SNApplication {
return this.webServices.themeService;
}
public getPrefsService() {
return this.webServices.prefsService;
}
public getKeyboardService() {
return this.webServices.keyboardService;
}

View File

@@ -7,7 +7,6 @@ import {
KeyboardManager,
AutolockService,
NativeExtManager,
PreferencesManager,
StatusManager,
ThemeManager
} from '@/services';
@@ -82,9 +81,6 @@ export class ApplicationGroup extends SNApplicationGroup {
const nativeExtService = new NativeExtManager(
application
);
const prefsService = new PreferencesManager(
application
);
const statusService = new StatusManager();
const themeService = new ThemeManager(
application,
@@ -96,7 +92,6 @@ export class ApplicationGroup extends SNApplicationGroup {
keyboardService,
autolockService,
nativeExtService,
prefsService,
statusManager: statusService,
themeService
});