From dc8a6cc745412c1d1a6e80d65905101a5fd59a46 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 12 Oct 2020 12:25:59 +0200 Subject: [PATCH] Code review --- .../sdk/internal/session/room/send/DefaultSendService.kt | 2 -- .../session/room/send/queue/EventSenderProcessor.kt | 2 +- .../sdk/internal/session/room/send/queue/QueueMemento.kt | 6 +++--- .../sdk/internal/session/room/send/queue/TaskInfo.kt | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt index 063598c0d7..5c395c1907 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt @@ -90,8 +90,6 @@ internal class DefaultSendService @AssistedInject constructor( .let { sendEvent(it) } } - // For test only - override fun sendFormattedTextMessage(text: String, formattedText: String, msgType: String): Cancelable { return localEchoEventFactory.createFormattedTextEvent(roomId, TextContent(text, formattedText), msgType) .also { createLocalEcho(it) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt index cbd870d3cb..62e225c624 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt @@ -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 * 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 internal class EventSenderProcessor @Inject constructor( diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt index 6dcecc6620..e69c65ec4c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt @@ -17,11 +17,11 @@ package org.matrix.android.sdk.internal.session.room.send.queue 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.extensions.tryOrNull import org.matrix.android.sdk.api.session.crypto.CryptoService 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 timber.log.Timber import javax.inject.Inject @@ -34,12 +34,12 @@ import javax.inject.Inject * reschedule them (and only them) on next restart */ internal class QueueMemento @Inject constructor(context: Context, - sessionParams: SessionParams, + @SessionId sessionId: String, private val queuedTaskFactory: QueuedTaskFactory, private val localEchoRepository: LocalEchoRepository, 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() fun track(task: QueuedTask) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/TaskInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/TaskInfo.kt index ae07d199b0..87c6299c4d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/TaskInfo.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/TaskInfo.kt @@ -27,7 +27,7 @@ import org.matrix.android.sdk.internal.network.parsing.RuntimeJsonAdapterFactory * Info that need to be persisted by the sender thread * With polymorphic moshi parsing */ -interface TaskInfo { +internal interface TaskInfo { val type: String val order: Int @@ -55,7 +55,7 @@ interface TaskInfo { } @JsonClass(generateAdapter = true) -data class SendEventTaskInfo( +internal data class SendEventTaskInfo( @Json(name = "type") override val type: String = TaskInfo.TYPE_SEND, @Json(name = "localEchoId") val localEchoId: String, @Json(name = "encrypt") val encrypt: Boolean?, @@ -63,14 +63,14 @@ data class SendEventTaskInfo( ) : TaskInfo @JsonClass(generateAdapter = true) -data class RedactEventTaskInfo( +internal data class RedactEventTaskInfo( @Json(name = "type") override val type: String = TaskInfo.TYPE_REDACT, @Json(name = "redactionLocalEcho") val redactionLocalEcho: String?, @Json(name = "order") override val order: Int ) : TaskInfo @JsonClass(generateAdapter = true) -data class FallbackTaskInfo( +internal data class FallbackTaskInfo( @Json(name = "type") override val type: String = TaskInfo.TYPE_REDACT, @Json(name = "order") override val order: Int ) : TaskInfo