mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Expose global account data get and set on MatrixClient
MatrixClient had no way to read or write global account data although the underlying client supports it. Add getAccountData and setAccountData to the interface and implement them in RustMatrixClient using the same withContext/runCatchingExceptions idiom as the neighbouring methods. The content is the raw JSON string the SDK returns and accepts: event types are open ended, so a typed wrapper belongs to whichever caller needs one. Scope is limited to global account data; the room level variant and the change notification APIs can follow when a feature needs them.
This commit is contained in:
+10
@@ -124,6 +124,8 @@ class FakeMatrixClient(
|
||||
private val getJoinedRoomIdsResult: () -> Result<Set<RoomId>> = { Result.success(emptySet()) },
|
||||
private val getRecentEmojisLambda: () -> Result<List<String>> = { Result.success(emptyList()) },
|
||||
private val addRecentEmojiLambda: (String) -> Result<Unit> = { Result.success(Unit) },
|
||||
private val getAccountDataLambda: (String) -> Result<String?> = { lambdaError() },
|
||||
private val setAccountDataLambda: (String, String) -> Result<Unit> = { _, _ -> lambdaError() },
|
||||
private val markRoomAsFullyReadResult: (RoomId, EventId) -> Result<Unit> = { _, _ -> lambdaError() },
|
||||
private val markAllRoomsAsReadResult: () -> Result<Unit> = { Result.success(Unit) },
|
||||
private val performDatabaseVacuumLambda: () -> Result<Unit> = { lambdaError() },
|
||||
@@ -407,6 +409,14 @@ class FakeMatrixClient(
|
||||
return getRecentEmojisLambda()
|
||||
}
|
||||
|
||||
override suspend fun getAccountData(eventType: String): Result<String?> {
|
||||
return getAccountDataLambda(eventType)
|
||||
}
|
||||
|
||||
override suspend fun setAccountData(eventType: String, content: String): Result<Unit> {
|
||||
return setAccountDataLambda(eventType, content)
|
||||
}
|
||||
|
||||
override suspend fun markRoomAsFullyRead(roomId: RoomId, eventId: EventId): Result<Unit> {
|
||||
return markRoomAsFullyReadResult(roomId, eventId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user