3

I noticed that when I get activities from a notification feed using mark_read=[<id>] the response seems incorrect: response.unread shows the correct counter (that is, it has decreased by 1), but the object for <id> in response.results has is_read=false.

Is this a bug or expected behaviour? and if this is expected, what's the best way to handle this on my side so I don't display it as being unread?

aiguofer
  • 1,887
  • 20
  • 34

1 Answers1

0

This is expected behavior. When reading a feed with mark_read or mark_seen, the APIs return the seen/read of activities before they get updated by the request.

This is mainly to support the common case of retrieving a feed and marking all activities as seen (but still be able to tell which ones are seen for the first time). In your case, since you are marking activities as seen by providing the ID, you should be able to update the UI accordingly.

Tommaso Barbugli
  • 11,781
  • 2
  • 42
  • 41
  • ahh ok interesting... I find it a little odd that a client would 'mark_read' or 'mark_seen' before actually seeing/reading it (that is, when fetching the feed for the first time). We're marking them as the activity happens and using the response to re-populate the UI, but we can just manually change `is_read` from the UI as you pointed out. – aiguofer Jan 28 '16 at 22:58
  • @aiguofer that's how you support this very common flow: "open" the notification feed, mark all activities as seen and highlight the ones that the user sees for the first time (eg. Facebook notification feed) – Tommaso Barbugli Jan 29 '16 at 10:51
  • @aiguofer but of course, if you do the request just to mark specific activities as seen or read you don't even care about what the APIs returns ;) – Tommaso Barbugli Jan 29 '16 at 10:51
  • @tomasso-barbugli well, we're doing the 'facebook notification' model, where we mark as seen when they click on the icon and mark as read when they click on the actual notification. However, we're just polling notifications once per minute, so we update the feed with the response when an activity (read/seen) happens. Since new notifications could have come in since the last time we polled, we use the new response to repopulate the UI. – aiguofer Jan 29 '16 at 19:56