From 14515f6004513d86b1189c5609c3b54b19961236 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 21 Sep 2022 16:02:20 -0400 Subject: [PATCH 1/6] fix: add lru-cache to checked packages, to fix upgrade issue with lru-cache --- src/cli/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cli/index.js b/src/cli/index.js index 5c3c01fd88..86bfc127b4 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -41,6 +41,7 @@ try { checkVersion('commander'); checkVersion('chalk'); checkVersion('lodash'); + checkVersion('lru-cache'); } catch (e) { if (['ENOENT', 'DEP_WRONG_VERSION', 'MODULE_NOT_FOUND'].includes(e.code)) { console.warn('Dependencies outdated or not yet installed.'); From aad0a618c86f45055827dada020bad11b041bd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 23 Sep 2022 09:09:15 -0400 Subject: [PATCH 2/6] fix: scroll to post if theme doesn't have top navbar --- public/src/modules/navigator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index 824f55434a..2937470707 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -559,7 +559,7 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct } const postHeight = scrollTo.outerHeight(true); - const navbarHeight = components.get('navbar').outerHeight(true); + const navbarHeight = components.get('navbar').outerHeight(true) || 0; const topicHeaderHeight = $('.topic-header').outerHeight(true) || 0; const viewportHeight = $(window).height(); From 803398e91549b59129a44f558a6eeb1556a057bc Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 23 Sep 2022 13:10:14 -0400 Subject: [PATCH 3/6] fix: broken flag history on flag update --- public/src/client/flags/detail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/client/flags/detail.js b/public/src/client/flags/detail.js index fdffc096f2..782304f318 100644 --- a/public/src/client/flags/detail.js +++ b/public/src/client/flags/detail.js @@ -26,7 +26,7 @@ define('forum/flags/detail', [ return memo; }, {}); - api.put(`/flags/${ajaxify.data.flagId}`, data).then((history) => { + api.put(`/flags/${ajaxify.data.flagId}`, data).then(({ history }) => { alerts.success('[[flags:updated]]'); Detail.reloadHistory(history); }).catch(alerts.error); From 7240e8ce575fbca92ffb94ad6fdf4a81621679d8 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 28 Sep 2022 10:27:50 -0400 Subject: [PATCH 4/6] =?UTF-8?q?chore:=20=F0=9F=A4=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd4ac1c692..2fa3d9ec12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,6 @@ * bring back treding plugins (8aa1596d) * incrementing version number - v2.5.2 (babcd17e) * update changelog for v2.5.2 (84b6a7c7) -* incrementing version number - v2.5.1 (ce3aa950) -* incrementing version number - v2.5.0 (01d276cb) -* incrementing version number - v2.4.5 (dd3e1a28) -* incrementing version number - v2.4.4 (d5525c87) -* incrementing version number - v2.4.3 (9c647c6c) -* incrementing version number - v2.4.2 (3aa7b855) -* incrementing version number - v2.4.1 (60cbd148) -* incrementing version number - v2.4.0 (4834cde3) -* incrementing version number - v2.3.1 (d2425942) -* incrementing version number - v2.3.0 (046ea120) ##### New Features From 989b55d07e6fc720e1d9792c6a192546dacc8971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 1 Oct 2022 22:15:06 -0400 Subject: [PATCH 5/6] fix: crash in category drag, closes #10932 happens when a child is dragged to root or from root to a nested level --- public/src/admin/manage/categories.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index cae9f782ca..d5eb350038 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -212,11 +212,17 @@ define('admin/manage/categories', [ const oldParentCid = parseInt(e.from.getAttribute('data-cid'), 10); const newParentCid = parseInt(e.to.getAttribute('data-cid'), 10); if (oldParentCid !== newParentCid) { - document.querySelector(`.categories li[data-cid="${newParentCid}"] .toggle`).classList.toggle('hide', false); + const toggle = document.querySelector(`.categories li[data-cid="${newParentCid}"] .toggle`); + if (toggle) { + toggle.classList.toggle('hide', false); + } const children = document.querySelectorAll(`.categories li[data-cid="${oldParentCid}"] ul[data-cid] li[data-cid]`); if (!children.length) { - document.querySelector(`.categories li[data-cid="${oldParentCid}"] .toggle`).classList.toggle('hide', true); + const toggle = document.querySelector(`.categories li[data-cid="${oldParentCid}"] .toggle`); + if (toggle) { + toggle.classList.toggle('hide', true); + } } e.item.dataset.parentCid = newParentCid; From 177d9048128b39f4daf2322cc5958fea118f95bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 3 Oct 2022 09:40:54 -0400 Subject: [PATCH 6/6] fix: category ordering add test --- src/categories/update.js | 2 +- test/categories.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/categories/update.js b/src/categories/update.js index 20b14361fb..d4be83edb8 100644 --- a/src/categories/update.js +++ b/src/categories/update.js @@ -108,7 +108,7 @@ module.exports = function (Categories) { if (currentIndex === -1) { throw new Error('[[error:no-category]]'); } - // moves cid to index order-1 in the array + // moves cid to index order - 1 in the array if (childrenCids.length > 1) { childrenCids.splice(Math.max(0, order - 1), 0, childrenCids.splice(currentIndex, 1)[0]); } diff --git a/test/categories.js b/test/categories.js index 98d15c28bc..cd28ee33ef 100644 --- a/test/categories.js +++ b/test/categories.js @@ -421,6 +421,22 @@ describe('Categories', () => { assert.equal(data.icon, updateData[cid].icon); }); + it('should properly order categories', async () => { + const p1 = await Categories.create({ name: 'p1', description: 'd', parentCid: 0, order: 1 }); + const c1 = await Categories.create({ name: 'c1', description: 'd1', parentCid: p1.cid, order: 1 }); + const c2 = await Categories.create({ name: 'c2', description: 'd2', parentCid: p1.cid, order: 2 }); + const c3 = await Categories.create({ name: 'c3', description: 'd3', parentCid: p1.cid, order: 3 }); + // move c1 to second place + await apiCategories.update({ uid: adminUid }, { [c1.cid]: { order: 2 } }); + let cids = await db.getSortedSetRange(`cid:${p1.cid}:children`, 0, -1); + assert.deepStrictEqual(cids.map(Number), [c2.cid, c1.cid, c3.cid]); + + // move c3 to front + await apiCategories.update({ uid: adminUid }, { [c3.cid]: { order: 1 } }); + cids = await db.getSortedSetRange(`cid:${p1.cid}:children`, 0, -1); + assert.deepStrictEqual(cids.map(Number), [c3.cid, c2.cid, c1.cid]); + }); + it('should not remove category from parent if parent is set again to same category', async () => { const parentCat = await Categories.create({ name: 'parent', description: 'poor parent' }); const updateData = {};