From 3b9e11904460f2eb2b123e0b0e62b2582287eb62 Mon Sep 17 00:00:00 2001 From: Leonabcd123 <156839416+Leonabcd123@users.noreply.github.com> Date: Fri, 9 Jan 2026 14:35:16 +0200 Subject: [PATCH] Refactor --- frontend/src/ts/modals/edit-tag.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/frontend/src/ts/modals/edit-tag.ts b/frontend/src/ts/modals/edit-tag.ts index e01bcde89..d400c2b5a 100644 --- a/frontend/src/ts/modals/edit-tag.ts +++ b/frontend/src/ts/modals/edit-tag.ts @@ -151,17 +151,19 @@ const actionModals: Record = { }; } - DB.getSnapshot()?.tags?.forEach((tag) => { - if (tag._id === tagId) { - tag.personalBests = { - time: {}, - words: {}, - quote: {}, - zen: {}, - custom: {}, - }; - } - }); + const matchingTag = DB.getSnapshot()?.tags.find( + (tag) => tag._id === tagId, + ); + + if (matchingTag !== undefined) { + matchingTag.personalBests = { + time: {}, + words: {}, + quote: {}, + zen: {}, + custom: {}, + }; + } void Settings.update(); return { status: 1, message: `Tag PB cleared` };