mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 18:05:59 +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
|
this.isDirect = true
|
||||||
}
|
}
|
||||||
}.flatMap {
|
}.flatMap {
|
||||||
val directChats = directChatsHelper.getDirectChats()
|
val directChats = directChatsHelper.getLocalUserAccount()
|
||||||
updateUserAccountDataTask.execute(UpdateUserAccountDataTask.DirectChatParams(directMessages = directChats))
|
updateUserAccountDataTask.execute(UpdateUserAccountDataTask.DirectChatParams(directMessages = directChats))
|
||||||
}.flatMap {
|
}.flatMap {
|
||||||
Try.just(roomId)
|
Try.just(roomId)
|
||||||
|
|
|
@ -79,7 +79,7 @@ internal class UserAccountDataSyncHandler @Inject constructor(private val monarc
|
||||||
private fun synchronizeWithServerIfNeeded(realm: Realm, invites: Map<String, InvitedRoomSync>?) {
|
private fun synchronizeWithServerIfNeeded(realm: Realm, invites: Map<String, InvitedRoomSync>?) {
|
||||||
if (invites.isNullOrEmpty()) return
|
if (invites.isNullOrEmpty()) return
|
||||||
|
|
||||||
val directChats = directChatsHelper.getDirectChats()
|
val directChats = directChatsHelper.getLocalUserAccount()
|
||||||
val directChatInvites = HashMap<String, MutableList<String>>().apply {
|
val directChatInvites = HashMap<String, MutableList<String>>().apply {
|
||||||
directChats.forEach { (inviterId, roomIds) ->
|
directChats.forEach { (inviterId, roomIds) ->
|
||||||
put(inviterId, ArrayList(roomIds))
|
put(inviterId, ArrayList(roomIds))
|
||||||
|
|
|
@ -24,16 +24,22 @@ import io.realm.RealmConfiguration
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
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 ->
|
return Realm.getInstance(realmConfiguration).use { realm ->
|
||||||
val currentDirectRooms = RoomSummaryEntity.getDirectRooms(realm)
|
val currentDirectRooms = RoomSummaryEntity.getDirectRooms(realm)
|
||||||
val directChatsMap = mutableMapOf<String, MutableList<String>>()
|
val directChatsMap = mutableMapOf<String, MutableList<String>>()
|
||||||
for (directRoom in currentDirectRooms) {
|
for (directRoom in currentDirectRooms) {
|
||||||
if (directRoom.roomId == filterRoomId) continue
|
if (directRoom.roomId == filterRoomId) continue
|
||||||
val directUserId = directRoom.directUserId ?: continue
|
val directUserId = directRoom.directUserId ?: continue
|
||||||
directChatsMap.getOrPut(directUserId, { arrayListOf() }).apply {
|
directChatsMap
|
||||||
|
.getOrPut(directUserId, { arrayListOf() })
|
||||||
|
.apply {
|
||||||
add(directRoom.roomId)
|
add(directRoom.roomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,6 @@
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/chipGroupScrollView" />
|
app:layout_constraintTop_toBottomOf="@+id/chipGroupScrollView" />
|
||||||
|
|
||||||
|
@ -113,7 +111,6 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:minHeight="@dimen/layout_touch_size"
|
android:minHeight="@dimen/layout_touch_size"
|
||||||
|
|
Loading…
Reference in a new issue