Skip to content
Snippets Groups Projects
Commit bf2d9600 authored by Taras's avatar Taras
Browse files

Add room id to Update timeline callback

parent 8ee79259
No related branches found
No related tags found
No related merge requests found
......@@ -209,7 +209,7 @@ class CommonTestHelper internal constructor(context: Context, val cryptoConfig:
val messageSent = CompletableDeferred<String>()
timeline.addListener(object : Timeline.Listener {
override fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) {
override fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) {
val decryptedMsg = timeline.getSnapshot()
.filter { it.root.getClearType() == EventType.MESSAGE }
.also { list ->
......@@ -249,7 +249,7 @@ class CommonTestHelper internal constructor(context: Context, val cryptoConfig:
Log.v("#E2E TEST", "onNewTimelineEvents snapshot is $eventIds")
}
override fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) {
override fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) {
val success = timeline.getSnapshot()
// .filter { it.root.getClearType() == EventType.MESSAGE }
.also { list ->
......@@ -282,7 +282,7 @@ class CommonTestHelper internal constructor(context: Context, val cryptoConfig:
timeline.start()
val messageSent = CompletableDeferred<Unit>()
timeline.addListener(object : Timeline.Listener {
override fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) {
override fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) {
val success = timeline.getSnapshot()
.filter { it.root.getClearType() == EventType.MESSAGE }
.also { list ->
......@@ -319,7 +319,7 @@ class CommonTestHelper internal constructor(context: Context, val cryptoConfig:
suspendCoroutine<Unit> { continuation ->
val timelineListener = object : Timeline.Listener {
override fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) {
override fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) {
val allSentMessages = snapshot
.filter { it.root.sendState == SendState.SYNCED }
.filter { it.root.getClearType() == EventType.MESSAGE }
......@@ -521,7 +521,7 @@ class CommonTestHelper internal constructor(context: Context, val cryptoConfig:
fun createEventListener(latch: CountDownLatch, predicate: (List<TimelineEvent>) -> Boolean): Timeline.Listener {
return object : Timeline.Listener {
override fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) {
override fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) {
if (predicate(snapshot)) {
latch.countDown()
}
......
......@@ -95,7 +95,7 @@ private suspend fun Timeline.waitForEncryptedMessages() {
// noop
}
override fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) {
override fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) {
val newMessages = snapshot
.filter { it.root.sendState == SendState.SYNCED }
.filter { it.root.getClearType() == EventType.STATE_ROOM_ENCRYPTION }
......
......@@ -68,7 +68,7 @@ class PollAggregationTest : InstrumentedTest {
val aliceEventsListener = object : Timeline.Listener {
override fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) {
override fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) {
snapshot.firstOrNull { it.root.getClearType() in EventType.POLL_START.values }?.let { pollEvent ->
val pollEventId = pollEvent.eventId
val pollContent = pollEvent.root.content?.toModel<MessagePollContent>()
......
......@@ -98,7 +98,7 @@ interface Timeline {
* @param snapshot the most up to date snapshot
*/
// Added timelineId for circles
fun onTimelineUpdated(timelineId: String, snapshot: List<TimelineEvent>) = Unit
fun onTimelineUpdated(roomId: String, timelineId: String, snapshot: List<TimelineEvent>) = Unit
/**
* Called whenever an error we can't recover from occurred.
......
......@@ -129,7 +129,7 @@ internal class DefaultTimeline(
timelineScope.launch {
val snapshot = strategy.buildSnapshot()
withContext(coroutineDispatchers.main) {
tryOrNull { listener.onTimelineUpdated(timelineID, snapshot) }
tryOrNull { listener.onTimelineUpdated(roomId, timelineID, snapshot) }
}
}
return true
......@@ -342,10 +342,10 @@ internal class DefaultTimeline(
listeners.forEach {
if (initialEventId != null && isFromThreadTimeline && snapshot.firstOrNull { it.eventId == initialEventId } == null) {
// We are in a thread timeline with a permalink, post update timeline only when the appropriate message have been found
tryOrNull { it.onTimelineUpdated(timelineID, arrayListOf()) }
tryOrNull { it.onTimelineUpdated(roomId, timelineID, arrayListOf()) }
} else {
// In all the other cases update timeline as expected
tryOrNull { it.onTimelineUpdated(timelineID, snapshot) }
tryOrNull { it.onTimelineUpdated(roomId, timelineID, snapshot) }
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment