From 7fc05af09e3359b9a4e99db0f375a8a73296dc47 Mon Sep 17 00:00:00 2001 From: NongMO <31816449+nongmo677@users.noreply.github.com> Date: Sun, 3 Dec 2023 21:19:22 +0800 Subject: [PATCH] fix: custom chat title (#534) * Fix: Update Custom Chat Title Based on chatId * remove `new:true` option * Update update.ts --------- Co-authored-by: Archer <545436317@qq.com> --- projects/app/src/pages/api/core/chat/update.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/app/src/pages/api/core/chat/update.ts b/projects/app/src/pages/api/core/chat/update.ts index 0d64c87c0..6f0b2a59d 100644 --- a/projects/app/src/pages/api/core/chat/update.ts +++ b/projects/app/src/pages/api/core/chat/update.ts @@ -13,9 +13,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) await authChat({ req, authToken: true, chatId }); - await MongoChat.findByIdAndUpdate(chatId, { - ...(customTitle ? { customTitle } : {}), - ...(top ? { top } : { top: null }) + await MongoChat.findOneAndUpdate({ chatId }, { + ...(customTitle && { customTitle }), + ...(top && { top }) }); jsonRes(res); } catch (err) {