Initial support for member suggestions (#1631)
* Initial support for member suggestion (search and UI) * Add custom `BottomSheetScaffold` implementation to workaround several scrolling bugs * Start searching as soon as `@` is typed, add UI following initial designs * Extract suggestion processing code * Extract component, add previews, fix tests * Add tests * Add exception from kover to the forked bottom sheet code * Add a feature flag for mentions - Extract composer & mention suggestions to their composable. - Extract mentions suggestions processing to its own class. - Add `MatrixRoom.canTriggerRoomNotification` function. - Update strings and conditions for displaying the `@room` mention. --------- Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
parent
d7ce326612
commit
0bd9c78836
312 changed files with 1522 additions and 51 deletions
|
|
@ -130,6 +130,8 @@ interface MatrixRoom : Closeable {
|
|||
|
||||
suspend fun canUserSendMessage(userId: UserId, type: MessageEventType): Result<Boolean>
|
||||
|
||||
suspend fun canUserTriggerRoomNotification(userId: UserId): Result<Boolean>
|
||||
|
||||
suspend fun updateAvatar(mimeType: String, data: ByteArray): Result<Unit>
|
||||
|
||||
suspend fun removeAvatar(): Result<Unit>
|
||||
|
|
|
|||
|
|
@ -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.matrix.api.user
|
||||
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import io.element.android.libraries.di.SingleIn
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import javax.inject.Inject
|
||||
|
||||
@SingleIn(SessionScope::class)
|
||||
class CurrentSessionIdHolder @Inject constructor(matrixClient: MatrixClient) {
|
||||
val current = matrixClient.sessionId
|
||||
|
||||
fun isCurrentSession(sessionId: SessionId?): Boolean = current == sessionId
|
||||
}
|
||||
|
|
@ -349,6 +349,12 @@ class RustMatrixRoom(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun canUserTriggerRoomNotification(userId: UserId): Result<Boolean> {
|
||||
return runCatching {
|
||||
innerRoom.canUserTriggerRoomNotification(userId.value)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun sendImage(file: File, thumbnailFile: File, imageInfo: ImageInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
|
||||
return sendAttachment(listOf(file, thumbnailFile)) {
|
||||
innerRoom.sendImage(file.path, thumbnailFile.path, imageInfo.map(), progressCallback?.toProgressWatcher())
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class FakeMatrixRoom(
|
|||
override val alternativeAliases: List<String> = emptyList(),
|
||||
override val isPublic: Boolean = true,
|
||||
override val isDirect: Boolean = false,
|
||||
override val isOneToOne: Boolean = false,
|
||||
override val joinedMemberCount: Long = 123L,
|
||||
override val activeMemberCount: Long = 234L,
|
||||
val notificationSettingsService: NotificationSettingsService = FakeNotificationSettingsService(),
|
||||
|
|
@ -106,6 +107,7 @@ class FakeMatrixRoom(
|
|||
private var progressCallbackValues = emptyList<Pair<Long, Long>>()
|
||||
private var generateWidgetWebViewUrlResult = Result.success("https://call.element.io")
|
||||
private var getWidgetDriverResult: Result<MatrixWidgetDriver> = Result.success(FakeWidgetDriver())
|
||||
private var canUserTriggerRoomNotificationResult: Result<Boolean> = Result.success(true)
|
||||
val editMessageCalls = mutableListOf<Pair<String, String?>>()
|
||||
|
||||
var sendMediaCount = 0
|
||||
|
|
@ -270,6 +272,10 @@ class FakeMatrixRoom(
|
|||
return canSendEventResults[type] ?: Result.failure(IllegalStateException("No fake answer"))
|
||||
}
|
||||
|
||||
override suspend fun canUserTriggerRoomNotification(userId: UserId): Result<Boolean> {
|
||||
return canUserTriggerRoomNotificationResult
|
||||
}
|
||||
|
||||
override suspend fun sendImage(
|
||||
file: File,
|
||||
thumbnailFile: File,
|
||||
|
|
@ -434,6 +440,10 @@ class FakeMatrixRoom(
|
|||
canSendEventResults[type] = result
|
||||
}
|
||||
|
||||
fun givenCanTriggerRoomNotification(result: Result<Boolean>) {
|
||||
canUserTriggerRoomNotificationResult = result
|
||||
}
|
||||
|
||||
fun givenIgnoreResult(result: Result<Unit>) {
|
||||
ignoreResult = result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue