mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 03:49:04 +03:00
Fix code quality issues
This commit is contained in:
parent
e245023add
commit
eb446d7b49
4 changed files with 13 additions and 10 deletions
|
@ -82,7 +82,7 @@ internal class DefaultCreateRoomTask @Inject constructor(private val roomAPI: Ro
|
|||
this.isDirect = true
|
||||
}
|
||||
}.flatMap {
|
||||
val directChats = directChatsHelper.getDirectChats()
|
||||
val directChats = directChatsHelper.getLocalUserAccount()
|
||||
updateUserAccountDataTask.execute(UpdateUserAccountDataTask.DirectChatParams(directMessages = directChats))
|
||||
}.flatMap {
|
||||
Try.just(roomId)
|
||||
|
|
|
@ -79,7 +79,7 @@ internal class UserAccountDataSyncHandler @Inject constructor(private val monarc
|
|||
private fun synchronizeWithServerIfNeeded(realm: Realm, invites: Map<String, InvitedRoomSync>?) {
|
||||
if (invites.isNullOrEmpty()) return
|
||||
|
||||
val directChats = directChatsHelper.getDirectChats()
|
||||
val directChats = directChatsHelper.getLocalUserAccount()
|
||||
val directChatInvites = HashMap<String, MutableList<String>>().apply {
|
||||
directChats.forEach { (inviterId, roomIds) ->
|
||||
put(inviterId, ArrayList(roomIds))
|
||||
|
|
|
@ -24,18 +24,24 @@ import io.realm.RealmConfiguration
|
|||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class DirectChatsHelper @Inject constructor(@SessionDatabase private val realmConfiguration: RealmConfiguration) {
|
||||
internal class DirectChatsHelper @Inject constructor(@SessionDatabase
|
||||
private val realmConfiguration: RealmConfiguration) {
|
||||
|
||||
fun getDirectChats(filterRoomId: String? = null): Map<String, List<String>> {
|
||||
/**
|
||||
* @return a map of userId <-> list of roomId
|
||||
*/
|
||||
fun getLocalUserAccount(filterRoomId: String? = null): Map<String, List<String>> {
|
||||
return Realm.getInstance(realmConfiguration).use { realm ->
|
||||
val currentDirectRooms = RoomSummaryEntity.getDirectRooms(realm)
|
||||
val directChatsMap = mutableMapOf<String, MutableList<String>>()
|
||||
for (directRoom in currentDirectRooms) {
|
||||
if (directRoom.roomId == filterRoomId) continue
|
||||
val directUserId = directRoom.directUserId ?: continue
|
||||
directChatsMap.getOrPut(directUserId, { arrayListOf() }).apply {
|
||||
add(directRoom.roomId)
|
||||
}
|
||||
directChatsMap
|
||||
.getOrPut(directUserId, { arrayListOf() })
|
||||
.apply {
|
||||
add(directRoom.roomId)
|
||||
}
|
||||
}
|
||||
directChatsMap
|
||||
}
|
||||
|
|
|
@ -93,8 +93,6 @@
|
|||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/chipGroupScrollView" />
|
||||
|
||||
|
@ -113,7 +111,6 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:minHeight="@dimen/layout_touch_size"
|
||||
|
|
Loading…
Reference in a new issue