-
Notifications
You must be signed in to change notification settings - Fork 509
Delete messages from store for deleted conversation #4949
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
Delete messages from store for deleted conversation #4949
Conversation
When a conversation is deleted through an action, also delete the matching messages for consistency. This also prevents the corresponding vues to try to access the deleted conversation. Signed-off-by: Vincent Petry <[email protected]>
Merge deleteConversation that takes a conversation object with deleteConversationByToken since only the token is needed anyway. Signed-off-by: Vincent Petry <[email protected]>
|
For reference, this is where the app sidebar deletes the conversation from store upon leaving: https://github.com/nextcloud/spreed/blob/bugfix/4572/clear-messages-when-conversation-delete/src/FilesSidebarTabApp.vue#L219 The issue was that the CallView + MessagesList were still rendered, so they were trying to render old messages that were not cleared which referred to the deleted conversation: https://github.com/nextcloud/spreed/blob/bugfix/4572/clear-messages-when-conversation-delete/src/components/MessagesList/MessagesGroup/Message/Message.vue#L282. The fix prevents those message vues to be rendered in the first place and brings back the loading placeholder in that case. |
purgeConversation is done every 30 seconds, so don't do it there |
That sounds rather hacky and like it could break as it could have been unintended. Wouldn't it be better to call a new action from this action instead? |
It isn't hacky if it's part of the framework. It might be the reason why dispatch uses a string a action name instead of calling the function directly to allow for this. However, I failed to find any article about this feature, nor best practices, so I really wonder why it's there and why nobody is using it... So for the sake of readability I'll make the conversation store action call the message list store action to make it more explicit. |
|
Code adjusted and retested |
|
I still get |
|
damn, seems I had a cached state when I retested. I'm now getting something different than what you see |
|
regarding multiple action handlers with same name, so far I found a mention in https://hackernoon.com/correct-and-efficient-way-to-use-vuex-part-i-wf15432eu
and here by the Vue author himself, he calls these "Composable Action Flow" (see section 3): vuejs/vuex#236 |
While the former worked, it might confuse people as they might not be aware that the dispatcher is calling action functions on multiple store. This makes the deletion of messages an explicit action. Signed-off-by: Vincent Petry <[email protected]>
91dab4c to
dd12078
Compare
|
I've squashed the fix into the last commit. It turns out I only renamed deleteConversation to deleteMessages in the mutation but forgot to do the same in the action. |
|
@nickvergessen can you retest ? Not sure about the error you saw, didn't see it last time |
nickvergessen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I start to dislike the delete* method name as with real message deletion that is easy to mix up. should make clear its only removing from the store and not from DB, but same with conversation and others. so its okay for now
Yep. Went through the same dislike while working on this. |
Fixes #4572
When a conversation is deleted through an action, also delete the matching messages for consistency.
This also prevents the corresponding vues to try to access the deleted conversation.
Note: the proposed code works by defining an action in messagesStore with the same name as the one in the conversationsStore. The dispatching of actions will trigger on all the stores, which then makes this magic happen :-)
I noticed also that "purgeConversations" is also not clearing the messagesStore but decided against adding it here, as it might have side effects. I'll raise a tech debt ticket later to discuss this unrelated bit.