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/stores | |
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/stores')
-rw-r--r-- | src/stores/AppStore.js | 3 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 7 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 76956fdc7..a9c92fe87 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -17,6 +17,7 @@ import { readJsonSync } from 'fs-extra'; | |||
17 | import Store from './lib/Store'; | 17 | import Store from './lib/Store'; |
18 | import Request from './lib/Request'; | 18 | import Request from './lib/Request'; |
19 | import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; | 19 | import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; |
20 | import { cleanseJSObject } from '../jsUtils'; | ||
20 | import { isMac, isWindows, electronVersion, osRelease } from '../environment'; | 21 | import { isMac, isWindows, electronVersion, osRelease } from '../environment'; |
21 | import { ferdiumVersion, userDataPath, ferdiumLocale } from '../environment-remote'; | 22 | import { ferdiumVersion, userDataPath, ferdiumLocale } from '../environment-remote'; |
22 | import { generatedTranslations } from '../i18n/translations'; | 23 | import { generatedTranslations } from '../i18n/translations'; |
@@ -265,7 +266,7 @@ export default class AppStore extends Store { | |||
265 | } | 266 | } |
266 | 267 | ||
267 | @computed get debugInfo() { | 268 | @computed get debugInfo() { |
268 | const settings = JSON.parse(JSON.stringify(this.stores.settings.app)); | 269 | const settings = cleanseJSObject(this.stores.settings.app); |
269 | settings.lockedPassword = '******'; | 270 | settings.lockedPassword = '******'; |
270 | 271 | ||
271 | return { | 272 | return { |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index c8042e9de..3f551eddb 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -16,6 +16,7 @@ import { | |||
16 | } from '../helpers/recipe-helpers'; | 16 | } from '../helpers/recipe-helpers'; |
17 | import { workspaceStore } from '../features/workspaces'; | 17 | import { workspaceStore } from '../features/workspaces'; |
18 | import { DEFAULT_SERVICE_SETTINGS, KEEP_WS_LOADED_USID } from '../config'; | 18 | import { DEFAULT_SERVICE_SETTINGS, KEEP_WS_LOADED_USID } from '../config'; |
19 | import { cleanseJSObject } from '../jsUtils'; | ||
19 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 20 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
20 | import { ferdiumVersion } from '../environment-remote'; | 21 | import { ferdiumVersion } from '../environment-remote'; |
21 | 22 | ||
@@ -861,7 +862,7 @@ export default class ServicesStore extends Store { | |||
861 | const service = this.one(serviceId); | 862 | const service = this.one(serviceId); |
862 | 863 | ||
863 | // Make sure the args are clean, otherwise ElectronJS can't transmit them | 864 | // Make sure the args are clean, otherwise ElectronJS can't transmit them |
864 | const cleanArgs = JSON.parse(JSON.stringify(args)); | 865 | const cleanArgs = cleanseJSObject(args); |
865 | 866 | ||
866 | if (service.webview) { | 867 | if (service.webview) { |
867 | service.webview.send(channel, cleanArgs); | 868 | service.webview.send(channel, cleanArgs); |
@@ -1273,9 +1274,7 @@ export default class ServicesStore extends Store { | |||
1273 | 1274 | ||
1274 | if (service.webview) { | 1275 | if (service.webview) { |
1275 | // We need to completely clone the object, otherwise Electron won't be able to send the object via IPC | 1276 | // We need to completely clone the object, otherwise Electron won't be able to send the object via IPC |
1276 | const shareWithWebview = JSON.parse( | 1277 | const shareWithWebview = cleanseJSObject(service.shareWithWebview); |
1277 | JSON.stringify(service.shareWithWebview), | ||
1278 | ); | ||
1279 | 1278 | ||
1280 | debug('Initialize recipe', service.recipe.id, service.name); | 1279 | debug('Initialize recipe', service.recipe.id, service.name); |
1281 | service.webview.send( | 1280 | service.webview.send( |