Add mapping on FocusEventException.
Extract FocusRequestState to its own file and add preview.
This commit is contained in:
parent
d3d5081084
commit
a4c6e6c281
10 changed files with 219 additions and 47 deletions
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2024 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.impl.room
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.room.errors.FocusEventException
|
||||
import org.matrix.rustcomponents.sdk.FocusEventException as RustFocusEventException
|
||||
|
||||
fun Throwable.toFocusEventException(): Throwable {
|
||||
return when (this) {
|
||||
is RustFocusEventException -> {
|
||||
when (this) {
|
||||
is RustFocusEventException.InvalidEventId -> {
|
||||
FocusEventException.InvalidEventId(eventId, err)
|
||||
}
|
||||
is RustFocusEventException.EventNotFound -> {
|
||||
FocusEventException.EventNotFound(EventId(eventId))
|
||||
}
|
||||
is RustFocusEventException.Other -> {
|
||||
FocusEventException.Other(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ package io.element.android.libraries.matrix.impl.room
|
|||
|
||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.libraries.core.coroutine.childScope
|
||||
import io.element.android.libraries.core.extensions.mapFailure
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.core.ProgressCallback
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
|
|
@ -169,13 +170,17 @@ class RustMatrixRoom(
|
|||
|
||||
override suspend fun unsubscribeFromSync() = roomSyncSubscriber.unsubscribe(roomId)
|
||||
|
||||
override suspend fun timelineFocusedOnEvent(eventId: EventId): Timeline {
|
||||
return innerRoom.timelineFocusedOnEvent(
|
||||
eventId = eventId.value,
|
||||
numContextEvents = 50u,
|
||||
internalIdPrefix = "focus_$eventId",
|
||||
).let { inner ->
|
||||
createTimeline(inner, isLive = false)
|
||||
override suspend fun timelineFocusedOnEvent(eventId: EventId): Result<Timeline> {
|
||||
return runCatching {
|
||||
innerRoom.timelineFocusedOnEvent(
|
||||
eventId = eventId.value,
|
||||
numContextEvents = 50u,
|
||||
internalIdPrefix = "focus_$eventId",
|
||||
).let { inner ->
|
||||
createTimeline(inner, isLive = false)
|
||||
}
|
||||
}.mapFailure {
|
||||
it.toFocusEventException()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -442,7 +447,7 @@ class RustMatrixRoom(
|
|||
}
|
||||
|
||||
override suspend fun toggleReaction(emoji: String, eventId: EventId): Result<Unit> {
|
||||
return liveTimeline.toggleReaction(emoji, eventId)
|
||||
return liveTimeline.toggleReaction(emoji, eventId)
|
||||
}
|
||||
|
||||
override suspend fun forwardEvent(eventId: EventId, roomIds: List<RoomId>): Result<Unit> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue