Remove unused code

This commit is contained in:
ariskotsomitopoulos 2021-12-23 17:22:27 +02:00
parent f06397023a
commit 581f71e89d
3 changed files with 1 additions and 83 deletions

View file

@ -220,74 +220,8 @@ internal class DefaultRelationService @AssistedInject constructor(
return eventSenderProcessor.postEvent(event, cryptoSessionInfoProvider.isRoomEncrypted(roomId)) return eventSenderProcessor.postEvent(event, cryptoSessionInfoProvider.isRoomEncrypted(roomId))
} }
private fun decryptIfNeeded(event: Event, roomId: String) {
try {
// Event from sync does not have roomId, so add it to the event first
val result = cryptoService.decryptEvent(event.copy(roomId = roomId), "")
event.mxDecryptionResult = OlmDecryptionResult(
payload = result.clearEvent,
senderKey = result.senderCurve25519Key,
keysClaimed = result.claimedEd25519Key?.let { k -> mapOf("ed25519" to k) },
forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain
)
} catch (e: MXCryptoError) {
if (e is MXCryptoError.Base) {
event.mCryptoError = e.errorType
event.mCryptoErrorReason = e.technicalMessage.takeIf { it.isNotEmpty() } ?: e.detailedErrorDescription
}
}
}
override suspend fun fetchThreadTimeline(rootThreadEventId: String): List<Event> { override suspend fun fetchThreadTimeline(rootThreadEventId: String): List<Event> {
val results = fetchThreadTimelineTask.execute(FetchThreadTimelineTask.Params(roomId, rootThreadEventId)) return fetchThreadTimelineTask.execute(FetchThreadTimelineTask.Params(roomId, rootThreadEventId))
var counter = 0
//
// monarchy
// .awaitTransaction { realm ->
// val chunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomId)
//
// val optimizedThreadSummaryMap = hashMapOf<String, EventEntity>()
// for (event in results.reversed()) {
// if (event.eventId == null || event.senderId == null || event.type == null) {
// continue
// }
//
// // skip if event already exists
// if (EventEntity.where(realm, event.eventId).findFirst() != null) {
// counter++
// continue
// }
//
// if (event.isEncrypted()) {
// decryptIfNeeded(event, roomId)
// }
//
// val ageLocalTs = event.unsignedData?.age?.let { System.currentTimeMillis() - it }
// val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, EventInsertType.INCREMENTAL_SYNC)
// if (event.stateKey != null) {
// CurrentStateEventEntity.getOrCreate(realm, roomId, event.stateKey, event.type).apply {
// eventId = event.eventId
// root = eventEntity
// }
// }
// chunk?.addTimelineEvent(roomId, eventEntity, PaginationDirection.FORWARDS)
// eventEntity.rootThreadEventId?.let {
// // This is a thread event
// optimizedThreadSummaryMap[it] = eventEntity
// } ?: run {
// // This is a normal event or a root thread one
// optimizedThreadSummaryMap[eventEntity.eventId] = eventEntity
// }
// }
//
// optimizedThreadSummaryMap.updateThreadSummaryIfNeeded(
// roomId = roomId,
// realm = realm,
// currentUserId = userId)
// }
Timber.i("----> size: ${results.size} | skipped: $counter | threads: ${results.map{ it.eventId}}")
return results
} }
/** /**

View file

@ -177,7 +177,6 @@ internal class DefaultTimeline(
val threadTimelineEvents = TimelineEventEntity val threadTimelineEvents = TimelineEventEntity
.whereRoomId(realm, roomId = roomId) .whereRoomId(realm, roomId = roomId)
.equalTo(TimelineEventEntityFields.CHUNK.IS_LAST_FORWARD, true) .equalTo(TimelineEventEntityFields.CHUNK.IS_LAST_FORWARD, true)
// .`in`("${TimelineEventEntityFields.CHUNK.TIMELINE_EVENTS}.${TimelineEventEntityFields.EVENT_ID}", arrayOf(it))
.beginGroup() .beginGroup()
.equalTo(TimelineEventEntityFields.ROOT.ROOT_THREAD_EVENT_ID, it) .equalTo(TimelineEventEntityFields.ROOT.ROOT_THREAD_EVENT_ID, it)
.or() .or()
@ -192,8 +191,6 @@ internal class DefaultTimeline(
threadTimelineEvents threadTimelineEvents
} }
} ?: buildEventQuery(realm).sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.DESCENDING).findAll() } ?: buildEventQuery(realm).sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.DESCENDING).findAll()
if (isFromThreadTimeline)
Timber.i("----> timelineEvents.size: ${timelineEvents.size}")
timelineEvents.addChangeListener(eventsChangeListener) timelineEvents.addChangeListener(eventsChangeListener)
handleInitialLoad() handleInitialLoad()
@ -343,8 +340,6 @@ internal class DefaultTimeline(
val lastCacheEvent = results.lastOrNull() val lastCacheEvent = results.lastOrNull()
val firstCacheEvent = results.firstOrNull() val firstCacheEvent = results.firstOrNull()
val chunkEntity = getLiveChunk() val chunkEntity = getLiveChunk()
if (isFromThreadTimeline)
Timber.i("----> results.size: ${results.size} | contains root thread ${results.map { it.eventId }.contains(rootThreadEventId)}")
updateState(Timeline.Direction.FORWARDS) { state -> updateState(Timeline.Direction.FORWARDS) { state ->
state.copy( state.copy(

View file

@ -308,17 +308,6 @@ class RoomDetailViewModel @AssistedInject constructor(
} }
} }
// /**
// * Fetch all the thread replies for the current thread
// */
// private fun fetchThreadTimeline() {
// initialState.rootThreadEventId?.let {
// viewModelScope.launch(Dispatchers.IO) {
// room.fetchThreadTimeline(it)
// }
// }
// }
fun getOtherUserIds() = room.roomSummary()?.otherMemberIds fun getOtherUserIds() = room.roomSummary()?.otherMemberIds
fun getRoomSummary() = room.roomSummary() fun getRoomSummary() = room.roomSummary()