Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live updates of edited and deleted messages #39

Closed
kasimi opened this issue Dec 20, 2015 · 4 comments
Closed

Live updates of edited and deleted messages #39

kasimi opened this issue Dec 20, 2015 · 4 comments

Comments

@kasimi
Copy link
Contributor

kasimi commented Dec 20, 2015

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.

The 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.

  • For detecting deleted messages, the server needs to know the user's first and last message IDs. I see two possible solutions.

    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.
    2. The server fetches only those IDs that are missing in the database. This would require a new query.

    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?

  • 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.

There 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. 😊

@kasimi kasimi changed the title Live editing and deleting of messages Live updates of edited and deleted messages Dec 20, 2015
@dmzx
Copy link
Owner

dmzx commented Dec 20, 2015

Think the what you mentioned is worth a shot. 😄

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?

Yes you are right after confirm the message must be deleted and removed from db.

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.

Column can be added for this, Also I need to check the database migration files so version upgrade will not affect db when update is done.

I can create private github section for this and we and develop / test it there, let me know about that.

Grtz

@dmzx
Copy link
Owner

dmzx commented Dec 21, 2015

Got all the migration in 1 file now.

@kasimi
Copy link
Contributor Author

kasimi commented Dec 22, 2015

I don't know what you mean by private section. How about you create a new branch for this feature?

However I suggest to wait with that because I'm currently changing a lot of the logic in the render_helper.php class so that it supports returning JSON instead of plain HTML. This will be needed so that the frequent checks for new messages can also return data about edited and deleted messages. It's already gotten more complex than I had thought. More soon.

@dmzx
Copy link
Owner

dmzx commented Dec 22, 2015

Close this one 😉

@dmzx dmzx closed this as completed Dec 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants