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

Mark as resolved/unresolved prep 1 #1242

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

Conversation

chrisbobbe
Copy link
Collaborator

My local branch for #744 has gotten pretty long and I think it'll benefit from being split into multiple PRs. 🙂 Here's one.

(String, int, bool, int) is pretty hard to make sense of.
Instead of passing its fields separately. (We'd like to start using
lastUnreadId from the data too.)
This will make it available in a long-press handler in the app bar
for a topic narrow. That long-press handler brings up the topic
action sheet, which will need a message ID to pass in the API
request for resolve/unresolve topic. (Not sure the API request
should really *need* a message ID, but it requires it; shrug.)
We put it here in lib/api/route/messages.dart, next to another
constant that's about topics, kMaxTopicLength.
Since it has a `propagate_mode` param that means the same as
PropagateMode in an update-message event -- this is after all the
update-message request binding -- move that enum's definition here,
from lib/api/model, and adjust imports.
@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Dec 30, 2024
@chrisbobbe chrisbobbe requested a review from gnprice December 30, 2024 21:49
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Good idea.

Comments below from an initial review.

Comment on lines +166 to +169
String stripResolvePrefixIfPresent(String topic) =>
topic.startsWith(kResolvedTopicPrefix)
? topic.substring(kResolvedTopicPrefix.length)
: topic;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this end up getting used later in your branch?

Its behavior differs from unresolve_name in the shared code:
https://github.com/zulip/zulip/blob/1fac99733/web/shared/src/resolved_topic.ts#L22-L29

which I'm guessing (haven't checked) is what gets applied when the user unresolves a topic in web or the legacy mobile app.

Comment on lines +69 to +73
/// When built from server data, the action sheet ignores changes in that data;
/// we intentionally don't live-update the buttons on events.
/// If a button's label, action, or position changes suddenly,
/// it can be confusing and make the on-tap behavior unexpected.
/// Better to let the user decide to tap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah.

Looking for PerAccountStoreWidget.of calls in this file, I think there's one place we don't currently follow this: the hasSelfVote in ReactionButtons.

That one shouldn't cause this problem in practice, though, because it changes by the user's own action. (Or by the message getting deleted, but then it doesn't matter whether the user tries to add a reaction or remove one.)

Comment on lines +73 to +76
/// Better to let the user decide to tap
/// based on information that's comfortably in their working memory,
/// even if we sometimes have to explain (where we handle the tap)
/// that that information has changed and they need to decide again.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A key point here is that these races are always possible anyway — the change may have happened on the server but not reached us yet.

@@ -1,5 +1,6 @@
import 'package:json_annotation/json_annotation.dart';

import '../route/messages.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't like having lib/api/model/ import from lib/api/route/. If it's needed for the model, that feels like a sign it's part of the model and not part of how particular routes interact with the model.

I think these can just stay in this file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(When this file gets to feel unwieldy, I think the thing to do is to split pieces out by subject area: like a lib/ap/model/message.dart, akin to the narrow.dart and submessage.dart and so on that we already have.)

Comment on lines -769 to -771
/// As in [UpdateMessageEvent.propagateMode].
@JsonEnum(fieldRename: FieldRename.snake)
enum PropagateMode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this can move from lib/api/model/events.dart to lib/api/model/model.dart, since it's no longer specific to an event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants