-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3019 - Fix templates not being updated after changing ignoreChiralFl…
…ag setting
- Loading branch information
Showing
9 changed files
with
121 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/ketcher-react/src/script/ui/utils/optionsManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { KETCHER_SAVED_OPTIONS_KEY } from 'src/constants'; | ||
import { storage } from '../storage-ext'; | ||
|
||
interface SavedOptions { | ||
ignoreChiralFlag?: boolean; | ||
} | ||
|
||
export class OptionsManager { | ||
static getOptions(): SavedOptions { | ||
try { | ||
return JSON.parse(storage.getItem(KETCHER_SAVED_OPTIONS_KEY) || '{}'); | ||
} catch (e) { | ||
return {} as SavedOptions; | ||
} | ||
} | ||
|
||
static saveSettings(settings: SavedOptions) { | ||
if (!settings) { | ||
return; | ||
} | ||
storage.setItem(KETCHER_SAVED_OPTIONS_KEY, JSON.stringify(settings)); | ||
} | ||
|
||
static get ignoreChiralFlag() { | ||
const { ignoreChiralFlag } = this.getOptions(); | ||
|
||
return ignoreChiralFlag; | ||
} | ||
|
||
static set ignoreChiralFlag(ignoreChiralFlag: boolean | undefined) { | ||
const settings = this.getOptions(); | ||
|
||
this.saveSettings({ | ||
...settings, | ||
ignoreChiralFlag, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters