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

Handle edit message events triggering change in mention flags and unreads. #1068

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

zee-bit
Copy link
Member

@zee-bit zee-bit commented Jul 5, 2021

The commit structure is as follows:

  • helper/model: Copy unread mentioned messages from initial_data to Index.: Creates a new field in index as unread_mentioned_msg_ids which stores the message ids of unread mentioned messages obtained from the initial_data.

  • bugfix: api_types/model: Update mention flags on message edit events.: This commit updates the index, unread_count and flags if the message was indexed when an update message event with change in mention flag(s) is detected. If the message was not in index, we just update the unread_count. The count is updated after checking with initial data's unread mentioned msgs field which does not stay synced with the server, hence the logic is buggy.

  • model: Update index's "unread_mentioned_msg_ids" field from events.: This commit updates the index.unread_mentioned_msg_ids field through update_message and update_message_flag events.

  • tests: model: Extend other tests to incorporate both mentioned flags.: This commit expands some of the fixtures of present tests with the mentioned/wildcard_mentioned flags to make the tests more robust and generalized.

@zee-bit zee-bit force-pushed the edit-event-mentions-unreads branch 2 times, most recently from 553148c to b61a63c Compare July 9, 2021 22:53
@zee-bit zee-bit added area: event handling How events from the server are responded to bug Something isn't working PR needs review PR requires feedback to proceed labels Jul 9, 2021
@zee-bit zee-bit force-pushed the edit-event-mentions-unreads branch from b61a63c to 7b853d5 Compare July 19, 2021 13:43
@zulipbot zulipbot added the size: XL [Automatic label added by zulipbot] label Jul 19, 2021
@zee-bit zee-bit force-pushed the edit-event-mentions-unreads branch 2 times, most recently from c089fe2 to 14a97bc Compare July 19, 2021 20:04
This commit adds "unread_mentioned_msg_ids" field in model.index that
copies and stores the message ids of unread mentioned messages obtained
from the initial_data into this field. This field is currently not in
sync with the server, but we only copy this data to index so that we are
able to properly update it through events afterwards.

Tests amended.
This commit rearranges the parameters of test__handle_update_message_event
function such that all the expected_* variables are at the last and the
order of parameters in fixture matches that of the function to maintain
consistency with our general test functions.
This commit adds "flags" field in UpdateMessageEvent api_type, now
that we are planning to handle flag changes in update_message_events.

In particular, users can add/remove several flags such as mentioned/
wildcard_mentioned/has_alert_words from sent messages, and when they
do, it triggers an update_message_event to the rest of the users,
alongwith change in flags if there are any.
This commit updates the index, unread_count and flags if the message was
indexed when an update_message event with change in mentioned flag(s) is
detected. This currently doesn't handle updates when the event is for a
non-indexed message.

Changes in mentioned narrow after this event are not rendered at the same
time but it updates the index so that a return to the mentioned messages
narrow will do so.

Tests amended.
This commit handles updating message flag for un-indexed messages on edit
message events. If the message is not in index, we just need to update the
unread_count. The count is updated after checking with initial data's
unread mentioned msgs field which does not stay synced with the server,
hence the logic is currently buggy.
@zee-bit zee-bit force-pushed the edit-event-mentions-unreads branch from 14a97bc to e81fe1f Compare August 18, 2021 15:51
This commit updates the index.unread_mentioned_msg_ids field through
update_message and update_message_flag events.

The update_message event is responsible for adding/removing mentions from
messages and we need to handle updating the above field appropriately.
The update_message_flag event on the other hand can add the "read" flag
to messages, so updating this field for these types of events also needs
to be handled properly.

Tests amended.
This commit expands some of the fixtures of present tests with the
mentioned/wildcard_mentioned flags to make the tests more robust
and generalized.
@zulipbot
Copy link
Member

Heads up @zee-bit, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/main branch and resolve your pull request's merge conflicts accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: event handling How events from the server are responded to bug Something isn't working has conflicts PR needs review PR requires feedback to proceed size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants