From 059c52b3700a7cac9c224f82b8ecc535cc7226be Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Tue, 1 Nov 2022 13:29:08 -0700 Subject: [PATCH] Attempt to fix Android cookies --- frontend/src/components/SettingsForm/index.tsx | 5 ++++- frontend/src/services/System/SystemNativeClient/index.ts | 5 +++-- frontend/src/services/System/SystemWebClient/index.ts | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/SettingsForm/index.tsx b/frontend/src/components/SettingsForm/index.tsx index 9f211e24..4417529e 100644 --- a/frontend/src/components/SettingsForm/index.tsx +++ b/frontend/src/components/SettingsForm/index.tsx @@ -129,7 +129,10 @@ const SettingsForm = ({ onChange={(e) => { const fontSize = e.target.value; setSettings({ ...settings, fontSize }); - systemClient.setCookie(`settings_fontsize_${settings.frontend}`, fontSize); + systemClient.setCookie( + `settings_fontsize_${settings.frontend}`, + fontSize.toString(), + ); }} valueLabelDisplay='off' marks={fontSizes.map(({ label, value }) => ({ diff --git a/frontend/src/services/System/SystemNativeClient/index.ts b/frontend/src/services/System/SystemNativeClient/index.ts index 15a149a7..c27770dc 100644 --- a/frontend/src/services/System/SystemNativeClient/index.ts +++ b/frontend/src/services/System/SystemNativeClient/index.ts @@ -22,8 +22,9 @@ class SystemNativeClient implements SystemClient { }); }; - public getCookie: (key: string) => string | undefined = (key) => { - return window.NativeRobosats?.cookies[key]; + public getCookie: (key: string) => string = (key) => { + const cookie = window.NativeRobosats?.cookies[key]; + return cookie === null || cookie === undefined ? '' : cookie; }; public setCookie: (key: string, value: string) => void = (key, value) => { diff --git a/frontend/src/services/System/SystemWebClient/index.ts b/frontend/src/services/System/SystemWebClient/index.ts index 2720f724..3aab1a3c 100644 --- a/frontend/src/services/System/SystemWebClient/index.ts +++ b/frontend/src/services/System/SystemWebClient/index.ts @@ -27,7 +27,7 @@ class SystemWebClient implements SystemClient { } }; - public getCookie: (key: string) => string | undefined = (key) => { + public getCookie: (key: string) => string = (key) => { let cookieValue = null; if (document.cookie && document.cookie !== '') { const cookies = document.cookie.split(';');