properly access static methods

This commit is contained in:
b1ek 2023-05-17 02:39:56 +10:00
parent ddaf8d4374
commit 7d0616add7
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 8 additions and 4 deletions

View File

@ -22,7 +22,7 @@ class IAPIObject {
static storage_key = undefined; static storage_key = undefined;
static _checkStorageSupport() { static _checkStorageSupport() {
if (storage_key === undefined) { if (this.storage_key === undefined) {
throw Error('This doesn\'t support local storage'); throw Error('This doesn\'t support local storage');
} }
} }
@ -40,14 +40,18 @@ class IAPIObject {
/** @returns {ThisType} */ /** @returns {ThisType} */
static restoreFromLocalStorage() { static restoreFromLocalStorage() {
_checkStorageSupport(); _checkStorageSupport();
if (!window.localStorage.getItem(storage_key)) if (!window.localStorage.getItem(this.storage_key))
return false; return false;
return new APIToken(window.localStorage.getItem(storage_key)); return new APIToken(window.localStorage.getItem(this.storage_key));
} }
/** @returns {boolean} */ /** @returns {boolean} */
static isCached() { static isCached() {
_checkStorageSupport(); this._checkStorageSupport();
if (window.localStorage.getItem(this.storage_key)) {
return true;
}
return false;
} }
/** /**