From 85d104c3752c377bfd40052a552b36779baa328f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 11 May 2023 22:39:37 -0400 Subject: [PATCH] fix: #11594 set the order of theme to same as the on it's replacing --- src/meta/themes.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/meta/themes.js b/src/meta/themes.js index d757cfb9ec..6cce964832 100644 --- a/src/meta/themes.js +++ b/src/meta/themes.js @@ -89,9 +89,9 @@ Themes.set = async (data) => { switch (data.type) { case 'local': { const current = await Meta.configs.get('theme:id'); + const score = await db.sortedSetScore('plugins:active', current); await db.sortedSetRemove('plugins:active', current); - const numPlugins = await db.sortedSetCard('plugins:active'); - await db.sortedSetAdd('plugins:active', numPlugins, data.id); + await db.sortedSetAdd('plugins:active', score || 0, data.id); if (current !== data.id) { const pathToThemeJson = path.join(nconf.get('themes_path'), data.id, 'theme.json'); @@ -103,9 +103,9 @@ Themes.set = async (data) => { config = JSON.parse(config); const activePluginsConfig = nconf.get('plugins:active'); if (!activePluginsConfig) { + const score = await db.sortedSetScore('plugins:active', current); await db.sortedSetRemove('plugins:active', current); - const numPlugins = await db.sortedSetCard('plugins:active'); - await db.sortedSetAdd('plugins:active', numPlugins, data.id); + await db.sortedSetAdd('plugins:active', score || 0, data.id); } else if (!activePluginsConfig.includes(data.id)) { // This prevents changing theme when configuration doesn't include it, but allows it otherwise winston.error(`When defining active plugins in configuration, changing themes requires adding the theme '${data.id}' to the list of active plugins before updating it in the ACP`);