0

I've built a chat app using Django Channels. To check messages I should click on the message icon (just like stackoverflow for example). I want to add the feature enabling to have these small red circles on the message icon indicating the number of messages not read and I don't even know what I should type on Google to look for this. Any suggestions ? Thanks!

Yassine
  • 189
  • 1
  • 1
  • 10
  • Please try to save each new message when send by sendor in the database (you can use increment operator to get sum of all new messages). Select the count messages when you open your chat application and display it. – Rinshan Kolayil Oct 29 '19 at 18:10
  • Please refer the below link to learn how to work with database whe new connection occurs, https://channels.readthedocs.io/en/latest/topics/databases.html#database-connections – Rinshan Kolayil Oct 29 '19 at 18:14
  • I already save new messages and I can do it manually as suggested. It's just that I was wondering if something else (easier?) was already out there x) Thanks for the link though! – Yassine Oct 29 '19 at 22:11
  • Thanks for your time. If two channels is active, you don't need to put the counts, it's only required if someone is not active so you need to save in database. And also you can add it in alternative way if users are active => add some javascript to increment the count in websocket.receive function for each new message. – Rinshan Kolayil Oct 30 '19 at 06:28
  • I'll try that! thank you :) – Yassine Oct 30 '19 at 08:15
  • 1
    I found what I was looking for here https://stackoverflow.com/questions/55534182/new-chat-message-notification-django-channels and here https://stackoverflow.com/questions/36111630/python-django-how-to-update-count-in-message-and-notification-badges-in-real-ti – Yassine Oct 30 '19 at 22:57
  • You most welcome. I know there is references but I just forget to add reference. Please try to search before you ask – Rinshan Kolayil Oct 31 '19 at 11:52
  • I searched before I asked and I didn't know what to type. It just happened that I came across the answer after I asked – Yassine Oct 31 '19 at 21:00

0 Answers0