From d75b85482878ac0d1e1f89b77571b569bb4eb916 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Tue, 31 Jan 2023 17:40:46 +0200 Subject: [PATCH] Fix add to default category code for dms and gms (#7057) (#7064) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit aa6c1ff0583751085967c9fdffd67789f7b24421) Co-authored-by: Daniel Espino GarcĂ­a --- app/actions/local/category.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/actions/local/category.ts b/app/actions/local/category.ts index f3956dc9c..73f19eace 100644 --- a/app/actions/local/category.ts +++ b/app/actions/local/category.ts @@ -9,7 +9,6 @@ import {queryMyTeams} from '@queries/servers/team'; import {isDMorGM} from '@utils/channel'; import {logError} from '@utils/log'; -import type {Model} from '@nozbe/watermelondb'; import type ChannelModel from '@typings/database/models/servers/channel'; export const deleteCategory = async (serverUrl: string, categoryId: string) => { @@ -80,7 +79,6 @@ export async function addChannelToDefaultCategory(serverUrl: string, channel: Ch return {error: 'no current user id'}; } - const models: Model[] = []; const categoriesWithChannels: CategoryWithChannels[] = []; if (isDMorGM(channel)) { @@ -100,11 +98,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); }