From e87694289266f3d367b1ee93cd2902ec8fe918cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Tue, 31 Jan 2023 17:01:39 +0100 Subject: [PATCH] Fix add to default category code for dms and gms (#7057) (#7066) --- app/actions/local/category.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/actions/local/category.ts b/app/actions/local/category.ts index 26e8abb05..011a4c80c 100644 --- a/app/actions/local/category.ts +++ b/app/actions/local/category.ts @@ -81,7 +81,6 @@ export async function addChannelToDefaultCategory(serverUrl: string, channel: Ch return {error: 'no current user id'}; } - const models: Model[] = []; const categoriesWithChannels: CategoryWithChannels[] = []; if (isDMorGM(channel)) { @@ -101,11 +100,10 @@ export async function addChannelToDefaultCategory(serverUrl: string, channel: Ch cwc.channel_ids.unshift(channel.id); categoriesWithChannels.push(cwc); } - - const ccModels = await prepareCategoryChannels(operator, categoriesWithChannels); - models.push(...ccModels); } + const models = await prepareCategoryChannels(operator, categoriesWithChannels); + if (models.length && !prepareRecordsOnly) { await operator.batchRecords(models); }