Code review
This commit is contained in:
parent
d319a353d4
commit
dc8a6cc745
@ -90,8 +90,6 @@ internal class DefaultSendService @AssistedInject constructor(
|
|||||||
.let { sendEvent(it) }
|
.let { sendEvent(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// For test only
|
|
||||||
|
|
||||||
override fun sendFormattedTextMessage(text: String, formattedText: String, msgType: String): Cancelable {
|
override fun sendFormattedTextMessage(text: String, formattedText: String, msgType: String): Cancelable {
|
||||||
return localEchoEventFactory.createFormattedTextEvent(roomId, TextContent(text, formattedText), msgType)
|
return localEchoEventFactory.createFormattedTextEvent(roomId, TextContent(text, formattedText), msgType)
|
||||||
.also { createLocalEcho(it) }
|
.also { createLocalEcho(it) }
|
||||||
|
@ -46,7 +46,7 @@ import kotlin.concurrent.schedule
|
|||||||
* Each send is retried 3 times, if there is no network (e.g if cannot ping home server) it will wait and
|
* Each send is retried 3 times, if there is no network (e.g if cannot ping home server) it will wait and
|
||||||
* periodically test reachability before resume (does not count as a retry)
|
* periodically test reachability before resume (does not count as a retry)
|
||||||
*
|
*
|
||||||
* If the app is killed before all event were sent, on next wakeup the sheduled events will be re posted
|
* If the app is killed before all event were sent, on next wakeup the scheduled events will be re posted
|
||||||
*/
|
*/
|
||||||
@SessionScope
|
@SessionScope
|
||||||
internal class EventSenderProcessor @Inject constructor(
|
internal class EventSenderProcessor @Inject constructor(
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
package org.matrix.android.sdk.internal.session.room.send.queue
|
package org.matrix.android.sdk.internal.session.room.send.queue
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
|
||||||
import org.matrix.android.sdk.api.auth.data.sessionId
|
import org.matrix.android.sdk.api.auth.data.sessionId
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
|
import org.matrix.android.sdk.internal.di.SessionId
|
||||||
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
|
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -34,12 +34,12 @@ import javax.inject.Inject
|
|||||||
* reschedule them (and only them) on next restart
|
* reschedule them (and only them) on next restart
|
||||||
*/
|
*/
|
||||||
internal class QueueMemento @Inject constructor(context: Context,
|
internal class QueueMemento @Inject constructor(context: Context,
|
||||||
sessionParams: SessionParams,
|
@SessionId sessionId: String,
|
||||||
private val queuedTaskFactory: QueuedTaskFactory,
|
private val queuedTaskFactory: QueuedTaskFactory,
|
||||||
private val localEchoRepository: LocalEchoRepository,
|
private val localEchoRepository: LocalEchoRepository,
|
||||||
private val cryptoService: CryptoService) {
|
private val cryptoService: CryptoService) {
|
||||||
|
|
||||||
private val storage = context.getSharedPreferences("QueueMemento_${sessionParams.credentials.sessionId()}", Context.MODE_PRIVATE)
|
private val storage = context.getSharedPreferences("QueueMemento_$sessionId", Context.MODE_PRIVATE)
|
||||||
private val managedTaskInfos = mutableListOf<QueuedTask>()
|
private val managedTaskInfos = mutableListOf<QueuedTask>()
|
||||||
|
|
||||||
fun track(task: QueuedTask) {
|
fun track(task: QueuedTask) {
|
||||||
|
@ -27,7 +27,7 @@ import org.matrix.android.sdk.internal.network.parsing.RuntimeJsonAdapterFactory
|
|||||||
* Info that need to be persisted by the sender thread
|
* Info that need to be persisted by the sender thread
|
||||||
* With polymorphic moshi parsing
|
* With polymorphic moshi parsing
|
||||||
*/
|
*/
|
||||||
interface TaskInfo {
|
internal interface TaskInfo {
|
||||||
val type: String
|
val type: String
|
||||||
val order: Int
|
val order: Int
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ interface TaskInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class SendEventTaskInfo(
|
internal data class SendEventTaskInfo(
|
||||||
@Json(name = "type") override val type: String = TaskInfo.TYPE_SEND,
|
@Json(name = "type") override val type: String = TaskInfo.TYPE_SEND,
|
||||||
@Json(name = "localEchoId") val localEchoId: String,
|
@Json(name = "localEchoId") val localEchoId: String,
|
||||||
@Json(name = "encrypt") val encrypt: Boolean?,
|
@Json(name = "encrypt") val encrypt: Boolean?,
|
||||||
@ -63,14 +63,14 @@ data class SendEventTaskInfo(
|
|||||||
) : TaskInfo
|
) : TaskInfo
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class RedactEventTaskInfo(
|
internal data class RedactEventTaskInfo(
|
||||||
@Json(name = "type") override val type: String = TaskInfo.TYPE_REDACT,
|
@Json(name = "type") override val type: String = TaskInfo.TYPE_REDACT,
|
||||||
@Json(name = "redactionLocalEcho") val redactionLocalEcho: String?,
|
@Json(name = "redactionLocalEcho") val redactionLocalEcho: String?,
|
||||||
@Json(name = "order") override val order: Int
|
@Json(name = "order") override val order: Int
|
||||||
) : TaskInfo
|
) : TaskInfo
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class FallbackTaskInfo(
|
internal data class FallbackTaskInfo(
|
||||||
@Json(name = "type") override val type: String = TaskInfo.TYPE_REDACT,
|
@Json(name = "type") override val type: String = TaskInfo.TYPE_REDACT,
|
||||||
@Json(name = "order") override val order: Int
|
@Json(name = "order") override val order: Int
|
||||||
) : TaskInfo
|
) : TaskInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user