Skip to content

Decrease whitespace at end of message feed #1628

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 2 commits into from
Jul 8, 2025

Conversation

chrisbobbe
Copy link
Collaborator

This does two things:

Proposed by Tim in chat:

#mobile > space at end of thread @ 💬

I bet those two tweaks might fully address this issue.

Screenshots coming soon.

@chrisbobbe chrisbobbe added the launch feedback Things users specifically asked for upon launch label Jun 24, 2025
@chrisbobbe
Copy link
Collaborator Author

chrisbobbe commented Jun 24, 2025

Dark mode:

Current 11px to 0px 11px to 5px
image image image
image image image
image image image

@chrisbobbe
Copy link
Collaborator Author

chrisbobbe commented Jun 24, 2025

Light mode:

Before 11px to 0px 11px to 5px
image image image
image image image
image image image

@chrisbobbe chrisbobbe force-pushed the pr-space-at-end-of-feed branch from 15b7af9 to ae80e4f Compare July 7, 2025 19:14
@chrisbobbe
Copy link
Collaborator Author

Updated, this time decreasing the 11px to 5px instead of making it zero. I've kept the screenshots from the previous revision, though, and added ones from this revision. PTAL!

@alya
Copy link
Collaborator

alya commented Jul 7, 2025

5px seems like a fine adjustment to me.

@chrisbobbe chrisbobbe requested a review from gnprice July 7, 2025 22:38
@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Jul 7, 2025
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 for taking care of this! Comments below.

|| oneMessagePerBlock
|| !haveSameRecipient(prevMessage, message)
) {
if (prevMessage == null) {
items.add(MessageListRecipientHeaderItem(message));
canShareSender = false;
} else {
assert(items.last is MessageListMessageBaseItem);
Copy link
Member

Choose a reason for hiding this comment

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

msglist [nfc]: Pull out some asserts that also apply when haveSameRecipient

These invariants apply regardless of `haveSameRecipient`.

That also apply when not haveSameRecipient, right?

(The case where they were previously being asserted is one where haveSameRecipient is always true.)

Comment on lines 1549 to 1552
if (item.isLastInBlock && !item.isLastInFeed)
const SizedBox(height: 11)
else if (item.isLastInFeed)
const SizedBox(height: 5),
Copy link
Member

Choose a reason for hiding this comment

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

nit: can swap these cases to simplify one of the conditions


if (!messagesSameDay(prevMessageItem.message, message)) {
items.add(MessageListDateSeparatorItem(message));
prevMessageItem.isLastInFeed = false;
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather avoid making this _addItemsForMessage method more complicated if we can help it — it has a complicated job already as it is.

The question "is this the last item in the feed" seems like it can be answered easily within the MessageList widget, by looking at the index in the list. After all, the invariant says:

      ..isLastInFeed.equals(i == model.items.length);

(where i is the index after the item in question).

So instead how about:

  • MessageItem gains a boolean field isLastInFeed.
  • _buildItem gains a matching parameter.
  • Its two call sites compare itemIndex to totalItems to determine that parameter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, that's reasonable; I've done this in my new revision.

It puts a bit more of the work in widget code, which doesn't have tests for this new padding logic; would that be a blocker to merging?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, ideally there'd be a widget test or two for this. (I guess in particular one for the usual case, and one for the case where the bottom sliver is empty but the top is nonempty, checking effectively that that first _buildItem call site is doing the right thing.)

If that isn't quick to write, though, it's not a blocker for merging.

See discussion linked in the comment.
@chrisbobbe chrisbobbe force-pushed the pr-space-at-end-of-feed branch from ae80e4f to 9ee0db2 Compare July 7, 2025 23:55
@chrisbobbe
Copy link
Collaborator Author

Thanks! Revision pushed.

I've left in the two NFC commits because they seemed potentially helpful, but are now orthogonal to the interesting changes here:

359b99a msglist [nfc]: Make a common codepath for prevMessage != null
9c17fca msglist [nfc]: Pull out asserts that also apply at start of new block

Happy to remove or revise though if helpful.

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 for the revision! Just small comments.

Comment on lines 1196 to 1199
narrow: widget.narrow,
header: header,
item: data);
item: data,
isLastInFeed: isLastInFeed);
Copy link
Member

Choose a reason for hiding this comment

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

nit: metadata before payload / child-like argument (so here, isLastInFeed before header and item)


if (!messagesSameDay(prevMessageItem.message, message)) {
items.add(MessageListDateSeparatorItem(message));
prevMessageItem.isLastInFeed = false;
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, ideally there'd be a widget test or two for this. (I guess in particular one for the usual case, and one for the case where the bottom sliver is empty but the top is nonempty, checking effectively that that first _buildItem call site is doing the right thing.)

If that isn't quick to write, though, it's not a blocker for merging.

Comment on lines 456 to 464
final prevMessageItem = items.last as MessageListMessageBaseItem;
assert(identical(prevMessageItem.message, prevMessage));
assert(prevMessageItem.isLastInBlock);
prevMessageItem.isLastInBlock = false;
assert(prevMessageItem.isLastInBlock); // though this may mutate; see below

if (!messagesSameDay(prevMessageItem.message, message)) {
items.add(MessageListDateSeparatorItem(message));
if (oneMessagePerBlock || !haveSameRecipient(prevMessage, message)) {
items.add(MessageListRecipientHeaderItem(message));
canShareSender = false;
} else {
canShareSender = prevMessageItem.message.senderId == message.senderId;
prevMessageItem.isLastInBlock = false;
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think the refactors in the middle two commits are no longer helpful. The assertions are really there to support the prevMessageItem local, and then the last one is for checking the precondition of the assignment right after it:

      assert(prevMessageItem.isLastInBlock);
      prevMessageItem.isLastInBlock = false;

So separating them from that line, and from the uses of prevMessageItem in general, isn't an improvement.

@chrisbobbe chrisbobbe force-pushed the pr-space-at-end-of-feed branch from 9ee0db2 to 47ae5e3 Compare July 8, 2025 00:41
@chrisbobbe
Copy link
Collaborator Author

Thanks! Revision pushed.

@gnprice gnprice merged commit 47ae5e3 into zulip:main Jul 8, 2025
1 check passed
@gnprice
Copy link
Member

gnprice commented Jul 8, 2025

Thanks! Merged.

@chrisbobbe chrisbobbe deleted the pr-space-at-end-of-feed branch July 8, 2025 01:22
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 launch feedback Things users specifically asked for upon launch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants