mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Update rust sdk to 0.1.31: new notification api
This commit is contained in:
+5
-1
@@ -94,8 +94,11 @@ class RustMatrixClient constructor(
|
|||||||
client = client,
|
client = client,
|
||||||
dispatchers = dispatchers,
|
dispatchers = dispatchers,
|
||||||
)
|
)
|
||||||
|
private val notificationClient = client.notificationClient().use { builder ->
|
||||||
|
builder.finish()
|
||||||
|
}
|
||||||
|
|
||||||
private val notificationService = RustNotificationService(client)
|
private val notificationService = RustNotificationService(notificationClient)
|
||||||
|
|
||||||
private val clientDelegate = object : ClientDelegate {
|
private val clientDelegate = object : ClientDelegate {
|
||||||
override fun didReceiveAuthError(isSoftLogout: Boolean) {
|
override fun didReceiveAuthError(isSoftLogout: Boolean) {
|
||||||
@@ -250,6 +253,7 @@ class RustMatrixClient constructor(
|
|||||||
client.setDelegate(null)
|
client.setDelegate(null)
|
||||||
verificationService.destroy()
|
verificationService.destroy()
|
||||||
roomListService.destroy()
|
roomListService.destroy()
|
||||||
|
notificationClient.destroy()
|
||||||
client.destroy()
|
client.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -27,12 +27,12 @@ import org.matrix.rustcomponents.sdk.use
|
|||||||
class NotificationMapper {
|
class NotificationMapper {
|
||||||
private val timelineEventMapper = TimelineEventMapper()
|
private val timelineEventMapper = TimelineEventMapper()
|
||||||
|
|
||||||
fun map(notificationItem: NotificationItem): NotificationData {
|
fun map(roomId: RoomId, notificationItem: NotificationItem): NotificationData {
|
||||||
return notificationItem.use { item ->
|
return notificationItem.use { item ->
|
||||||
NotificationData(
|
NotificationData(
|
||||||
senderId = UserId(item.event.senderId()),
|
senderId = UserId(item.event.senderId()),
|
||||||
eventId = EventId(item.event.eventId()),
|
eventId = EventId(item.event.eventId()),
|
||||||
roomId = RoomId(item.roomInfo.id),
|
roomId = roomId,
|
||||||
senderAvatarUrl = item.senderInfo.avatarUrl,
|
senderAvatarUrl = item.senderInfo.avatarUrl,
|
||||||
senderDisplayName = item.senderInfo.displayName,
|
senderDisplayName = item.senderInfo.displayName,
|
||||||
roomAvatarUrl = item.roomInfo.avatarUrl ?: item.senderInfo.avatarUrl.takeIf { item.roomInfo.isDirect },
|
roomAvatarUrl = item.roomInfo.avatarUrl ?: item.senderInfo.avatarUrl.takeIf { item.roomInfo.isDirect },
|
||||||
|
|||||||
+6
-4
@@ -21,11 +21,11 @@ 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.SessionId
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationData
|
import io.element.android.libraries.matrix.api.notification.NotificationData
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationService
|
import io.element.android.libraries.matrix.api.notification.NotificationService
|
||||||
import org.matrix.rustcomponents.sdk.Client
|
import org.matrix.rustcomponents.sdk.NotificationClient
|
||||||
import org.matrix.rustcomponents.sdk.use
|
import org.matrix.rustcomponents.sdk.use
|
||||||
|
|
||||||
class RustNotificationService(
|
class RustNotificationService(
|
||||||
private val client: Client,
|
private val notificationClient: NotificationClient,
|
||||||
) : NotificationService {
|
) : NotificationService {
|
||||||
private val notificationMapper: NotificationMapper = NotificationMapper()
|
private val notificationMapper: NotificationMapper = NotificationMapper()
|
||||||
|
|
||||||
@@ -36,8 +36,10 @@ class RustNotificationService(
|
|||||||
filterByPushRules: Boolean,
|
filterByPushRules: Boolean,
|
||||||
): Result<NotificationData?> {
|
): Result<NotificationData?> {
|
||||||
return runCatching {
|
return runCatching {
|
||||||
val item = client.getNotificationItem(roomId.value, eventId.value, filterByPushRules)
|
val item = notificationClient.getNotification(roomId.value, eventId.value)
|
||||||
item?.use(notificationMapper::map)
|
item?.use {
|
||||||
|
notificationMapper.map(roomId, it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user