-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Support (un)resolving topics #1544
base: main
Are you sure you want to change the base?
Conversation
6e7c245
to
fb82ade
Compare
The function calls get_latest_message_in_topic to fetch recent message in topic to be (un)resolved. It verifies user and editing conditions using can_user_edit_topic function and finally add or remove RESOLVED_TOPIC_PREFIX from topic name. Fixes zulip#1075. Co-authored-by: Shivam Deotarse <[email protected]>
Tests added. Co-authored-by: Shivam Deotarse <[email protected]>
Co-authored-by: Shivam Deotarse <[email protected]>
Co-authored-by: Shivam Deotarse <[email protected]>
Co-authored-by: Shivam Deotarse <[email protected]>
Fixes zulip#1075. Co-authored-by: Shivam Deotarse <[email protected]>
fb82ade
to
a570d28
Compare
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.
@rsashank Thanks for the followup 👍
I may have had a few more thoughts, but wanted to get these comments to you before I go to bed :)
Re co-authoring, please note that
- Shivam's email doesn't appear to match his original commits
- some commits look entirely to be his with no additions; can you cherry-pick those from the original PR instead to indicate that?
if self.can_user_edit_topic(): | ||
latest_msg = self.get_latest_message_in_topic(stream_id, topic_name) | ||
if latest_msg: | ||
time_since_msg_sent = time.time() - latest_msg["timestamp"] | ||
# ZFL < 11, community_topic_editing_limit_seconds | ||
# was hardcoded as int value in secs eg. 86400s (1 day) or None | ||
if 11 <= self.server_feature_level < 162: |
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.
To reduce the level of nesting here, consider the matching else blocks for these early conditionals - they're basically error conditions (and we're not handling them, right now!)
In these cases, exiting early after performing those checks means the rest of the function knows it's in a good state and can continue. In terms of indenting, the current indented sections can then become an 'else' but at a non-indented level. (The absence of error handling then becomes fairly obvious too!)
# ZFL >= 162, realm_move_messages_within_stream_limit_seconds was | ||
# introduced in place of realm_community_topic_editing_limit_seconds | ||
elif self.server_feature_level >= 162: | ||
edit_time_limit = self.initial_data.get( | ||
"realm_move_messages_within_stream_limit_seconds", None | ||
) | ||
else: |
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.
This is the new section, and the matching new test case, compared to the previous PR?
initial_data[ | ||
"realm_community_topic_editing_limit_seconds" | ||
] = topic_editing_limit_seconds | ||
initial_data[ | ||
"realm_move_messages_within_stream_limit_seconds" | ||
] = move_messages_within_stream_limit_seconds |
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.
Strictly this doesn't cover the ZFL 183+ (Zulip 7) situation, where the first of these parameters was removed?
We could treat the two parameters as a patch to initial data via a dict, but unfortunately that then leaves assumptions as to whether the two values are in initial_data
, ie. for later versions we strictly want to remove the field.
# ZFL < 11, community_topic_editing_limit_seconds | ||
# was hardcoded as int value in secs eg. 86400s (1 day) or None |
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.
This comment seems a little out of position relative to the code? I'd consider reordering the conditional to start with the new maximum, and leave the <11 case to the end with this comment?
model.get_latest_message_in_topic = mocker.Mock( | ||
return_value={ | ||
"subject": topic_name, | ||
"timestamp": timestamp, |
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.
This suggests the timestamp
in the test should be a latest_message_timestamp
, to make the field clearer?
The subject/topic is for the entire topic already, so that's clear enough.
) | ||
|
||
if self.topic_name.startswith(RESOLVED_TOPIC_PREFIX): | ||
self.resolve_topic_setting_btn_lbl = "Unresolve Topic" |
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 know this was from the previous PR, but let's use button_label in the expanded form.
def test_toggle_resolve_status(self) -> None: | ||
resolve_button = self.topic_info_view.widgets[-1] | ||
resolve_button._emit("click") | ||
|
||
self.controller.model.toggle_topic_resolve_status.assert_called_once_with( | ||
stream_id=self.stream_id, topic_name=self.topic | ||
) | ||
|
||
self.controller.exit_popup.assert_called_once() |
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.
It looks like you added this extra test, and the one above this?
I'm not sure about using _emit
here, at least compared to our normal use of keypress
, but that should be fine - what inspired _emit
?
@@ -312,6 +312,11 @@ class KeyBinding(TypedDict): | |||
'help_text': 'Show/hide stream information & modify settings', | |||
'key_category': 'stream_list', | |||
}, | |||
'TOPIC_INFO': { | |||
'keys': ['i'], | |||
'help_text': 'Show/hide topic information & modify settings', |
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.
This is only useful for this feature right now, so perhaps we should update this slightly to mention updating the resolve status.
@@ -467,6 +472,7 @@ class KeyBinding(TypedDict): | |||
"msg_actions": "Message actions", | |||
"stream_list": "Stream list actions", | |||
"user_list": "User list actions", | |||
"topic_actions": "Topic actions", |
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.
Topic list actions?
) | ||
|
||
self.widgets.append(resolve_topic_setting) | ||
super().__init__(controller, self.widgets, "TOPIC_INFO", popup_width, title) |
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.
This TOPIC_INFO has no meaning here yet. Not sure of the ordering; let's leave it for now.
What does this PR do, and why?
This PR adds support for (un)resolving topics in ZT via TopicInfoView popup menu when topic is highlighted in left_stream_bar and i key is pressed to toggle topic settings.
Changes with respect to completion candidate PR:
Added support beyond ZFL 183:
Before Zulip 7.0 (feature level 183), the realm_community_topic_editing_limit_seconds property was returned by the response. It was removed because it had not been in use since the realm setting move_messages_within_stream_limit_seconds was introduced in feature level 162.
Changes to tests
Dropped the first commit
External discussion & connections
Support (un)resolving topics #T1235 (fix #T1075)
How did you test this?
Self-review checklist for each commit
Visual changes