From d3c093bb42a87aa0b82577acb0af23690d99eaa5 Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 28 Mar 2022 17:41:16 +0200 Subject: [PATCH] checking size of config removed confusing error --- backend/dao/preset.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/backend/dao/preset.ts b/backend/dao/preset.ts index f4f2b0b86..a84799447 100644 --- a/backend/dao/preset.ts +++ b/backend/dao/preset.ts @@ -51,14 +51,11 @@ class PresetDAO { name: string, config: any ): Promise { - const presetUpdates = config ? { name, config } : { name }; - const updateResult = await db + const presetUpdates = + config && Object.keys(config).length > 0 ? { name, config } : { name }; + await db .collection(COLLECTION_NAME) .updateOne(getPresetKeyFilter(uid, presetId), { $set: presetUpdates }); - - if (updateResult.modifiedCount === 0) { - throw new MonkeyError(404, "Preset not found"); - } } static async removePreset(uid: string, presetId: string): Promise {