Fix potential crash in notification message generation.

This commit is contained in:
Greyson Parrelli
2025-08-15 11:44:13 -04:00
committed by Jeffrey Starke
parent dd01cd15ca
commit 8df8cdf28d

View File

@@ -178,7 +178,11 @@ sealed class NotificationItem(val threadRecipient: Recipient, protected val reco
if (spoilerRanges?.isNotEmpty() == true) {
for (spoiler in spoilerRanges) {
updatedText = updatedText.replaceRange(spoiler.start.coerceAtMost(updatedText.length - 1), (spoiler.start + spoiler.length).coerceAtMost(updatedText.length), "■■■■")
updatedText = updatedText.replaceRange(
startIndex = spoiler.start.coerceAtMost(updatedText.length - 1).coerceAtLeast(0),
endIndex = (spoiler.start + spoiler.length).coerceAtMost(updatedText.length).coerceAtLeast(0),
replacement = "■■■■"
)
}
}