Skip to content

Commit

Permalink
fix:AG-10327 user rules fullscreen
Browse files Browse the repository at this point in the history
editor store settings
  • Loading branch information
Mizzick committed Oct 1, 2021
1 parent 49cdc7a commit 7633bff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
Expand Up @@ -37,6 +37,12 @@ export const UserRulesEditor = observer(({ fullscreen, uiStore }) => {
shouldResetSize = true;
}

useEffect(() => {
(async () => {
await store.requestSettingsData();
})();
}, [store]);

// Get initial storage content and set to the editor
useEffect(() => {
(async () => {
Expand Down
Expand Up @@ -8,7 +8,6 @@ import {
} from 'mobx';

import { messenger } from '../../../services/messenger';
// import { optionsStorage } from '../../../options/options-storage';
import { createSavingService, EVENTS as SAVING_FSM_EVENTS, STATES } from '../Editor/savingFSM';

const savingService = createSavingService({
Expand All @@ -19,6 +18,8 @@ const savingService = createSavingService({
});

class UserRulesEditorStore {
@observable settings = null;

@observable userRulesEditorContentChanged = false;

@observable userRulesEditorWrap = null;
Expand All @@ -42,6 +43,15 @@ class UserRulesEditorStore {
});
}

@action
async requestSettingsData() {
const data = await messenger.getOptionsData();

runInAction(() => {
this.settings = data.settings;
});
}

@action
setUserRulesEditorContentChangedState = (state) => {
this.userRulesEditorContentChanged = state;
Expand All @@ -58,21 +68,32 @@ class UserRulesEditorStore {
};

@action
setUserRulesEditorWrapMode() {
// TODO: work with settings
updateSetting(settingId, value) {
if (this.settings) {
this.settings.values[settingId] = value;
}

messenger.changeUserSetting(settingId, value);
}

@action
async setUserRulesEditorWrapMode() {
this.userRulesEditorWrap = !this.userRulesEditorWrap;
// optionsStorage.setItem(
// optionsStorage.KEYS.USER_RULES_EDITOR_WRAP,
// this.userRulesEditorWrap,
// );
if (this.settings) {
await this.updateSetting(
this.settings.names.USER_RULES_EDITOR_WRAP, this.userRulesEditorWrap,
);
}
}

@computed
get userRulesEditorWrapState() {
// this.userRulesEditorWrap = optionsStorage.getItem(
// optionsStorage.KEYS.USER_RULES_EDITOR_WRAP,
// );
if (this.settings) {
this.userRulesEditorWrap = this.settings.values[
this.settings.names.USER_RULES_EDITOR_WRAP
];
}

return this.userRulesEditorWrap;
}

Expand Down

0 comments on commit 7633bff

Please sign in to comment.