From 7d0616add761b6949683fb54537016a0032f644d Mon Sep 17 00:00:00 2001 From: b1ek Date: Wed, 17 May 2023 02:39:56 +1000 Subject: [PATCH] properly access static methods --- pairent_frontend_react/src/API/User.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pairent_frontend_react/src/API/User.js b/pairent_frontend_react/src/API/User.js index d48ee9b..1bed60c 100644 --- a/pairent_frontend_react/src/API/User.js +++ b/pairent_frontend_react/src/API/User.js @@ -22,7 +22,7 @@ class IAPIObject { static storage_key = undefined; static _checkStorageSupport() { - if (storage_key === undefined) { + if (this.storage_key === undefined) { throw Error('This doesn\'t support local storage'); } } @@ -40,14 +40,18 @@ class IAPIObject { /** @returns {ThisType} */ static restoreFromLocalStorage() { _checkStorageSupport(); - if (!window.localStorage.getItem(storage_key)) + if (!window.localStorage.getItem(this.storage_key)) return false; - return new APIToken(window.localStorage.getItem(storage_key)); + return new APIToken(window.localStorage.getItem(this.storage_key)); } /** @returns {boolean} */ static isCached() { - _checkStorageSupport(); + this._checkStorageSupport(); + if (window.localStorage.getItem(this.storage_key)) { + return true; + } + return false; } /**