Clean code

This commit is contained in:
ganfra 2020-06-25 12:12:50 +02:00
parent f28e3ca504
commit 60c873aa66
13 changed files with 15 additions and 24 deletions

View file

@ -202,5 +202,4 @@ interface Session :
}
val sharedSecretStorageService: SharedSecretStorageService
}

View file

@ -18,7 +18,7 @@ package im.vector.matrix.android.api.session.room.model
data class EventAnnotationsSummary(
var eventId: String,
var reactionsSummary: List<ReactionAggregatedSummary> = emptyList(),
var editSummary: EditAggregatedSummary?= null,
var editSummary: EditAggregatedSummary? = null,
var pollResponseSummary: PollResponseAggregatedSummary? = null,
var referencesAggregatedSummary: ReferencesAggregatedSummary? = null
)

View file

@ -34,5 +34,4 @@ interface TypingUsersTracker {
* Returns a LiveData of the sender information of all currently typing users in a room, excluding yourself.
*/
fun getTypingUsersLive(roomId: String): LiveData<List<SenderInfo>>
}

View file

@ -15,7 +15,6 @@
*/
package im.vector.matrix.android.internal.database.query
import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.api.session.events.model.LocalEcho
import im.vector.matrix.android.internal.database.model.ChunkEntity
import im.vector.matrix.android.internal.database.model.ReadMarkerEntity
@ -36,7 +35,7 @@ internal fun isEventRead(realmConfiguration: RealmConfiguration,
}
var isEventRead = false
Realm.getInstance(realmConfiguration).use{ realm ->
Realm.getInstance(realmConfiguration).use { realm ->
val liveChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomId) ?: return@use
val eventToCheck = liveChunk.timelineEvents.find(eventId)
isEventRead = if (eventToCheck == null || eventToCheck.root?.sender == userId) {

View file

@ -27,16 +27,16 @@ internal interface SessionLifecycleObserver {
Called when the session is opened
*/
@MainThread
fun onStart(){
//noop
fun onStart() {
// noop
}
/*
Called when the session is cleared
*/
@MainThread
fun onClearCache(){
//noop
fun onClearCache() {
// noop
}
/*
@ -44,6 +44,6 @@ internal interface SessionLifecycleObserver {
*/
@MainThread
fun onStop() {
//noop
// noop
}
}

View file

@ -17,7 +17,6 @@
package im.vector.matrix.android.internal.session.room
import androidx.lifecycle.LiveData
import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.session.room.Room
import im.vector.matrix.android.api.session.room.RoomService
@ -26,8 +25,6 @@ import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams
import im.vector.matrix.android.api.util.Cancelable
import im.vector.matrix.android.api.util.Optional
import im.vector.matrix.android.internal.database.mapper.RoomSummaryMapper
import im.vector.matrix.android.internal.di.SessionDatabase
import im.vector.matrix.android.internal.session.room.alias.GetRoomIdByAliasTask
import im.vector.matrix.android.internal.session.room.create.CreateRoomTask
import im.vector.matrix.android.internal.session.room.membership.joining.JoinRoomTask

View file

@ -54,7 +54,7 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
})
}
fun getRoomSummaryLive(roomId: String): LiveData<Optional<RoomSummary>>{
fun getRoomSummaryLive(roomId: String): LiveData<Optional<RoomSummary>> {
val liveData = monarchy.findAllMappedWithChanges(
{ realm -> RoomSummaryEntity.where(realm, roomId).isNotEmpty(RoomSummaryEntityFields.DISPLAY_NAME) },
{ roomSummaryMapper.map(it) }

View file

@ -21,11 +21,8 @@ import im.vector.matrix.android.api.extensions.orFalse
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.RelationType
import im.vector.matrix.android.api.session.events.model.toModel
import im.vector.matrix.android.api.session.room.model.EventAnnotationsSummary
import im.vector.matrix.android.api.session.room.model.ReactionAggregatedSummary
import im.vector.matrix.android.api.session.room.model.ReadReceipt
import im.vector.matrix.android.api.session.room.model.message.MessageContent
import im.vector.matrix.android.api.session.room.model.relation.ReactionContent
import im.vector.matrix.android.api.session.room.send.SendState
import im.vector.matrix.android.api.session.room.timeline.Timeline
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent

View file

@ -30,7 +30,6 @@ import com.squareup.inject.assisted.AssistedInject
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.MatrixPatterns
import im.vector.matrix.android.api.NoOpMatrixCallback
import im.vector.matrix.android.api.extensions.orFalse
import im.vector.matrix.android.api.query.QueryStringValue
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.session.events.model.EventType
@ -59,7 +58,6 @@ import im.vector.matrix.android.api.session.room.timeline.getTextEditableContent
import im.vector.matrix.android.api.util.toOptional
import im.vector.matrix.android.internal.crypto.attachments.toElementToDecrypt
import im.vector.matrix.android.internal.crypto.model.event.EncryptedEventContent
import im.vector.matrix.android.internal.extensions.observeK
import im.vector.matrix.rx.asObservable
import im.vector.matrix.rx.rx
import im.vector.matrix.rx.unwrap
@ -1045,7 +1043,7 @@ class RoomDetailViewModel @AssistedInject constructor(
}
}
private fun observeTypings(){
private fun observeTypings() {
typingHelper.getTypingMessage(initialState.roomId)
.asObservable()
.subscribe {

View file

@ -26,7 +26,6 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
import im.vector.matrix.android.api.session.sync.SyncState
import im.vector.matrix.android.api.session.user.model.User
import im.vector.matrix.android.api.session.widgets.model.Widget
import im.vector.matrix.android.api.util.MatrixItem
/**
* Describes the current send mode:

View file

@ -25,5 +25,4 @@ import im.vector.riotx.core.epoxy.VectorEpoxyModel
abstract class TimelineReadMarkerItem : VectorEpoxyModel<TimelineReadMarkerItem.Holder>() {
class Holder : VectorEpoxyHolder()
}

View file

@ -50,9 +50,13 @@ class TypingHelper @Inject constructor(
typingUsers.size == 1 ->
stringProvider.getString(R.string.room_one_user_is_typing, typingUsers[0].disambiguatedDisplayName)
typingUsers.size == 2 ->
stringProvider.getString(R.string.room_two_users_are_typing, typingUsers[0].disambiguatedDisplayName, typingUsers[1].disambiguatedDisplayName)
stringProvider.getString(R.string.room_two_users_are_typing,
typingUsers[0].disambiguatedDisplayName,
typingUsers[1].disambiguatedDisplayName)
else ->
stringProvider.getString(R.string.room_many_users_are_typing, typingUsers[0].disambiguatedDisplayName, typingUsers[1].disambiguatedDisplayName)
stringProvider.getString(R.string.room_many_users_are_typing,
typingUsers[0].disambiguatedDisplayName,
typingUsers[1].disambiguatedDisplayName)
}
}
}