{"action":"created","issue":{"url":"https://api.github.com/repos/dmzx/mChat-Extension/issues/39","labels_url":"https://api.github.com/repos/dmzx/mChat-Extension/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/dmzx/mChat-Extension/issues/39/comments","events_url":"https://api.github.com/repos/dmzx/mChat-Extension/issues/39/events","html_url":"https://github.com/dmzx/mChat-Extension/issues/39","id":123126972,"number":39,"title":"Live updates of edited and deleted messages","user":{"login":"kasimi","id":6710357,"avatar_url":"https://avatars.githubusercontent.com/u/6710357?v=3","gravatar_id":"","url":"https://api.github.com/users/kasimi","html_url":"https://github.com/kasimi","followers_url":"https://api.github.com/users/kasimi/followers","following_url":"https://api.github.com/users/kasimi/following{/other_user}","gists_url":"https://api.github.com/users/kasimi/gists{/gist_id}","starred_url":"https://api.github.com/users/kasimi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasimi/subscriptions","organizations_url":"https://api.github.com/users/kasimi/orgs","repos_url":"https://api.github.com/users/kasimi/repos","events_url":"https://api.github.com/users/kasimi/events{/privacy}","received_events_url":"https://api.github.com/users/kasimi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-20T02:10:58Z","updated_at":"2015-12-21T12:43:32Z","closed_at":null,"body":"You mentioned this already in another PR. When a user edits or deletes a message, other users need to refresh the page in order for their messages to reflect these changes. It would be nice if this could be updated live for the other users.\r\n\r\nThe problem is database performance. Every time mChat refreshes, messages that have a higher ID than the ID of the user's latest message are fetched. For fetching information about deleted and edited messages, two additional queries are necessary.\r\n\r\n* For detecting deleted messages, the server needs to know the user's first and last message IDs. I see two possible solutions.\r\n\r\n 1. In addition to new messages, all messages the user has are fetched again to find out which of them are missing. This could be added to the existing query.\r\n 2. The server fetches only those IDs that are missing in the database. This would require a new query.\r\n\r\n Note that I'm assuming that the existing logic of deleting messages isn't changed. Once a user deletes a message, it is removed from the database. One could design it in a way that deleting a message only sets a flag but retains the message in the database. I think this approach is unacceptable, as I'd expect a message to be irretrievably removed once the deletion is confirmed. What do you think?\r\n\r\n* For detecting edited messages, the database needs a new column `edit_time`. Every time mChat refreshes, it needs to send the `edit_time` of *every* message. The server can then fetch those messages that have a later edit time than the user sent. This could be added to the existing query.\r\n\r\nThere might be better solutions. I can go into more detail but first I was wondering if you have any comments or ideas yourself. The client-side coding is the smallest issue. :blush: "},"comment":{"url":"https://api.github.com/repos/dmzx/mChat-Extension/issues/comments/166296274","html_url":"https://github.com/dmzx/mChat-Extension/issues/39#issuecomment-166296274","issue_url":"https://api.github.com/repos/dmzx/mChat-Extension/issues/39","id":166296274,"user":{"login":"dmzx","id":6445099,"avatar_url":"https://avatars.githubusercontent.com/u/6445099?v=3","gravatar_id":"","url":"https://api.github.com/users/dmzx","html_url":"https://github.com/dmzx","followers_url":"https://api.github.com/users/dmzx/followers","following_url":"https://api.github.com/users/dmzx/following{/other_user}","gists_url":"https://api.github.com/users/dmzx/gists{/gist_id}","starred_url":"https://api.github.com/users/dmzx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmzx/subscriptions","organizations_url":"https://api.github.com/users/dmzx/orgs","repos_url":"https://api.github.com/users/dmzx/repos","events_url":"https://api.github.com/users/dmzx/events{/privacy}","received_events_url":"https://api.github.com/users/dmzx/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T12:43:32Z","updated_at":"2015-12-21T12:43:32Z","body":"Got all the migration in 1 file now."}}