commit fc9bca6b6ad3a5d314e9a708493359d3247f6633
parent 350bc323c6b8d3a02345767351ef86d99ceea608
Author: lash <dev@holbrook.no>
Date: Mon, 6 Feb 2023 17:16:21 +0000
Deduplicate token listings
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/js/manual_test_browser.js b/js/manual_test_browser.js
@@ -1,10 +1,17 @@
// This file contains a rought-edged example implementation of a user interface for reading and writing Craft NFT tokens.
+let tokenListCache = [];
/**
* Emitted when a new token has been found.
*/
window.addEventListener('token', (e) => {
+ for (let i = tokenListCache.length - 1; i > -1; i--) {
+ if (tokenListCache[i] == e.detail.tokenId) {
+ return;
+ }
+ }
+ tokenListCache.push(e.detail.tokenId);
const li = document.createElement('li');
const a = document.createElement('a');
a.setAttribute('onClick', 'uiViewToken("' + e.detail.tokenId + '")');