Reputation: 31
I am trying to implement a Facebook Notification style Notification option for an application . I use Server Sent options to fetch the notifications from the database table which counts the number of rows from the notofications table and displays that every time . with proper sessions I update the notification counter each time the user opens the notification box. But the thing is that whenever I log out for the user and logs in then the notification number becomes the same as the number of rows in the table.
Eg I had 20 unread notifications from the table. When I open it then it becomes 0 pending notifications. But after I log out and log in it becomes 20 again.
I thought of storing the last notification value in database to solve it and call that value when user logs in but I there any other efficient method ????
Upvotes: 1
Views: 70
Reputation: 1182
You could be adding an additional "readed/new" value to notifications, so you could filter out from the table. This would be resource consuming and probably not the most efficient way to do it.
I would filter from the "last login" if you have it in the user table (notifications should have already the timestamp saved somewhere) so you know that notifications from the last login time till current time aren't readed.
Upvotes: 1