Skip to content

Commit

Permalink
Improved data sanitation for the Pinned items
Browse files Browse the repository at this point in the history
  • Loading branch information
FMaz008 committed Oct 5, 2024
1 parent 2e634e0 commit 83c80c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ async function createGridInterface() {
}

async function addPinnedTile(asin, queue, title, thumbnail, is_parent_asin, enrollment_guid) {
if (!asin) {
return false;
}

//Check if the pin already exist:
if (document.getElementById("vh-pin-" + asin) != undefined) return false;

Expand Down
8 changes: 8 additions & 0 deletions scripts/PinnedListMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class PinnedListMgr {
}

async addItem(asin, queue, title, thumbnail, isParentAsin, enrollmentGUID, save = true, broadcast = true) {
if (!asin || !queue || !title || !thumbnail || !isParentAsin || !enrollmentGUID) {
throw new Error("Invalid data");
}

if (save) await this.loadFromLocalStorage(); //Load the list in case it was altered in a different tab

this.mapPin.set(asin, {
Expand Down Expand Up @@ -145,6 +149,10 @@ class PinnedListMgr {
}
}

async wipe() {
let storableVal = JSON.stringify([]);
await browser.storage.local.set({ pinnedItems: storableVal });
}
/**
* Send new items on the server to be added or removed from the changed list.
*/
Expand Down

0 comments on commit 83c80c1

Please sign in to comment.