code review update
This commit is contained in:
parent
9929d6a4eb
commit
82e68472dc
@ -271,7 +271,7 @@ private fun HashMap<String, RoomMemberContent?>.addSenderState(realm: Realm, roo
|
|||||||
* Create an EventEntity for the root thread event or get an existing one.
|
* Create an EventEntity for the root thread event or get an existing one.
|
||||||
*/
|
*/
|
||||||
private fun createEventEntity(realm: Realm, roomId: String, event: Event, currentTimeMillis: Long): EventEntity {
|
private fun createEventEntity(realm: Realm, roomId: String, event: Event, currentTimeMillis: Long): EventEntity {
|
||||||
val ageLocalTs = event.unsignedData?.age?.let { currentTimeMillis - it } ?: currentTimeMillis
|
val ageLocalTs = currentTimeMillis - (event.unsignedData?.age ?: 0)
|
||||||
return event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
return event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ internal class DefaultLoadRoomMembersTask @Inject constructor(
|
|||||||
if (roomMemberEvent.eventId == null || roomMemberEvent.stateKey == null || roomMemberEvent.type == null) {
|
if (roomMemberEvent.eventId == null || roomMemberEvent.stateKey == null || roomMemberEvent.type == null) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val ageLocalTs = roomMemberEvent.unsignedData?.age?.let { now - it } ?: now
|
val ageLocalTs = now - (roomMemberEvent.unsignedData?.age ?: 0)
|
||||||
val eventEntity = roomMemberEvent.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
val eventEntity = roomMemberEvent.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
||||||
CurrentStateEventEntity.getOrCreate(
|
CurrentStateEventEntity.getOrCreate(
|
||||||
realm,
|
realm,
|
||||||
|
@ -210,7 +210,7 @@ internal class DefaultFetchThreadTimelineTask @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
private fun createEventEntity(roomId: String, event: Event, realm: Realm): EventEntity {
|
private fun createEventEntity(roomId: String, event: Event, realm: Realm): EventEntity {
|
||||||
val now = clock.epochMillis()
|
val now = clock.epochMillis()
|
||||||
val ageLocalTs = event.unsignedData?.age?.let { now - it } ?: now
|
val ageLocalTs = now - (event.unsignedData?.age ?: 0)
|
||||||
return event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
return event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ internal class DefaultGetEventTask @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.ageLocalTs = event.unsignedData?.age?.let { clock.epochMillis() - it }
|
event.ageLocalTs = clock.epochMillis() - (event.unsignedData?.age ?: 0)
|
||||||
|
|
||||||
return event
|
return event
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ internal class TokenChunkEventPersistor @Inject constructor(
|
|||||||
val now = clock.epochMillis()
|
val now = clock.epochMillis()
|
||||||
|
|
||||||
stateEvents?.forEach { stateEvent ->
|
stateEvents?.forEach { stateEvent ->
|
||||||
val ageLocalTs = stateEvent.unsignedData?.age?.let { now - it } ?: now
|
val ageLocalTs = now - (stateEvent.unsignedData?.age ?: 0)
|
||||||
val stateEventEntity = stateEvent.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
val stateEventEntity = stateEvent.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
||||||
currentChunk.addStateEvent(roomId, stateEventEntity, direction)
|
currentChunk.addStateEvent(roomId, stateEventEntity, direction)
|
||||||
if (stateEvent.type == EventType.STATE_ROOM_MEMBER && stateEvent.stateKey != null) {
|
if (stateEvent.type == EventType.STATE_ROOM_MEMBER && stateEvent.stateKey != null) {
|
||||||
@ -155,7 +155,7 @@ internal class TokenChunkEventPersistor @Inject constructor(
|
|||||||
if (event.eventId == null || event.senderId == null) {
|
if (event.eventId == null || event.senderId == null) {
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
val ageLocalTs = event.unsignedData?.age?.let { now - it } ?: now
|
val ageLocalTs = now - (event.unsignedData?.age ?: 0)
|
||||||
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.PAGINATION)
|
||||||
if (event.type == EventType.STATE_ROOM_MEMBER && event.stateKey != null) {
|
if (event.type == EventType.STATE_ROOM_MEMBER && event.stateKey != null) {
|
||||||
val contentToUse = if (direction == PaginationDirection.BACKWARDS) {
|
val contentToUse = if (direction == PaginationDirection.BACKWARDS) {
|
||||||
|
@ -244,7 +244,7 @@ internal class RoomSyncHandler @Inject constructor(
|
|||||||
if (event.eventId == null || event.stateKey == null || event.type == null) {
|
if (event.eventId == null || event.stateKey == null || event.type == null) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val ageLocalTs = event.unsignedData?.age?.let { syncLocalTimestampMillis - it } ?: syncLocalTimestampMillis
|
val ageLocalTs = syncLocalTimestampMillis - (event.unsignedData?.age ?: 0)
|
||||||
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
||||||
Timber.v("## received state event ${event.type} and key ${event.stateKey}")
|
Timber.v("## received state event ${event.type} and key ${event.stateKey}")
|
||||||
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
||||||
@ -306,7 +306,7 @@ internal class RoomSyncHandler @Inject constructor(
|
|||||||
if (event.stateKey == null || event.type == null) {
|
if (event.stateKey == null || event.type == null) {
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
val ageLocalTs = event.unsignedData?.age?.let { syncLocalTimestampMillis - it } ?: syncLocalTimestampMillis
|
val ageLocalTs = syncLocalTimestampMillis - (event.unsignedData?.age ?: 0)
|
||||||
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
||||||
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
||||||
eventId = eventEntity.eventId
|
eventId = eventEntity.eventId
|
||||||
@ -336,7 +336,7 @@ internal class RoomSyncHandler @Inject constructor(
|
|||||||
if (event.eventId == null || event.stateKey == null || event.type == null) {
|
if (event.eventId == null || event.stateKey == null || event.type == null) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val ageLocalTs = event.unsignedData?.age?.let { syncLocalTimestampMillis - it } ?: syncLocalTimestampMillis
|
val ageLocalTs = syncLocalTimestampMillis - (event.unsignedData?.age ?: 0)
|
||||||
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
||||||
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
||||||
eventId = event.eventId
|
eventId = event.eventId
|
||||||
@ -348,7 +348,7 @@ internal class RoomSyncHandler @Inject constructor(
|
|||||||
if (event.eventId == null || event.senderId == null || event.type == null) {
|
if (event.eventId == null || event.senderId == null || event.type == null) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val ageLocalTs = event.unsignedData?.age?.let { syncLocalTimestampMillis - it } ?: syncLocalTimestampMillis
|
val ageLocalTs = syncLocalTimestampMillis - (event.unsignedData?.age ?: 0)
|
||||||
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
||||||
if (event.stateKey != null) {
|
if (event.stateKey != null) {
|
||||||
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
||||||
@ -401,7 +401,7 @@ internal class RoomSyncHandler @Inject constructor(
|
|||||||
for (rawEvent in eventList) {
|
for (rawEvent in eventList) {
|
||||||
// It's annoying roomId is not there, but lot of code rely on it.
|
// It's annoying roomId is not there, but lot of code rely on it.
|
||||||
// And had to do it now as copy would delete all decryption results..
|
// And had to do it now as copy would delete all decryption results..
|
||||||
val ageLocalTs = rawEvent.unsignedData?.age?.let { syncLocalTimestampMillis - it } ?: syncLocalTimestampMillis
|
val ageLocalTs = syncLocalTimestampMillis - (rawEvent.unsignedData?.age ?: 0)
|
||||||
val event = rawEvent.copy(roomId = roomId).also {
|
val event = rawEvent.copy(roomId = roomId).also {
|
||||||
it.ageLocalTs = ageLocalTs
|
it.ageLocalTs = ageLocalTs
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class VerificationChooseMethodController @Inject constructor(
|
|||||||
iconColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
|
iconColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
|
||||||
listener { host.listener?.doVerifyBySas() }
|
listener { host.listener?.doVerifyBySas() }
|
||||||
}
|
}
|
||||||
} else if (!state.isReadied) {
|
} else if (!state.isReadySent) {
|
||||||
// a bit of a special case, if you tapped on the timeline cell but not on a button
|
// a bit of a special case, if you tapped on the timeline cell but not on a button
|
||||||
buttonPositiveDestructiveButtonBarItem {
|
buttonPositiveDestructiveButtonBarItem {
|
||||||
id("accept_decline")
|
id("accept_decline")
|
||||||
|
@ -101,16 +101,12 @@ class VerificationChooseMethodFragment @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun acceptRequest() {
|
override fun acceptRequest() {
|
||||||
withState(viewModel) {
|
|
||||||
sharedViewModel.handle(VerificationAction.ReadyPendingVerification)
|
sharedViewModel.handle(VerificationAction.ReadyPendingVerification)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun declineRequest() {
|
override fun declineRequest() {
|
||||||
withState(viewModel) {
|
|
||||||
sharedViewModel.handle(VerificationAction.CancelPendingVerification)
|
sharedViewModel.handle(VerificationAction.CancelPendingVerification)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun doOpenQRCodeScanner() {
|
private fun doOpenQRCodeScanner() {
|
||||||
QrCodeScannerActivity.startForResult(requireActivity(), scanActivityResultLauncher)
|
QrCodeScannerActivity.startForResult(requireActivity(), scanActivityResultLauncher)
|
||||||
|
@ -45,7 +45,7 @@ data class VerificationChooseMethodViewState(
|
|||||||
val sasModeAvailable: Boolean = false,
|
val sasModeAvailable: Boolean = false,
|
||||||
val isMe: Boolean = false,
|
val isMe: Boolean = false,
|
||||||
val canCrossSign: Boolean = false,
|
val canCrossSign: Boolean = false,
|
||||||
val isReadied: Boolean = false
|
val isReadySent: Boolean = false
|
||||||
) : MavericksState
|
) : MavericksState
|
||||||
|
|
||||||
class VerificationChooseMethodViewModel @AssistedInject constructor(
|
class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||||
@ -83,7 +83,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
|||||||
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
||||||
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
||||||
sasModeAvailable = pvr?.isSasSupported().orFalse(),
|
sasModeAvailable = pvr?.isSasSupported().orFalse(),
|
||||||
isReadied = pvr?.isReady ?: false,
|
isReadySent = pvr?.isReady.orFalse(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal">
|
||||||
tools:visibility="visible">
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/destructive_button"
|
android:id="@+id/destructive_button"
|
||||||
@ -13,13 +12,13 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:text="@string/action_decline" />
|
tools:text="@string/action_decline" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/positive_button"
|
android:id="@+id/positive_button"
|
||||||
style="@style/Widget.Vector.Button.Positive"
|
style="@style/Widget.Vector.Button.Positive"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/action_accept" />
|
tools:text="@string/action_accept" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user