Merge pull request #2436 from Bilb/fix-shortening-last-message

fix: shorten further the last message
This commit is contained in:
Audric Ackermann 2022-08-24 17:13:54 +10:00 committed by GitHub
commit 56ee7fe7ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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} (