Skip to content

Commit

Permalink
Don't try to mark as read a notification if it's already read
Browse files Browse the repository at this point in the history
  • Loading branch information
jonan committed Jun 3, 2016
1 parent 267fb9a commit 02a9d1b
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.List;

import okhttp3.ResponseBody;
import retrofit2.Response;

/**
* Fragment to display a list of {@link Notification} objects
Expand Down Expand Up @@ -99,15 +98,20 @@ public void onListItemClick(ListView l, View v, int position, long id) {
}

// Mark notification as read
new AuthenticatedUserTask<ResponseBody>(getActivity()) {

@Override
protected ResponseBody run(Account account) throws Exception {
Response<ResponseBody> r = service.markAsRead(notification.id).execute();
notification.is_unread = false;
return r.body();
}
}.execute();
if (notification.is_unread) {
new AuthenticatedUserTask<ResponseBody>(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
Expand Down

0 comments on commit 02a9d1b

Please sign in to comment.