From 13c5f20633eb34e0a1c0b659d9b21c9de9f7e050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lancelot=20de=20Ferri=C3=A8re?= Date: Wed, 24 Jan 2024 09:41:53 +0100 Subject: [PATCH] GC user items --- src/builder/UserItem.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/builder/UserItem.ts b/src/builder/UserItem.ts index 61adb98d..9620fe03 100644 --- a/src/builder/UserItem.ts +++ b/src/builder/UserItem.ts @@ -50,7 +50,11 @@ export abstract class GeneralizedUserItem implements perUserStorable { let reprocess = false; const promises = new Map>(); // Process metadata and clean it up where it seems like things went through (this is a bit optimistic but that's probably OK) - for (const tokenName in this.metadata) + for (const tokenName in this.metadata) { + if (this.metadata[tokenName].updates.length === 0) { + delete this.metadata[tokenName]; + continue; + } for (let i = 0; i < this.metadata[tokenName].updates.length; ++i) { const update = this.metadata[tokenName].updates[i]; // Clear the metadata if we are now ahead of it. @@ -97,6 +101,7 @@ export abstract class GeneralizedUserItem implements perUserStorable { } else tokens.push(tokenName); } + } // Update locally, then wait for pending stuff and see if we need to reprocess. this._tokenNames = tokens; for (const item of promises)