Move debounceDelayMillis to a constant class field
This commit is contained in:
parent
0ab95f235a
commit
d726b2859d
|
@ -44,6 +44,8 @@ import javax.inject.Inject
|
|||
import kotlin.math.pow
|
||||
import kotlin.math.sqrt
|
||||
|
||||
private const val DEBOUNCE_DELAY_MILLIS = 500L
|
||||
|
||||
/**
|
||||
* A class that will inline the images in the message's body.
|
||||
* Implement [CoroutineScope] by the constructor scope
|
||||
|
@ -81,7 +83,7 @@ internal class MessageRenderer(
|
|||
imageCompressor.send(embeddedImages)
|
||||
// Workaround that ignore values for the next half second, since ViewModel is emitting
|
||||
// too many times
|
||||
delay(debounceDelayMillis)
|
||||
delay(DEBOUNCE_DELAY_MILLIS)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,10 +227,6 @@ internal class MessageRenderer(
|
|||
MessageRenderer(dispatchers, messageDirectory(messageId), documentParser, imageDecoder, scope)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val debounceDelayMillis = 500L
|
||||
}
|
||||
}
|
||||
|
||||
// region constants
|
||||
|
|
|
@ -827,12 +827,12 @@ class MailboxActivity :
|
|||
val mailboxLocation = mailboxLocationMain.value
|
||||
menu.findItem(R.id.empty).isVisible =
|
||||
mailboxLocation in listOf(
|
||||
MessageLocationType.DRAFT,
|
||||
MessageLocationType.SPAM,
|
||||
MessageLocationType.TRASH,
|
||||
MessageLocationType.LABEL,
|
||||
MessageLocationType.LABEL_FOLDER
|
||||
)
|
||||
MessageLocationType.DRAFT,
|
||||
MessageLocationType.SPAM,
|
||||
MessageLocationType.TRASH,
|
||||
MessageLocationType.LABEL,
|
||||
MessageLocationType.LABEL_FOLDER
|
||||
)
|
||||
return super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package ch.protonmail.android.views.messagesList
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
|
|
@ -107,6 +107,7 @@ internal class MessageRendererTest : CoroutinesTest {
|
|||
|
||||
val count = 2
|
||||
val consumer: (String) -> Unit = mockk(relaxed = true)
|
||||
val expectedDebounceTime = 500L
|
||||
|
||||
with(renderer) {
|
||||
launch(Unconfined) {
|
||||
|
@ -114,7 +115,7 @@ internal class MessageRendererTest : CoroutinesTest {
|
|||
}
|
||||
repeat(count) {
|
||||
images.offer(mockEmbeddedImages)
|
||||
advanceTimeBy(MessageRenderer.debounceDelayMillis)
|
||||
advanceTimeBy(expectedDebounceTime)
|
||||
}
|
||||
advanceUntilIdle()
|
||||
renderedBody.close()
|
||||
|
|
Loading…
Reference in New Issue