Skip to content

Update state.narrows on topic/stream edits #2688

@jainkuniya

Description

@jainkuniya

(new description written 2021-07 by @gnprice)

When a message gets edited, we reflect the edit in state.messages, but not in other data structures that know about the message. In particular state.unread (that's #4840), and state.narrows.

This means that if a message has its topic and/or stream change, then if you've already seen that message in a message list (so that we have an entry in state.narrows for that narrow), it will still be in the old narrow if you go and look there.

Conversely, if you've already looked at the new narrow where it should appear, so that we've fetched from that narrow covering the point where the message would appear, I believe this means the message won't show up there. (But if you first visit the narrow only after the edit happened, then it will, because we fetch the relevant messages from the server.)

A particularly salient way for this to show up is if you're looking at a topic narrow, and edit a message's topic yourself. You're looking right at it in that narrow, and it won't disappear. (This was reported as #4830.)

The way we'll fix this is to add a case for EVENT_UPDATE_MESSAGE in narrowsReducer.js. It should be sure to

  • handle stream edits as well as topic edits (see also Support moving messages between streams #3957);
  • handle whole-stream narrows as well as topic narrows;
  • add to the new narrows, if applicable, as well as remove from the old.
    • For the nuances of "applicable", see jsdoc on NarrowsState and CaughtUpState, and the existing logic that narrowsReducer.js has for the EVENT_NEW_MESSAGE case.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions