From aa6c1ff0583751085967c9fdffd67789f7b24421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Tue, 31 Jan 2023 16:38:25 +0100 Subject: [PATCH] Fix add to default category code for dms and gms (#7057) --- 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); }