From 5182944b70835790f1f41e4723750e0b5b878524 Mon Sep 17 00:00:00 2001 From: Farhan Ahmad Nurzi Date: Mon, 15 Apr 2024 13:06:13 +0800 Subject: [PATCH 1/2] fix: value undefined error --- src/javascript/app/base/page.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/javascript/app/base/page.js b/src/javascript/app/base/page.js index 51db50d5c12..ff0053820ec 100644 --- a/src/javascript/app/base/page.js +++ b/src/javascript/app/base/page.js @@ -70,8 +70,8 @@ const Page = (() => { }; // reload the page when the client account values(except balance and startsession) is changed on other pages. const active_loginid = LocalStore.get('active_loginid'); - const new_currency = JSON.parse(evt.newValue)[active_loginid].currency; - const old_currency = JSON.parse(evt.oldValue)[active_loginid].currency; + const new_currency = JSON.parse(evt.newValue)[active_loginid] ? JSON.parse(evt.newValue)[active_loginid].currency : ''; + const old_currency = JSON.parse(evt.oldValue)[active_loginid] ? JSON.parse(evt.oldValue)[active_loginid].currency : ''; if (removedSessionAndBalnce(evt.newValue) !== removedSessionAndBalnce(evt.oldValue) && old_currency !== new_currency) { From dcafab2e92b52622f979c65751648aef20b3d536 Mon Sep 17 00:00:00 2001 From: Farhan Ahmad Nurzi Date: Mon, 15 Apr 2024 15:44:41 +0800 Subject: [PATCH 2/2] refactor: separate json parsing --- src/javascript/app/base/page.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/javascript/app/base/page.js b/src/javascript/app/base/page.js index ff0053820ec..1836e18cd3d 100644 --- a/src/javascript/app/base/page.js +++ b/src/javascript/app/base/page.js @@ -70,8 +70,10 @@ const Page = (() => { }; // reload the page when the client account values(except balance and startsession) is changed on other pages. const active_loginid = LocalStore.get('active_loginid'); - const new_currency = JSON.parse(evt.newValue)[active_loginid] ? JSON.parse(evt.newValue)[active_loginid].currency : ''; - const old_currency = JSON.parse(evt.oldValue)[active_loginid] ? JSON.parse(evt.oldValue)[active_loginid].currency : ''; + const new_accounts = JSON.parse(evt.newValue); + const old_accounts = JSON.parse(evt.oldValue); + const new_currency = new_accounts[active_loginid] ? new_accounts[active_loginid].currency : ''; + const old_currency = old_accounts[active_loginid] ? old_accounts[active_loginid].currency : ''; if (removedSessionAndBalnce(evt.newValue) !== removedSessionAndBalnce(evt.oldValue) && old_currency !== new_currency) {