mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
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.
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ internal class DefaultLoadRoomMembersTask @Inject constructor(
|
||||
if (roomMemberEvent.eventId == null || roomMemberEvent.stateKey == null || roomMemberEvent.type == null) {
|
||||
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)
|
||||
CurrentStateEventEntity.getOrCreate(
|
||||
realm,
|
||||
|
@ -210,7 +210,7 @@ internal class DefaultFetchThreadTimelineTask @Inject constructor(
|
||||
*/
|
||||
private fun createEventEntity(roomId: String, event: Event, realm: Realm): EventEntity {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ internal class TokenChunkEventPersistor @Inject constructor(
|
||||
val now = clock.epochMillis()
|
||||
|
||||
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)
|
||||
currentChunk.addStateEvent(roomId, stateEventEntity, direction)
|
||||
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) {
|
||||
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)
|
||||
if (event.type == EventType.STATE_ROOM_MEMBER && event.stateKey != null) {
|
||||
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) {
|
||||
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)
|
||||
Timber.v("## received state event ${event.type} and key ${event.stateKey}")
|
||||
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) {
|
||||
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)
|
||||
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
||||
eventId = eventEntity.eventId
|
||||
@ -336,7 +336,7 @@ internal class RoomSyncHandler @Inject constructor(
|
||||
if (event.eventId == null || event.stateKey == null || event.type == null) {
|
||||
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)
|
||||
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
||||
eventId = event.eventId
|
||||
@ -348,7 +348,7 @@ internal class RoomSyncHandler @Inject constructor(
|
||||
if (event.eventId == null || event.senderId == null || event.type == null) {
|
||||
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)
|
||||
if (event.stateKey != null) {
|
||||
CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
|
||||
@ -401,7 +401,7 @@ internal class RoomSyncHandler @Inject constructor(
|
||||
for (rawEvent in eventList) {
|
||||
// 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..
|
||||
val ageLocalTs = rawEvent.unsignedData?.age?.let { syncLocalTimestampMillis - it } ?: syncLocalTimestampMillis
|
||||
val ageLocalTs = syncLocalTimestampMillis - (rawEvent.unsignedData?.age ?: 0)
|
||||
val event = rawEvent.copy(roomId = roomId).also {
|
||||
it.ageLocalTs = ageLocalTs
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class VerificationChooseMethodController @Inject constructor(
|
||||
iconColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
|
||||
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
|
||||
buttonPositiveDestructiveButtonBarItem {
|
||||
id("accept_decline")
|
||||
|
@ -101,15 +101,11 @@ class VerificationChooseMethodFragment @Inject constructor(
|
||||
}
|
||||
|
||||
override fun acceptRequest() {
|
||||
withState(viewModel) {
|
||||
sharedViewModel.handle(VerificationAction.ReadyPendingVerification)
|
||||
}
|
||||
sharedViewModel.handle(VerificationAction.ReadyPendingVerification)
|
||||
}
|
||||
|
||||
override fun declineRequest() {
|
||||
withState(viewModel) {
|
||||
sharedViewModel.handle(VerificationAction.CancelPendingVerification)
|
||||
}
|
||||
sharedViewModel.handle(VerificationAction.CancelPendingVerification)
|
||||
}
|
||||
|
||||
private fun doOpenQRCodeScanner() {
|
||||
|
@ -45,7 +45,7 @@ data class VerificationChooseMethodViewState(
|
||||
val sasModeAvailable: Boolean = false,
|
||||
val isMe: Boolean = false,
|
||||
val canCrossSign: Boolean = false,
|
||||
val isReadied: Boolean = false
|
||||
val isReadySent: Boolean = false
|
||||
) : MavericksState
|
||||
|
||||
class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||
@ -83,7 +83,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
||||
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
||||
sasModeAvailable = pvr?.isSasSupported().orFalse(),
|
||||
isReadied = pvr?.isReady ?: false,
|
||||
isReadySent = pvr?.isReady.orFalse(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
tools:visibility="visible">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/destructive_button"
|
||||
@ -13,13 +12,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/action_decline" />
|
||||
tools:text="@string/action_decline" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/positive_button"
|
||||
style="@style/Widget.Vector.Button.Positive"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_accept" />
|
||||
tools:text="@string/action_accept" />
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user