-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ignore push for a thread if it's currently visible to user #7641
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Push notification for thread message is now shown correctly when user observes rooms main timeline |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ class NotificationDrawerManager @Inject constructor( | |
private val notificationState by lazy { createInitialNotificationState() } | ||
private val avatarSize = context.resources.getDimensionPixelSize(R.dimen.profile_avatar_size) | ||
private var currentRoomId: String? = null | ||
private var currentThreadId: String? = null | ||
private val firstThrottler = FirstThrottler(200) | ||
|
||
private var useCompleteNotificationFormat = vectorPreferences.useCompleteNotificationFormat() | ||
|
@@ -123,6 +124,22 @@ class NotificationDrawerManager @Inject constructor( | |
} | ||
} | ||
|
||
/** | ||
* Should be called when the application is currently opened and showing timeline for the given threadId. | ||
* Used to ignore events related to that thread (no need to display notification) and clean any existing notification on this room. | ||
*/ | ||
fun setCurrentThread(threadId: String?) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe merge with the method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. user can switch between different threads in the same rooms, so i think it's better to separate changing room and changing thread There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
updateEvents { | ||
val hasChanged = threadId != currentThreadId | ||
currentThreadId = threadId | ||
currentRoomId?.let { roomId -> | ||
if (hasChanged && threadId != null) { | ||
it.clearMessagesForThread(roomId, threadId) | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun notificationStyleChanged() { | ||
updateEvents { | ||
val newSettings = vectorPreferences.useCompleteNotificationFormat() | ||
|
@@ -164,7 +181,7 @@ class NotificationDrawerManager @Inject constructor( | |
private fun refreshNotificationDrawerBg() { | ||
Timber.v("refreshNotificationDrawerBg()") | ||
val eventsToRender = notificationState.updateQueuedEvents(this) { queuedEvents, renderedEvents -> | ||
notifiableEventProcessor.process(queuedEvents.rawEvents(), currentRoomId, renderedEvents).also { | ||
notifiableEventProcessor.process(queuedEvents.rawEvents(), currentRoomId, currentThreadId, renderedEvents).also { | ||
queuedEvents.clearAndAdd(it.onlyKeptEvents()) | ||
} | ||
} | ||
|
@@ -198,8 +215,8 @@ class NotificationDrawerManager @Inject constructor( | |
notificationRenderer.render(session.myUserId, myUserDisplayName, myUserAvatarUrl, useCompleteNotificationFormat, eventsToRender) | ||
} | ||
|
||
fun shouldIgnoreMessageEventInRoom(roomId: String?): Boolean { | ||
return currentRoomId != null && roomId == currentRoomId | ||
fun shouldIgnoreMessageEventInRoom(resolvedEvent: NotifiableMessageEvent): Boolean { | ||
return resolvedEvent.shouldIgnoreMessageEventInRoom(currentRoomId, currentThreadId) | ||
} | ||
|
||
companion object { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we do not have the threadId in the
pushData
, true?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't :(