feat(manager/chat_purge): random delay

This commit is contained in:
rhunk 2023-10-15 00:49:28 +02:00
parent c533983fb3
commit 50a43ee6ad
2 changed files with 11 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
import me.rhunk.snapenhance.common.util.snap.SnapWidgetBroadcastReceiverHelper import me.rhunk.snapenhance.common.util.snap.SnapWidgetBroadcastReceiverHelper
import me.rhunk.snapenhance.ui.util.AlertDialogs import me.rhunk.snapenhance.ui.util.AlertDialogs
import me.rhunk.snapenhance.ui.util.Dialog import me.rhunk.snapenhance.ui.util.Dialog
import kotlin.random.Random
class MessagingPreview( class MessagingPreview(
private val context: RemoteSideContext, private val context: RemoteSideContext,
@ -135,7 +136,10 @@ class MessagingPreview(
if (deleteAllConfirmationDialog) { if (deleteAllConfirmationDialog) {
Dialog(onDismissRequest = { deleteAllConfirmationDialog = false }) { Dialog(onDismissRequest = { deleteAllConfirmationDialog = false }) {
alertDialogs.ConfirmDialog(title = "Are you sure you want to delete all your messages?", onDismiss = { alertDialogs.ConfirmDialog(
title = "Are you sure you want to delete all your messages?",
message = "Warning: This action may flag your account for spam if used excessively.",
onDismiss = {
deleteAllConfirmationDialog = false deleteAllConfirmationDialog = false
}, onConfirm = { }, onConfirm = {
deletedMessageCount = 0 deletedMessageCount = 0
@ -161,6 +165,7 @@ class MessagingPreview(
fetchedMessages.forEach { fetchedMessages.forEach {
deleteIndividualMessage(it.serverMessageId) deleteIndividualMessage(it.serverMessageId)
delay(Random.nextLong(50, 170))
} }
lastMessageId = fetchedMessages.first().clientMessageId lastMessageId = fetchedMessages.first().clientMessageId

View File

@ -94,6 +94,11 @@ class SocialSection : Section() {
currentMessagingPreview = messagePreview currentMessagingPreview = messagePreview
} }
messagePreview.Content() messagePreview.Content()
DisposableEffect(Unit) {
onDispose {
currentMessagingPreview = null
}
}
} }
} }
} }