Updates on rust: makes SS working but slow. Also branch some timeline virtual items.
This commit is contained in:
parent
f0db8b00ea
commit
6e6d2141b9
41 changed files with 352 additions and 138 deletions
|
|
@ -36,6 +36,7 @@ import org.matrix.rustcomponents.sdk.ClientDelegate
|
|||
import org.matrix.rustcomponents.sdk.MediaSource
|
||||
import org.matrix.rustcomponents.sdk.RequiredState
|
||||
import org.matrix.rustcomponents.sdk.SlidingSyncMode
|
||||
import org.matrix.rustcomponents.sdk.SlidingSyncRequestListFilters
|
||||
import org.matrix.rustcomponents.sdk.SlidingSyncViewBuilder
|
||||
import org.matrix.rustcomponents.sdk.StoppableSpawn
|
||||
import timber.log.Timber
|
||||
|
|
@ -66,7 +67,22 @@ internal class RustMatrixClient internal constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private val slidingSyncView = SlidingSyncViewBuilder()
|
||||
private val slidingSyncFilters by lazy {
|
||||
SlidingSyncRequestListFilters(
|
||||
isDm = null,
|
||||
spaces = emptyList(),
|
||||
isEncrypted = null,
|
||||
isInvite = false,
|
||||
isTombstoned = false,
|
||||
roomTypes = emptyList(),
|
||||
notRoomTypes = listOf("m.space"),
|
||||
roomNameLike = null,
|
||||
tags = emptyList(),
|
||||
notTags = emptyList()
|
||||
)
|
||||
}
|
||||
|
||||
private val visibleRoomsView = SlidingSyncViewBuilder()
|
||||
.timelineLimit(limit = 10u)
|
||||
.requiredState(
|
||||
requiredState = listOf(
|
||||
|
|
@ -74,17 +90,19 @@ internal class RustMatrixClient internal constructor(
|
|||
RequiredState(key = "m.room.encryption", value = ""),
|
||||
)
|
||||
)
|
||||
.name(name = "HomeScreenView")
|
||||
.filters(slidingSyncFilters)
|
||||
.name(name = "CurrentlyVisibleRooms")
|
||||
.sendUpdatesForItems(true)
|
||||
.syncMode(mode = SlidingSyncMode.SELECTIVE)
|
||||
.addRange(0u, 30u)
|
||||
.addRange(0u, 20u)
|
||||
.build()
|
||||
|
||||
private val slidingSync = client
|
||||
.slidingSync()
|
||||
.homeserver("https://slidingsync.lab.element.dev")
|
||||
.homeserver("https://slidingsync.lab.matrix.org")
|
||||
.withCommonExtensions()
|
||||
// .coldCache("ElementX")
|
||||
.addView(slidingSyncView)
|
||||
.coldCache("ElementX")
|
||||
.addView(visibleRoomsView)
|
||||
.build()
|
||||
|
||||
private val slidingSyncObserverProxy = SlidingSyncObserverProxy(coroutineScope)
|
||||
|
|
@ -92,7 +110,7 @@ internal class RustMatrixClient internal constructor(
|
|||
RustRoomSummaryDataSource(
|
||||
slidingSyncObserverProxy.updateSummaryFlow,
|
||||
slidingSync,
|
||||
slidingSyncView,
|
||||
visibleRoomsView,
|
||||
dispatchers,
|
||||
::onRestartSync
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ package io.element.android.libraries.matrix.timeline
|
|||
|
||||
import org.matrix.rustcomponents.sdk.EventTimelineItem
|
||||
import org.matrix.rustcomponents.sdk.TimelineItem
|
||||
import org.matrix.rustcomponents.sdk.VirtualTimelineItem
|
||||
|
||||
sealed interface MatrixTimelineItem {
|
||||
data class Event(val event: EventTimelineItem) : MatrixTimelineItem {
|
||||
val uniqueId: String = event.uniqueIdentifier()
|
||||
}
|
||||
|
||||
object Virtual : MatrixTimelineItem
|
||||
data class Virtual(val virtual: VirtualTimelineItem) : MatrixTimelineItem
|
||||
object Other : MatrixTimelineItem
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ fun TimelineItem.asMatrixTimelineItem(): MatrixTimelineItem {
|
|||
}
|
||||
val asVirtual = asVirtual()
|
||||
if (asVirtual != null) {
|
||||
return MatrixTimelineItem.Virtual
|
||||
return MatrixTimelineItem.Virtual(asVirtual)
|
||||
}
|
||||
return MatrixTimelineItem.Other
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,48 +17,59 @@
|
|||
package io.element.android.libraries.matrix.tracing
|
||||
|
||||
data class TracingConfiguration(
|
||||
val common: LogLevel = LogLevel.Warn,
|
||||
val targets: Map<Target, LogLevel> = emptyMap()
|
||||
val overrides: Map<Target, LogLevel> = emptyMap()
|
||||
) {
|
||||
|
||||
val filter = "$common,${
|
||||
targets.map { "${it.key.filter}=${it.value.filter}" }.joinToString(separator = ",")
|
||||
}"
|
||||
private val targets = mapOf(
|
||||
Target.Common to LogLevel.Warn,
|
||||
Target.Hyper to LogLevel.Warn,
|
||||
Target.Sled to LogLevel.Warn,
|
||||
Target.MatrixSdk.Sled to LogLevel.Warn,
|
||||
Target.MatrixSdk.HttpClient to LogLevel.Trace,
|
||||
Target.MatrixSdk.SlidingSync to LogLevel.Trace,
|
||||
Target.MatrixSdk.BaseSlidingSync to LogLevel.Trace
|
||||
)
|
||||
|
||||
sealed class Target(open val filter: String) {
|
||||
object Hyper : Target("hyper")
|
||||
object Sled : Target("sled")
|
||||
sealed class MatrixSdk(override val filter: String) : Target(filter) {
|
||||
object Root : MatrixSdk("matrix_sdk")
|
||||
object Sled : MatrixSdk("matrix_sdk_sled")
|
||||
object FFI : MatrixSdk("matrix_sdk_ffi")
|
||||
object HttpClient : MatrixSdk("matrix_sdk::http_client")
|
||||
object UniffiAPI : MatrixSdk("matrix_sdk_ffi::uniffi_api")
|
||||
object SlidingSync : MatrixSdk("matrix_sdk::sliding_sync")
|
||||
object BaseSlidingSync : MatrixSdk("matrix_sdk_base::sliding_sync")
|
||||
val filter: String
|
||||
get() {
|
||||
val newTargets = HashMap(targets)
|
||||
overrides.forEach { (target, logLevel) ->
|
||||
newTargets[target] = logLevel
|
||||
}
|
||||
return newTargets.map { "${it.key.filter}=${it.value.filter}" }.joinToString(separator = ",")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed class LogLevel(val filter: String) {
|
||||
object Warn : LogLevel("warn")
|
||||
object Trace : LogLevel("trace")
|
||||
object Info : LogLevel("info")
|
||||
object Debug : LogLevel("debug")
|
||||
object Error : LogLevel("error")
|
||||
sealed class Target(open val filter: String) {
|
||||
object Common : Target("common")
|
||||
object Hyper : Target("hyper")
|
||||
object Sled : Target("sled")
|
||||
sealed class MatrixSdk(override val filter: String) : Target(filter) {
|
||||
object Root : MatrixSdk("matrix_sdk")
|
||||
object Sled : MatrixSdk("matrix_sdk_sled")
|
||||
object FFI : MatrixSdk("matrix_sdk_ffi")
|
||||
object HttpClient : MatrixSdk("matrix_sdk::http_client")
|
||||
object UniffiAPI : MatrixSdk("matrix_sdk_ffi::uniffi_api")
|
||||
object SlidingSync : MatrixSdk("matrix_sdk::sliding_sync")
|
||||
object BaseSlidingSync : MatrixSdk("matrix_sdk_base::sliding_sync")
|
||||
}
|
||||
}
|
||||
|
||||
sealed class LogLevel(val filter: String) {
|
||||
object Warn : LogLevel("warn")
|
||||
object Trace : LogLevel("trace")
|
||||
object Info : LogLevel("info")
|
||||
object Debug : LogLevel("debug")
|
||||
object Error : LogLevel("error")
|
||||
}
|
||||
|
||||
fun setupTracing(tracingConfiguration: TracingConfiguration) {
|
||||
org.matrix.rustcomponents.sdk.setupTracing(tracingConfiguration.filter)
|
||||
}
|
||||
|
||||
object TracingConfigurations {
|
||||
val release = TracingConfiguration(common = TracingConfiguration.LogLevel.Info)
|
||||
val debug = TracingConfiguration()
|
||||
val full = TracingConfiguration(
|
||||
common = TracingConfiguration.LogLevel.Info,
|
||||
targets = mapOf(
|
||||
TracingConfiguration.Target.Sled to TracingConfiguration.LogLevel.Warn
|
||||
)
|
||||
)
|
||||
val release = TracingConfiguration(overrides = mapOf(Target.Common to LogLevel.Info))
|
||||
val debug = TracingConfiguration(overrides = mapOf(Target.Common to LogLevel.Info))
|
||||
|
||||
fun custom(overrides: Map<Target, LogLevel>) = TracingConfiguration(overrides)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue