I have an apl with chat using python and websockets. If user successfully authenticate his/her status in the database turns online. Database query collects the online status users every minutes and send a message to front end where I want to update the list from the websocket message. everything works fine until I log in with another account from a different browser. The first window keep appending the names not matter which browser I refresh this is happening only with the first opened browser window/tab. Any ideas how to collect data and append to front end with vanilla js and keep the data until its changes in the database so the new authenticated user append to list and every online members show up in the sidebar properly. Like the messenger sidebar. If you could please help. I appreciate
8/7/2020 5:34:54 PM_] | [\]
4 AnswersNew Answer
Why not refresh the whole local userlist array so it is always in sync with the backend userlist array? P. S. I downvoted your question to discourage you from self-upvoting.
You'll need to set a timer, say every 3 minutes or so, performs check on the activity of the users, and kicks the idle ones.
thanks! currently have 190 users in database and only around 20 online at the same time JS appends the list same with the whole array so the sidebar grows quickly 😂
the trick was to make query to online status users from database save them in a list with variable like _last_online and after 1minute it creates a new variable _current_online and compare them to a set() do it always eleminating the duplicates it is not the best but working on the development server