diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2022-05-15 01:44:18 -0500 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-05-15 19:05:55 -0500 |
commit | 082b64b6c40fcab3ecf303f53ce83e7753894a32 (patch) | |
tree | 92626869949cc671effce89cfbcd52092243de5c /src/webview | |
parent | fix: revert "Typescript conversion" (#153) (diff) | |
download | ferdium-app-082b64b6c40fcab3ecf303f53ce83e7753894a32.tar.gz ferdium-app-082b64b6c40fcab3ecf303f53ce83e7753894a32.tar.zst ferdium-app-082b64b6c40fcab3ecf303f53ce83e7753894a32.zip |
Extract utility functions for JSON parsing
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/lib/Userscript.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/webview/lib/Userscript.ts b/src/webview/lib/Userscript.ts index f02a8f135..b0e4fb805 100644 --- a/src/webview/lib/Userscript.ts +++ b/src/webview/lib/Userscript.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { cleanseJSObject, convertToJSON } from '../../jsUtils'; | ||
2 | |||
1 | type Recipe = { | 3 | type Recipe = { |
2 | setBadge: (direct: number, indirect: number) => void; | 4 | setBadge: (direct: number, indirect: number) => void; |
3 | setDialogTitle: (title: string) => void; | 5 | setDialogTitle: (title: string) => void; |
@@ -34,7 +36,7 @@ export default class Userscript { | |||
34 | internal_setSettings(settings: any) { | 36 | internal_setSettings(settings: any) { |
35 | // This is needed to get a clean JS object from the settings itself to provide better accessibility | 37 | // This is needed to get a clean JS object from the settings itself to provide better accessibility |
36 | // Otherwise this will be a mobX instance | 38 | // Otherwise this will be a mobX instance |
37 | this.settings = JSON.parse(JSON.stringify(settings)); | 39 | this.settings = cleanseJSObject(settings); |
38 | } | 40 | } |
39 | 41 | ||
40 | /** | 42 | /** |
@@ -101,7 +103,7 @@ export default class Userscript { | |||
101 | const ferdiumUserKey = window.localStorage.getItem(`ferdium-user-${key}`); | 103 | const ferdiumUserKey = window.localStorage.getItem(`ferdium-user-${key}`); |
102 | 104 | ||
103 | if (ferdiumUserKey) { | 105 | if (ferdiumUserKey) { |
104 | return JSON.parse(ferdiumUserKey); | 106 | return convertToJSON(ferdiumUserKey); |
105 | } | 107 | } |
106 | } | 108 | } |
107 | } | 109 | } |