Node.js based forum software built for the modern web
fix: preserve order when changing parent
Barış Soner Uşaklı2ceda70a9795
diff --git a/src/categories/update.js b/src/categories/update.jsindex 438e833639..cdca138635 100644--- a/src/categories/update.js+++ b/src/categories/update.js@@ -69,10 +69,11 @@ module.exports = function (Categories) {if (childrenCids.includes(newParent)) {throw new Error('[[error:cant-set-child-as-parent]]');}- const oldParent = await Categories.getCategoryField(cid, 'parentCid');+ const categoryData = await Categories.getCategoryFields(cid, ['parentCid', 'order']);+ const oldParent = categoryData.parentCid;await Promise.all([db.sortedSetRemove(`cid:${oldParent}:children`, cid),- db.sortedSetAdd(`cid:${newParent}:children`, cid, cid),+ db.sortedSetAdd(`cid:${newParent}:children`, categoryData.order, cid),db.setObjectField(`category:${cid}`, 'parentCid', newParent),]);