update the URL record only when it exists

This commit is contained in:
buzz-lightsnack-2007 2024-05-09 11:40:56 +08:00
parent 2ca43d5995
commit 35663a3ed7

View file

@ -32,14 +32,17 @@ class Page_Results extends Page {
*/ */
async update(override = false) { async update(override = false) {
// Set the reference website when overriding or unset. // Set the reference website when overriding or unset.
if (override || !this[`ref`]) {this[`ref`] = await global.read([`last`])}; if (override || !this[`ref`]) {
let RECORD = await global.read([`last`]);
(RECORD) ? this[`ref`] = RECORD : false;
};
if (this[`ref`]) { if (this[`ref`]) {
// Get all the data. // Get all the data.
let DATA = { let DATA = {
"data": await global.read([`sites`, this[`ref`]]) "data": await global.read([`sites`, this[`ref`]])
} }
// Set the data. // Set the data.
this[`data`] = (DATA[`data`] && (typeof DATA[`data`]).includes(`obj`)) ? DATA[`data`] : (this[`data`] ? this[`data`] : {}); this[`data`] = (DATA[`data`] && (typeof DATA[`data`]).includes(`obj`)) ? DATA[`data`] : (this[`data`] ? this[`data`] : {});
} }