Fix code quality issues

This commit is contained in:
ganfra 2019-08-14 14:53:40 +02:00
parent d3827b8673
commit 501474b720
3 changed files with 33 additions and 9 deletions

View File

@ -65,13 +65,29 @@ internal class RoomFactory @Inject constructor(private val context: Context,
private val leaveRoomTask: LeaveRoomTask) {

fun create(roomId: String): Room {
val timelineService = DefaultTimelineService(roomId, monarchy, taskExecutor, contextOfEventTask, cryptoService, paginationTask, timelineEventMapper, readReceiptsSummaryMapper)
val timelineService = DefaultTimelineService(roomId,
monarchy,
taskExecutor,
contextOfEventTask,
cryptoService,
paginationTask,
timelineEventMapper,
readReceiptsSummaryMapper
)
val sendService = DefaultSendService(context, credentials, roomId, eventFactory, cryptoService, monarchy)
val stateService = DefaultStateService(roomId, monarchy.realmConfiguration, taskExecutor, sendStateTask)
val roomMembersService = DefaultMembershipService(roomId, monarchy, taskExecutor, loadRoomMembersTask, inviteTask, joinRoomTask, leaveRoomTask)
val readService = DefaultReadService(roomId, monarchy, taskExecutor, setReadMarkersTask, readReceiptsSummaryMapper, credentials)
val relationService = DefaultRelationService(context,
credentials, roomId, eventFactory, cryptoService, findReactionEventForUndoTask, fetchEditHistoryTask, monarchy, taskExecutor)
credentials,
roomId,
eventFactory,
cryptoService,
findReactionEventForUndoTask,
fetchEditHistoryTask,
monarchy,
taskExecutor
)

return DefaultRoom(
roomId,

View File

@ -52,7 +52,10 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu
// Deletion here means we don't have any readReceipts for the given hidden events
changeSet.deletions.forEach {
val eventId = correctedReadReceiptsEventByIndex[it]
val timelineEvent = liveEvents.where().equalTo(TimelineEventEntityFields.EVENT_ID, eventId).findFirst()
val timelineEvent = liveEvents.where()
.equalTo(TimelineEventEntityFields.EVENT_ID, eventId)
.findFirst()

// We are rebuilding the corresponding event with only his own RR
val readReceipts = readReceiptsSummaryMapper.map(timelineEvent?.readReceipts)
hasChange = delegate.rebuildEvent(eventId, readReceipts) || hasChange
@ -71,11 +74,11 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu
// If we find one, we should
if (firstDisplayedEvent != null) {
correctedReadReceiptsEventByIndex.put(index, firstDisplayedEvent.eventId)
correctedReadReceiptsByEvent.getOrPut(firstDisplayedEvent.eventId, {
readReceiptsSummaryMapper.map(firstDisplayedEvent.readReceipts).toMutableList()
}).addAll(
readReceiptsSummaryMapper.map(summary)
)
correctedReadReceiptsByEvent
.getOrPut(firstDisplayedEvent.eventId, {
ArrayList(readReceiptsSummaryMapper.map(firstDisplayedEvent.readReceipts))
})
.addAll(readReceiptsSummaryMapper.map(summary))
}
}
}

View File

@ -46,7 +46,12 @@ class VectorDateFormatter @Inject constructor(private val context: Context,
if (time == null) {
return ""
}
return DateUtils.getRelativeDateTimeString(context, time, DateUtils.DAY_IN_MILLIS, 2 * DateUtils.DAY_IN_MILLIS, DateUtils.FORMAT_SHOW_WEEKDAY).toString()
return DateUtils.getRelativeDateTimeString(context,
time,
DateUtils.DAY_IN_MILLIS,
2 * DateUtils.DAY_IN_MILLIS,
DateUtils.FORMAT_SHOW_WEEKDAY
).toString()
}

}