Bug fix bailey notification not dismissed (#1655)

* added resources to run project

* fixed bug of bailey notification not being dismissed

* added examples files back
This commit is contained in:
pauliancu97 2021-10-18 18:42:51 +03:00 committed by GitHub
parent 1d2906af29
commit dd51b95f53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,7 +61,7 @@ open class NotificationsViewModel : BaseViewModel() {
var notifications = convertInvitationsToNotifications(it)
if (it.flags?.newStuff == true) {
val notification = Notification()
notification.id = "new-stuff-notification"
notification.id = "custom-new-stuff-notification"
notification.type = Notification.Type.NEW_STUFF.type
val data = NewStuffData()
notification.data = data
@ -179,11 +179,19 @@ open class NotificationsViewModel : BaseViewModel() {
* instead of one of the ones coming from server.
*/
private fun isCustomNotification(notification: Notification): Boolean {
return notification.id.startsWith("custom-") || notification.id == "new-stuff-notification"
return notification.id.startsWith("custom-")
}
private fun isCustomNewStuffNotification(notification: Notification) =
notification.id == "custom-new-stuff-notification"
fun dismissNotification(notification: Notification) {
if (isCustomNotification(notification)) {
if (isCustomNewStuffNotification(notification)) {
customNotifications.onNext(
customNotifications.value?.filterNot { it.id == notification.id }
)
}
return
}
@ -199,6 +207,13 @@ open class NotificationsViewModel : BaseViewModel() {
.filter { !actionableNotificationTypes.contains(it.type) }
.map { it.id }
val customNewStuffNotification = notifications
.firstOrNull { isCustomNewStuffNotification(it) }
if (customNewStuffNotification != null) {
dismissNotification(customNewStuffNotification)
}
if (dismissableIds.isEmpty()) {
return
}