From 268ea407469bb379d8ac5b948f152eba2d837426 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 24 Aug 2022 16:09:29 +1000 Subject: [PATCH] fix: increase shorten length of the lastMessage saved in DB --- ts/node/sql.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/node/sql.ts b/ts/node/sql.ts index 89702f4e2..9d4ad82ad 100644 --- a/ts/node/sql.ts +++ b/ts/node/sql.ts @@ -420,6 +420,7 @@ function getConversationCount() { // tslint:disable-next-line: max-func-body-length // tslint:disable-next-line: cyclomatic-complexity +// tslint:disable-next-line: max-func-body-length function saveConversation(data: ConversationAttributes, instance?: BetterSqlite3.Database) { const formatted = assertValidConversationAttributes(data); @@ -458,10 +459,13 @@ function saveConversation(data: ConversationAttributes, instance?: BetterSqlite3 conversationIdOrigin, } = formatted; - // shorten the last message as we never need more than 60 chars (and it bloats the redux/ipc calls uselessly + const maxLength = 300; + // shorten the last message as we never need more than `maxLength` chars (and it bloats the redux/ipc calls uselessly. const shortenedLastMessage = - isString(lastMessage) && lastMessage.length > 60 ? lastMessage.substring(60) : lastMessage; + isString(lastMessage) && lastMessage.length > maxLength + ? lastMessage.substring(0, maxLength) + : lastMessage; assertGlobalInstanceOrInstance(instance) .prepare( `INSERT OR REPLACE INTO ${CONVERSATIONS_TABLE} (