mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Support retrieving account data whose key starts with a string.
This commit is contained in:
parent
b09a00efda
commit
3d68233723
2 changed files with 23 additions and 0 deletions
|
@ -63,4 +63,17 @@ interface SessionAccountDataService {
|
|||
* Update the account data with the provided type and the provided account data content.
|
||||
*/
|
||||
suspend fun updateUserAccountData(type: String, content: Content)
|
||||
|
||||
/**
|
||||
* Retrieve user account data list whose type starts with the given type.
|
||||
* @param type the type or the starting part of a type
|
||||
* @return list of account data whose type starts with the given type
|
||||
*/
|
||||
fun getUserAccountDataEventsStartWith(type: String): List<UserAccountDataEvent>
|
||||
|
||||
/**
|
||||
* Deletes user account data of the given type.
|
||||
* @param type the type to delete from user account data
|
||||
*/
|
||||
suspend fun deleteUserAccountData(type: String)
|
||||
}
|
||||
|
|
|
@ -60,6 +60,16 @@ internal class UserAccountDataDataSource @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
fun getAccountDataEventsStartWith(type: String): List<UserAccountDataEvent> {
|
||||
return realmSessionProvider.withRealm { realm ->
|
||||
realm
|
||||
.where(UserAccountDataEntity::class.java)
|
||||
.contains(UserAccountDataEntityFields.TYPE, type)
|
||||
.findAll()
|
||||
.map(accountDataMapper::map)
|
||||
}
|
||||
}
|
||||
|
||||
private fun accountDataEventsQuery(realm: Realm, types: Set<String>): RealmQuery<UserAccountDataEntity> {
|
||||
val query = realm.where(UserAccountDataEntity::class.java)
|
||||
if (types.isNotEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue