diff --git a/app/src/main/java/com/github/mobile/ui/notification/NotificationsListFragment.java b/app/src/main/java/com/github/mobile/ui/notification/NotificationsListFragment.java index 7ab4bbea..001e5507 100644 --- a/app/src/main/java/com/github/mobile/ui/notification/NotificationsListFragment.java +++ b/app/src/main/java/com/github/mobile/ui/notification/NotificationsListFragment.java @@ -36,7 +36,6 @@ import java.util.List; import okhttp3.ResponseBody; -import retrofit2.Response; /** * Fragment to display a list of {@link Notification} objects @@ -99,15 +98,20 @@ public void onListItemClick(ListView l, View v, int position, long id) { } // Mark notification as read - new AuthenticatedUserTask(getActivity()) { - - @Override - protected ResponseBody run(Account account) throws Exception { - Response r = service.markAsRead(notification.id).execute(); - notification.is_unread = false; - return r.body(); - } - }.execute(); + if (notification.is_unread) { + new AuthenticatedUserTask(getActivity()) { + + @Override + protected ResponseBody run(Account account) throws Exception { + return service.markAsRead(notification.id).execute().body(); + } + + @Override + protected void onSuccess(ResponseBody responseBody) throws Exception { + notification.is_unread = false; + } + }.execute(); + } } @Override