mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-23 14:17:15 +00:00
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:
parent
1d2906af29
commit
dd51b95f53
1 changed files with 17 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue