Skip to content

Edit-message (6/n): Misc. preparation for edit-message feature #1483

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

Merged
merged 3 commits into from
Apr 25, 2025

Conversation

chrisbobbe
Copy link
Collaborator

Here's another small batch of miscellaneous prep work for the edit-message feature, #126.

@chrisbobbe chrisbobbe added the maintainer review PR ready for review by Zulip maintainers label Apr 24, 2025
@chrisbobbe chrisbobbe requested a review from PIG208 April 24, 2025 02:36
Copy link
Member

@PIG208 PIG208 left a comment

Choose a reason for hiding this comment

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

Thanks! Left some small comments. This otherwise looks good to me.

@@ -562,7 +562,7 @@ void showMessageActionSheet({required BuildContext context, required Message mes
// So we rely on the fact that isComposeBoxOffered for any given message list
// will be constant through the page's life.
final messageListPage = MessageListPage.ancestorOf(pageContext);
final isComposeBoxOffered = messageListPage.composeBoxController != null;
final isComposeBoxOffered = messageListPage.composeBoxState?.controller != null;
Copy link
Member

Choose a reason for hiding this comment

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

Could this just be

Suggested change
final isComposeBoxOffered = messageListPage.composeBoxState?.controller != null;
final isComposeBoxOffered = messageListPage.composeBoxState != null;

As the dartdoc of composeBoxState states:

  /// The [ComposeBoxState] for this [MessageListPage]'s compose box,
  /// if this [MessageListPage] offers a compose box and it has mounted,
  /// else null.
  ComposeBoxState? get composeBoxState;

Checking composeBoxState?.controller != null seems a bit confusing use of the API to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, indeed.

final stream = eg.stream();
await setupMessageListPage(tester, narrow: ChannelNarrow(stream.streamId),
streams: [stream],
messages: [eg.streamMessage(stream: stream, content: "<p>a message</p>")]);
final state = MessageListPage.ancestorOf(tester.element(find.text("a message")));
check(state.composeBoxController).isNotNull();
check(state.composeBoxState?.controller).isNotNull();
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the earlier comment on a null-check, I feel that checking if composeBoxState?.controller is null will make more sense if the controller is nullable. The updated contract seems to be: as long as composeBoxState is present, there is a compose box and vice versa.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah; I think what happened is I did something like a copy-paste and didn't make this refinement from there :)

@@ -906,7 +858,7 @@ class CopyMessageTextButton extends MessageActionSheetMenuItemButton {

Copy link
Member

Choose a reason for hiding this comment

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

nit: perhaps update the reference here?

  @override void onPressed() async {
    // This action doesn't show request progress.
    // But hopefully it won't take long at all; and
    // fetchRawContentWithFeedback has a TODO for giving feedback if it does.

@chrisbobbe
Copy link
Collaborator Author

Thanks for the review! Revision pushed.

@PIG208 PIG208 added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Apr 25, 2025
@PIG208 PIG208 requested a review from gnprice April 25, 2025 01:06
@PIG208
Copy link
Member

PIG208 commented Apr 25, 2025

The updates LGTM. Thanks! Marking for Greg's review.

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 both! All looks good except a comment on the last commit.

Comment on lines 305 to 308
return InheritedMessage(message: message,
child: DefaultTextStyle(
style: ContentTheme.of(context).textStylePlainParagraph,
child: switch (content) {
ZulipContent() => BlockContentList(nodes: content.nodes),
PollContent() => PollWidget(messageId: message.id, poll: content.poll),
}));
child: child));
Copy link
Member

Choose a reason for hiding this comment

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

This part might become clearer in the upcoming PR that will use this change. But I'm not sure that here in MessageContent is the right place to implement this behavior:

content [nfc]: Pull out `child` variable in MessageContent.build

For the edit-message feature, the Figma fades message content during
the loading state:
  https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4026-8563&m=dev
This refactor prepares for that.

It feels like it might more naturally live in the parent widget.

(Which could do it just as well, right? I imagine the fading doesn't interact with the DefaultTextStyle or the InheritedMessage.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed; yeah, I'll drop this commit.

Soon we'll want a method for starting a message-edit session, and
it'll make sense to put it on ComposeBoxState rather than
ComposeBoxController; one reason is that it'll need UI code to show
an error dialog.

With this change, the ComposeBoxState -- and so that new method --
will be accessible in the message-list widget code, where we open
the message action sheet from.
@chrisbobbe
Copy link
Collaborator Author

Thanks! Revision pushed.

@gnprice gnprice merged commit 2739149 into zulip:main Apr 25, 2025
1 check passed
@chrisbobbe chrisbobbe deleted the pr-edit-message-6 branch April 25, 2025 22:05
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.

3 participants