From 3c8c804fc3447cfa852d15ea0b8ead3f84e656aa Mon Sep 17 00:00:00 2001 From: Savely Savianok <1986developer@gmail.com> Date: Tue, 25 Feb 2025 21:05:50 +0300 Subject: [PATCH] feat: fixed reset of app settings --- app-side/index.js | 1 + page/index.js | 5 +++-- setting/index.js | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app-side/index.js b/app-side/index.js index f97ba7c..1932ed6 100644 --- a/app-side/index.js +++ b/app-side/index.js @@ -9,6 +9,7 @@ AppSideService( onRequest(req, res){ if(req.method === 'totps'){ console.log(req) + console.log(`sending response: ${settings.settingsStorage.getItem('TOTPs')}`) res(null, settings.settingsStorage.getItem('TOTPs')) } }, diff --git a/page/index.js b/page/index.js index 9f84e28..94b04a0 100644 --- a/page/index.js +++ b/page/index.js @@ -9,10 +9,11 @@ Page( onInit() { this.getTOTPData().then((x) => { console.log(x) - app._options.globalData.TOTPS = x ?? [] + app._options.globalData.TOTPS = JSON.parse(x) ?? [] this.initPage() }) - .catch(() => { + .catch((x) => { + console.log(x) app._options.globalData.TOTPS = [] this.initPage() }) diff --git a/setting/index.js b/setting/index.js index 6b09be0..683dad8 100644 --- a/setting/index.js +++ b/setting/index.js @@ -6,7 +6,8 @@ AppSettingsPage({ build(props) { _props = props; - const storage = props.settingsStorage.getItem("TOTPs") ?? [] + console.log(props.settingsStorage.getItem("TOTPs")) + const storage = JSON.parse(props.settingsStorage.getItem("TOTPs") ?? "[]") const totpEntrys = GetTOTPList(storage) const createButton = TextInput({ placeholder: "otpauth://", @@ -160,5 +161,5 @@ function GetTOTPList(storage){ function updateStorage(storage){ console.log("new storage is:") console.log(storage) - _props.settingsStorage.setItem('TOTPs', storage) + _props.settingsStorage.setItem('TOTPs', JSON.stringify(storage)) } \ No newline at end of file