fix: #8982, copy color on tag rename, dont copy if target exists

refresh page on tag rename
This commit is contained in:
Barış Soner Uşaklı
2020-11-27 16:36:23 -05:00
parent 77a6dbacc4
commit d3c04afb98
3 changed files with 12 additions and 1 deletions

View File

@@ -14,5 +14,6 @@
"alerts.editing": "Editing tag(s)",
"alerts.confirm-delete": "Do you want to delete the selected tags?",
"alerts.update-success": "Tag Updated!"
"alerts.update-success": "Tag Updated!",
"reset-colors": "Reset colors"
}

View File

@@ -159,6 +159,7 @@ define('admin/manage/tags', [
return app.alertError(err.message);
}
app.alertSuccess('[[admin/manage/tags:alerts.update-success]]');
ajaxify.refresh();
});
},
},

View File

@@ -90,6 +90,15 @@ module.exports = function (Topics) {
}
newTagName = utils.cleanUpTag(newTagName, meta.config.maximumTagLength);
await Topics.createEmptyTag(newTagName);
const targetExists = await db.isSortedSetMember('tags:topic:count', newTagName);
const tagData = await db.getObject('tag:' + tag);
if (tagData && !targetExists) {
await db.setObject('tag:' + newTagName, {
color: tagData.color,
bgColor: tagData.bgColor,
});
}
await batch.processSortedSet('tag:' + tag + ':topics', async function (tids) {
const scores = await db.sortedSetScores('tag:' + tag + ':topics', tids);
await db.sortedSetAdd('tag:' + newTagName + ':topics', scores, tids);