Fix code quality issues

This commit is contained in:
ariskotsomitopoulos 2021-12-25 23:35:40 +02:00
parent 9ef4e1e83f
commit 0e30f4e817
3 changed files with 23 additions and 8 deletions

View file

@ -342,13 +342,17 @@ internal class DefaultTimeline(
updateState(Timeline.Direction.FORWARDS) { state ->
state.copy(
hasMoreInCache = !builtEventsIdMap.containsKey(firstCacheEvent?.eventId), // what is in DB
hasReachedEnd = if (isFromThreadTimeline) true else chunkEntity?.isLastForward ?: false // if you neeed fetch more
hasReachedEnd = if (isFromThreadTimeline) true else chunkEntity?.isLastForward ?: false // if you need fetch more
)
}
updateState(Timeline.Direction.BACKWARDS) { state ->
state.copy(
hasMoreInCache = !builtEventsIdMap.containsKey(lastCacheEvent?.eventId),
hasReachedEnd = if (isFromThreadTimeline && results.map { it.eventId }.contains(rootThreadEventId)) true else (chunkEntity?.isLastBackward ?: false || lastCacheEvent?.root?.type == EventType.STATE_ROOM_CREATE)
hasReachedEnd = if (isFromThreadTimeline && results.map { it.eventId }.contains(rootThreadEventId)) {
true
} else {
(chunkEntity?.isLastBackward ?: false || lastCacheEvent?.root?.type == EventType.STATE_ROOM_CREATE)
}
)
}
}

View file

@ -734,27 +734,32 @@ class TimelineFragment @Inject constructor(
}
override fun onSendVoiceMessage() {
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = false, rootThreadEventId = getRootThreadEventId()))
messageComposerViewModel.handle(
MessageComposerAction.EndRecordingVoiceMessage(isCancelled = false, rootThreadEventId = getRootThreadEventId()))
updateRecordingUiState(RecordingUiState.Idle)
}
override fun onDeleteVoiceMessage() {
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = true, rootThreadEventId = getRootThreadEventId()))
messageComposerViewModel.handle(
MessageComposerAction.EndRecordingVoiceMessage(isCancelled = true, rootThreadEventId = getRootThreadEventId()))
updateRecordingUiState(RecordingUiState.Idle)
}
override fun onRecordingLimitReached() {
messageComposerViewModel.handle(MessageComposerAction.PauseRecordingVoiceMessage)
messageComposerViewModel.handle(
MessageComposerAction.PauseRecordingVoiceMessage)
updateRecordingUiState(RecordingUiState.Draft)
}
override fun onRecordingWaveformClicked() {
messageComposerViewModel.handle(MessageComposerAction.PauseRecordingVoiceMessage)
messageComposerViewModel.handle(
MessageComposerAction.PauseRecordingVoiceMessage)
updateRecordingUiState(RecordingUiState.Draft)
}
private fun updateRecordingUiState(state: RecordingUiState) {
messageComposerViewModel.handle(MessageComposerAction.OnVoiceRecordingUiStateChanged(state))
messageComposerViewModel.handle(
MessageComposerAction.OnVoiceRecordingUiStateChanged(state))
}
}
}

View file

@ -83,7 +83,13 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde
eventIdToHighlight: String?,
requestModelBuild: () -> Unit,
callback: TimelineEventController.Callback?): MergedMembershipEventsItem_? {
val mergedEvents = timelineEventVisibilityHelper.prevSameTypeEvents(items, currentPosition, 2, eventIdToHighlight, partialState.rootThreadEventId, partialState.isFromThreadTimeline())
val mergedEvents = timelineEventVisibilityHelper.prevSameTypeEvents(
items,
currentPosition,
2,
eventIdToHighlight,
partialState.rootThreadEventId,
partialState.isFromThreadTimeline())
return if (mergedEvents.isEmpty()) {
null
} else {