Skip to content

Commit

Permalink
Try to get event fastlane before sync on push
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Sep 16, 2021
1 parent 03a4e75 commit 6cd73da
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,29 +219,24 @@ val upHandler = object: MessagingReceiverHandler {
} else {
// Try to get the Event content faster
Timber.d("Requesting event in fast lane")
getEventFastLane(session, notification.roomId, notification.eventId)

Timber.d("Requesting background sync")
session.requireBackgroundSync()
if (!getEventFastLane(session, notification.roomId, notification.eventId)) {
Timber.d("Requesting background sync")
session.requireBackgroundSync()
}
}
}
} catch (e: Exception) {
Timber.e(e, "## onMessageReceivedInternal() failed")
}
}

private fun getEventFastLane(session: Session, roomId: String?, eventId: String?) {
roomId?.takeIf { it.isNotEmpty() } ?: return
eventId?.takeIf { it.isNotEmpty() } ?: return
private fun getEventFastLane(session: Session, roomId: String?, eventId: String?): Boolean {
roomId?.takeIf { it.isNotEmpty() } ?: return false
eventId?.takeIf { it.isNotEmpty() } ?: return false

// If the room is currently displayed, we will not show a notification, so no need to get the Event faster
if (notificationDrawerManager.shouldIgnoreMessageEventInRoom(roomId)) {
return
}

if (wifiDetector.isConnectedToWifi().not()) {
Timber.d("No WiFi network, do not get Event")
return
return true
}

coroutineScope.launch {
Expand All @@ -258,6 +253,7 @@ val upHandler = object: MessagingReceiverHandler {
notificationDrawerManager.refreshNotificationDrawer()
}
}
return true
}

// check if the event was not yet received
Expand Down

0 comments on commit 6cd73da

Please sign in to comment.