Merge branch 'develop' into feature/fga/update-rust-sdk-0.1.31
This commit is contained in:
commit
c8776f9806
29 changed files with 223 additions and 88 deletions
|
|
@ -19,6 +19,7 @@ package io.element.android.libraries.architecture
|
|||
import androidx.compose.runtime.Stable
|
||||
import com.bumble.appyx.core.children.ChildEntry
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import com.bumble.appyx.core.node.ParentNode
|
||||
import com.bumble.appyx.core.plugin.Plugin
|
||||
import com.bumble.appyx.navmodel.backstack.BackStack
|
||||
|
|
@ -39,4 +40,15 @@ abstract class BackstackNode<NavTarget : Any>(
|
|||
buildContext = buildContext,
|
||||
plugins = plugins,
|
||||
childKeepMode = childKeepMode,
|
||||
)
|
||||
) {
|
||||
override fun onBuilt() {
|
||||
super.onBuilt()
|
||||
lifecycle.logLifecycle(this::class.java.simpleName)
|
||||
whenChildAttached<Node> { _, child ->
|
||||
// BackstackNode will be logged by their parent.
|
||||
if (child !is BackstackNode<*>) {
|
||||
child.lifecycle.logLifecycle(child::class.java.simpleName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2023 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.architecture
|
||||
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import com.bumble.appyx.core.lifecycle.subscribe
|
||||
import timber.log.Timber
|
||||
|
||||
fun Lifecycle.logLifecycle(name: String) {
|
||||
subscribe(
|
||||
onCreate = { Timber.tag("Lifecycle").d("onCreate $name") },
|
||||
onPause = { Timber.tag("Lifecycle").d("onPause $name") },
|
||||
onResume = { Timber.tag("Lifecycle").d("onResume $name") },
|
||||
onDestroy = { Timber.tag("Lifecycle").d("onDestroy $name") },
|
||||
)
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ fun String?.insertBeforeLast(insert: String, delimiter: String = "."): String {
|
|||
* Throws if length is < 1.
|
||||
*/
|
||||
fun String.ellipsize(length: Int): String {
|
||||
require(length > 1)
|
||||
require(length >= 1)
|
||||
|
||||
if (this.length <= length) {
|
||||
return this
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package io.element.android.libraries.deeplink
|
|||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import io.element.android.libraries.core.data.tryOrNull
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
|
|
@ -37,21 +36,15 @@ class DeeplinkParser @Inject constructor() {
|
|||
if (host != HOST) return null
|
||||
val pathBits = path.orEmpty().split("/").drop(1)
|
||||
val sessionId = pathBits.elementAtOrNull(0)?.let(::SessionId) ?: return null
|
||||
val screenPathComponent = pathBits.elementAtOrNull(1)
|
||||
val roomId = tryOrNull { screenPathComponent?.let(::RoomId) }
|
||||
|
||||
return when {
|
||||
roomId != null -> {
|
||||
return when (val screenPathComponent = pathBits.elementAtOrNull(1)) {
|
||||
null -> DeeplinkData.Root(sessionId)
|
||||
DeepLinkPaths.INVITE_LIST -> DeeplinkData.InviteList(sessionId)
|
||||
else -> {
|
||||
val roomId = screenPathComponent.let(::RoomId)
|
||||
val threadId = pathBits.elementAtOrNull(2)?.let(::ThreadId)
|
||||
DeeplinkData.Room(sessionId, roomId, threadId)
|
||||
}
|
||||
screenPathComponent == DeepLinkPaths.INVITE_LIST -> {
|
||||
DeeplinkData.InviteList(sessionId)
|
||||
}
|
||||
screenPathComponent == null -> {
|
||||
DeeplinkData.Root(sessionId)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class RoomMembershipContentFormatter @Inject constructor(
|
|||
): CharSequence? {
|
||||
val userId = membershipContent.userId
|
||||
val memberIsYou = matrixClient.isMe(userId)
|
||||
return when (val change = membershipContent.change) {
|
||||
return when (membershipContent.change) {
|
||||
MembershipChange.JOINED -> if (memberIsYou) {
|
||||
sp.getString(R.string.state_event_room_join_by_you)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ interface MatrixRoom : Closeable {
|
|||
|
||||
suspend fun toggleReaction(emoji: String, eventId: EventId): Result<Unit>
|
||||
|
||||
suspend fun forwardEvent(eventId: EventId, rooms: List<RoomId>): Result<Unit>
|
||||
suspend fun forwardEvent(eventId: EventId, roomIds: List<RoomId>): Result<Unit>
|
||||
|
||||
suspend fun retrySendMessage(transactionId: String): Result<Unit>
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,13 @@ interface RoomSummaryDataSource {
|
|||
|
||||
suspend fun RoomSummaryDataSource.awaitAllRoomsAreLoaded(timeout: Duration = Duration.INFINITE) {
|
||||
try {
|
||||
Timber.d("awaitAllRoomsAreLoaded: wait")
|
||||
withTimeout(timeout) {
|
||||
allRoomsLoadingState().firstOrNull {
|
||||
it is RoomSummaryDataSource.LoadingState.Loaded
|
||||
}
|
||||
}
|
||||
} catch (timeoutException: TimeoutCancellationException) {
|
||||
Timber.v("AwaitAllRooms: no response after $timeout")
|
||||
Timber.d("awaitAllRoomsAreLoaded: no response after $timeout")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ fun RoomListService.roomOrNull(roomId: String): RoomListItem? {
|
|||
return try {
|
||||
room(roomId)
|
||||
} catch (exception: RoomListException) {
|
||||
Timber.e(exception, "Failed finding room with id=$roomId")
|
||||
Timber.d(exception, "Failed finding room with id=$roomId.")
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
|||
import io.element.android.libraries.matrix.test.room.FakeRoomSummaryDataSource
|
||||
import io.element.android.libraries.matrix.test.sync.FakeSyncService
|
||||
import io.element.android.libraries.matrix.test.verification.FakeSessionVerificationService
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
class FakeMatrixClient(
|
||||
|
|
@ -72,11 +73,11 @@ class FakeMatrixClient(
|
|||
return findDmResult
|
||||
}
|
||||
|
||||
override suspend fun ignoreUser(userId: UserId): Result<Unit> {
|
||||
override suspend fun ignoreUser(userId: UserId): Result<Unit> = simulateLongTask {
|
||||
return ignoreUserResult
|
||||
}
|
||||
|
||||
override suspend fun unignoreUser(userId: UserId): Result<Unit> {
|
||||
override suspend fun unignoreUser(userId: UserId): Result<Unit> = simulateLongTask {
|
||||
return unignoreUserResult
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ class FakeMatrixRoom(
|
|||
|
||||
override suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<Unit> = fakeSendMedia(progressCallback)
|
||||
|
||||
override suspend fun forwardEvent(eventId: EventId, rooms: List<RoomId>): Result<Unit> = simulateLongTask {
|
||||
override suspend fun forwardEvent(eventId: EventId, roomIds: List<RoomId>): Result<Unit> = simulateLongTask {
|
||||
forwardEventResult
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,8 @@ package io.element.android.libraries.matrix.ui.di
|
|||
import com.squareup.anvil.annotations.ContributesTo
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import io.element.android.libraries.matrix.ui.media.LoggedInImageLoaderFactory
|
||||
import io.element.android.libraries.matrix.ui.media.NotLoggedInImageLoaderFactory
|
||||
|
||||
@ContributesTo(SessionScope::class)
|
||||
interface MatrixUIBindings {
|
||||
fun loggedInImageLoaderFactory(): LoggedInImageLoaderFactory
|
||||
fun notLoggedInImageLoaderFactory(): NotLoggedInImageLoaderFactory
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ class NotificationFactory @Inject constructor(
|
|||
val roomMeta = roomNotifications.filterIsInstance<RoomNotification.Message>().map { it.meta }
|
||||
val invitationMeta = invitationNotifications.filterIsInstance<OneShotNotification.Append>().map { it.meta }
|
||||
val simpleMeta = simpleNotifications.filterIsInstance<OneShotNotification.Append>().map { it.meta }
|
||||
val fallbackMeta = simpleNotifications.filterIsInstance<OneShotNotification.Append>().map { it.meta }
|
||||
val fallbackMeta = fallbackNotifications.filterIsInstance<OneShotNotification.Append>().map { it.meta }
|
||||
return when {
|
||||
roomMeta.isEmpty() && invitationMeta.isEmpty() && simpleMeta.isEmpty() -> SummaryNotification.Removed
|
||||
else -> SummaryNotification.Update(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue