From d862d89b3032e4372b3837e394c5ab20251adebc Mon Sep 17 00:00:00 2001 From: yassine04e Date: Thu, 19 Dec 2024 23:52:20 +0100 Subject: [PATCH] fix: Putting the load in the onSuccess call of the sendNotification --- .../travelpouch/ui/notifications/NotificationItem.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/se/travelpouch/ui/notifications/NotificationItem.kt b/app/src/main/java/com/github/se/travelpouch/ui/notifications/NotificationItem.kt index 1df4504a..ac12f1da 100644 --- a/app/src/main/java/com/github/se/travelpouch/ui/notifications/NotificationItem.kt +++ b/app/src/main/java/com/github/se/travelpouch/ui/notifications/NotificationItem.kt @@ -252,6 +252,9 @@ fun handleInvitationResponse( notificationViewModel.sendNotificationToUser( notification.senderUid, responseNotification) + + notificationViewModel.loadNotificationsForUser( + profileViewModel.profile.value.fsUid) }, onFailure = { Toast.makeText(context, it.message, Toast.LENGTH_SHORT).show() @@ -269,13 +272,14 @@ fun handleInvitationResponse( Toast.makeText(context, responseMessage, Toast.LENGTH_SHORT).show() notificationViewModel.sendNotificationToUser( notification.senderUid, responseNotification) + notificationViewModel.loadNotificationsForUser( + profileViewModel.profile.value.fsUid) }, onFailure = { Toast.makeText(context, it.message, Toast.LENGTH_SHORT).show() chosen() }) } - notificationViewModel.loadNotificationsForUser(profileViewModel.profile.value.fsUid) }, onFailure = { Toast.makeText(context, "Failed to get travel", Toast.LENGTH_SHORT).show() @@ -305,6 +309,9 @@ fun handleInvitationResponse( onSuccess = { notificationViewModel.sendNotificationToUser( notification.senderUid, firendNotification) + + notificationViewModel.loadNotificationsForUser( + profileViewModel.profile.value.fsUid) }, onFailure = { Toast.makeText(context, it.message, Toast.LENGTH_LONG).show() }) Toast.makeText(context, "Friend added", Toast.LENGTH_LONG).show() @@ -334,6 +341,8 @@ fun handleInvitationResponse( notification.senderUid, firendNotification) Toast.makeText(context, "Request declined", Toast.LENGTH_LONG).show() + + notificationViewModel.loadNotificationsForUser(profileViewModel.profile.value.fsUid) }, onFailure = { chosen()