private fun Call<Message>.enqueueAndHandleSlowMode() { if (cooldownInterval > 0 && isSlowModeActive.value && !isInEditMode) { cooldownTimerJob?.cancel()  cooldownTimer.value = cooldownInterval enqueue { if (it.isSuccess || !chatClient.clientState.isNetworkAvailable) { cooldownTimerJob = scope.launch { for (timeRemaining in cooldownInterval downTo 0) { cooldownTimer.value = timeRemaining delay(OneSecond) } } } else { cooldownTimer.value = 0 } } } else { enqueue() } }
Executes the message Call and shows cooldown countdown timer instead of send button when slow mode is enabled. 