From db666b2fbd7ef8e8b63319e2e5ba7b6c235a647a Mon Sep 17 00:00:00 2001 From: ericlin2 Date: Sat, 21 Sep 2024 14:54:10 -0400 Subject: [PATCH 1/2] Added refactored code from p1 --- src/topics/tags.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/topics/tags.js b/src/topics/tags.js index daab4e5f77..575e1d4738 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -157,8 +157,11 @@ module.exports = function (Topics) { await db.sortedSetRemove(cids.map(cid => `cid:${cid}:tag:${tag}:topics`), tids); // update 'tags' field in topic hash + function getTagValues(tags) { + return tags.map(tagItem => tagItem.value); + } topicData.forEach((topic) => { - topic.tags = topic.tags.map(tagItem => tagItem.value); + topic.tags = updateTagValues(topic.tags); const index = topic.tags.indexOf(tag); if (index !== -1) { topic.tags.splice(index, 1, newTagName); From 159603dfbc190f3d040676606f0516eb8bb4a4cc Mon Sep 17 00:00:00 2001 From: ericlin2 Date: Sat, 21 Sep 2024 15:02:03 -0400 Subject: [PATCH 2/2] copied newest commit --- src/topics/tags.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/topics/tags.js b/src/topics/tags.js index 575e1d4738..dc1063b807 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -131,7 +131,7 @@ module.exports = function (Topics) { await renameTag(tagData.value, tagData.newName); } }; - + const updateTagValues = tags => tags.map(tagItem => tagItem.value); async function renameTag(tag, newTagName) { if (!newTagName || tag === newTagName) { return; @@ -157,9 +157,6 @@ module.exports = function (Topics) { await db.sortedSetRemove(cids.map(cid => `cid:${cid}:tag:${tag}:topics`), tids); // update 'tags' field in topic hash - function getTagValues(tags) { - return tags.map(tagItem => tagItem.value); - } topicData.forEach((topic) => { topic.tags = updateTagValues(topic.tags); const index = topic.tags.indexOf(tag);