Pinned events : introduce pinnedEventsTimeline method.
This commit is contained in:
parent
e93772b4d8
commit
ebc9fd745e
3 changed files with 25 additions and 0 deletions
|
|
@ -106,6 +106,11 @@ interface MatrixRoom : Closeable {
|
||||||
*/
|
*/
|
||||||
suspend fun timelineFocusedOnEvent(eventId: EventId): Result<Timeline>
|
suspend fun timelineFocusedOnEvent(eventId: EventId): Result<Timeline>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new timeline for the pinned events of the room.
|
||||||
|
*/
|
||||||
|
suspend fun pinnedEventsTimeline(): Result<Timeline>
|
||||||
|
|
||||||
fun destroy()
|
fun destroy()
|
||||||
|
|
||||||
suspend fun subscribeToSync()
|
suspend fun subscribeToSync()
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,21 @@ class RustMatrixRoom(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun pinnedEventsTimeline(): Result<Timeline> {
|
||||||
|
return runCatching {
|
||||||
|
innerRoom.pinnedEventsTimeline(
|
||||||
|
internalIdPrefix = "pinned_events",
|
||||||
|
maxEventsToLoad = 100u,
|
||||||
|
).let { inner ->
|
||||||
|
createTimeline(inner, isLive = false)
|
||||||
|
}
|
||||||
|
}.onFailure {
|
||||||
|
if (it is CancellationException) {
|
||||||
|
throw it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun destroy() {
|
override fun destroy() {
|
||||||
roomCoroutineScope.cancel()
|
roomCoroutineScope.cancel()
|
||||||
liveTimeline.close()
|
liveTimeline.close()
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ class FakeMatrixRoom(
|
||||||
private val updateMembersResult: () -> Unit = { lambdaError() },
|
private val updateMembersResult: () -> Unit = { lambdaError() },
|
||||||
private val getMembersResult: (Int) -> Result<List<RoomMember>> = { lambdaError() },
|
private val getMembersResult: (Int) -> Result<List<RoomMember>> = { lambdaError() },
|
||||||
private val timelineFocusedOnEventResult: (EventId) -> Result<Timeline> = { lambdaError() },
|
private val timelineFocusedOnEventResult: (EventId) -> Result<Timeline> = { lambdaError() },
|
||||||
|
private val pinnedEventsTimelineResult: () -> Result<Timeline> = { lambdaError() },
|
||||||
private val setSendQueueEnabledLambda: (Boolean) -> Unit = { _: Boolean -> },
|
private val setSendQueueEnabledLambda: (Boolean) -> Unit = { _: Boolean -> },
|
||||||
private val saveComposerDraftLambda: (ComposerDraft) -> Result<Unit> = { _: ComposerDraft -> Result.success(Unit) },
|
private val saveComposerDraftLambda: (ComposerDraft) -> Result<Unit> = { _: ComposerDraft -> Result.success(Unit) },
|
||||||
private val loadComposerDraftLambda: () -> Result<ComposerDraft?> = { Result.success<ComposerDraft?>(null) },
|
private val loadComposerDraftLambda: () -> Result<ComposerDraft?> = { Result.success<ComposerDraft?>(null) },
|
||||||
|
|
@ -181,6 +182,10 @@ class FakeMatrixRoom(
|
||||||
timelineFocusedOnEventResult(eventId)
|
timelineFocusedOnEventResult(eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun pinnedEventsTimeline(): Result<Timeline> = simulateLongTask {
|
||||||
|
pinnedEventsTimelineResult()
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun subscribeToSync() = Unit
|
override suspend fun subscribeToSync() = Unit
|
||||||
|
|
||||||
override suspend fun powerLevels(): Result<MatrixRoomPowerLevels> {
|
override suspend fun powerLevels(): Result<MatrixRoomPowerLevels> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue