Skip to content

Commit 1dba22a

Browse files
committed
set negative placeholderId (not tested)
Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
1 parent 501cf5e commit 1dba22a

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,14 @@ class OfflineFirstChatRepository @Inject constructor(
697697
try {
698698
val currentTimeMillis = System.currentTimeMillis()
699699

700-
// Use the first 15 hex chars so the value always fits in a signed Long.
701700
// Use referenceId.hashCode() as the placeholder id so that:
702701
// 1. It is unique per file even when multiple files are selected simultaneously
703702
// 2. It fits in an Int, so it survives the Long→Int cast in ChatMessageUi.id without
704703
// truncation, keeping DB lookups consistent when the message is tapped.
705-
// 3. It is always positive, because getMessagesEqualOrNewerThan expects it to be larger
706-
// than oldestMessageId
704+
// 3. It is always negative -> sending the lastReadMessage to server checks "-1 < messageId"
705+
// to avoid temporary/placeholder messages (see createChatMessageEntity)
707706
@Suppress("MagicNumber")
708-
val placeholderId = (referenceId.hashCode().toLong() and 0x7FFF_FFFFL)
707+
val placeholderId = -(referenceId.hashCode().toLong() and 0x7FFF_FFFFL)
709708

710709
Log.d(
711710
TAG,

0 commit comments

Comments
 (0)