Skip to content

Commit

Permalink
Merge pull request #21 from CMU-313/eric-p1-refactor
Browse files Browse the repository at this point in the history
Added refactored code from p1
  • Loading branch information
ericlin2 authored Sep 22, 2024
2 parents 3d490ca + 159603d commit 56862d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/topics/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -158,7 +158,7 @@ module.exports = function (Topics) {

// update 'tags' field in topic hash
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);
Expand Down

0 comments on commit 56862d5

Please sign in to comment.