Skip to content

Internal links ignore /near/MSGID pointing to specific messages #3604

Open
@gnprice

Description

@gnprice

@rishig reports:

The following link is sending me to the end of the narrow on mobile, i.e. it seems to be ignoring the /near/779699 part:
https://chat.zulip.org/#narrow/stream/14-GSoC/topic/Zulip.20swag/near/779699

This is a kind of followup to #2760 -- just a few weeks ago we made such links work at all, going to the right narrow, but the near part which should point to a specific message isn't working.

Looking in the code, a link in the message list is handled here:

export const messageLinkPress = (href: string) => (dispatch: Dispatch, getState: GetState) => {
  // ...
  const narrow = getNarrowFromLink(href, auth.realm, usersById, streamsById);
  if (narrow) {
    const anchor = getMessageIdFromLink(href, auth.realm);
    dispatch(doNarrow(narrow, anchor));
    return;

But then the only thing that doNarrow does with its anchor parameter is to make sure to fetch messages around that desired anchor:

export const doNarrow = (narrow: Narrow, anchor: number = FIRST_UNREAD_ANCHOR) => (
  // ...
  dispatch({ type: DO_NARROW, narrow });
  dispatch(fetchMessagesInNarrow(narrow, anchor));
  dispatch(navigateToChat(narrow));
};

It doesn't actually do anything to try to place our scroll position there.

Looking through the history, it seems like in fact this code may never have worked. Certainly as far back as commit fcff285 a bit over two years ago, when messageLinkPress itself was created in a small refactoring, the anchor parameter has been computed and then mostly ignored; in fact at that point, it was completely ignored, not even used for trying to fetch the right messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1 high-prioritya-message listwebapp parityFeatures that exist in the webapp that we need to port to mobile. We aren't aiming for full parity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions