Skip to content

messages reducer: Sketch a plan for keeping Message.edit_history current#5422

Merged
chrisbobbe merged 5 commits intozulip:mainfrom
chrisbobbe:pr-prep-maintain-edit-history
Jun 26, 2022
Merged

messages reducer: Sketch a plan for keeping Message.edit_history current#5422
chrisbobbe merged 5 commits intozulip:mainfrom
chrisbobbe:pr-prep-maintain-edit-history

Conversation

@chrisbobbe
Copy link
Copy Markdown
Contributor

For the plan, see the jsdoc and multi-part TODO added to Message['edit_history'] in the second commit.

Maintaining an up-to-date Message['edit_history'] is on the path to #5306.

@chrisbobbe chrisbobbe added P1 high-priority server release goal Things we should try to coordinate with a major Zulip Server release. labels Jun 22, 2022
@chrisbobbe chrisbobbe requested a review from gnprice June 22, 2022 20:22
Copy link
Copy Markdown
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 @chrisbobbe! This looks good. Small comments below, then please merge at will.

Comment thread src/api/eventTypes.js Outdated
Comment on lines 307 to 309
// TODO(server-5.0): Always present as of FL 114; make required.
user_id?: UserId | null,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// TODO(server-5.0): Always present as of FL 114; make required.
user_id?: UserId | null,
// Before FL 114, can be absent with the same meaning as null.
// TODO(server-5.0): Make required.
user_id?: UserId | null,

I.e., include the information of how to interpret the old format.

Copy link
Copy Markdown
Contributor Author

@chrisbobbe chrisbobbe Jun 26, 2022

Choose a reason for hiding this comment

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

Good thought, thanks.

user_id: integer | null

The ID of the user who sent the message.

Null when event is for a rendering update of the original message, such as for an inline URL preview.

Changes: As of Zulip 5.0 (feature level 114), this field is present for all update_message events. Previously, this field was omitted for inline URL preview updates.

Hmm. Read literally, the meaning isn't exactly the same: in the old format, "missing" is for inline URL preview updates; in the new format, null is for any "rendering update," which includes but isn't limited to inline URL preview updates.

In main, I think it's probably true that "URL preview update" is the only kind of "rendering update" we have. And I'm pretty sure that's true of pre-FL 114 servers.

So I guess there isn't anything I would change from your suggestion, but I wanted to point it out.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right. The old version of the API didn't have any explicit coherent concept here; when revising it, "rendering update" was the concept we came up with to explain why it made sense for the events that had been missing this field to be missing it.

Comment thread src/api/eventTypes.js Outdated
Comment on lines +310 to +312
// TODO(server-5.0): New in FL 114.
rendering_only?: boolean,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// TODO(server-5.0): New in FL 114.
rendering_only?: boolean,
// TODO(server-5.0): New in FL 114. On old servers, infer from `user_id`.
rendering_only?: boolean,

Comment thread src/api/modelTypes.js Outdated
Comment on lines +771 to +779
// - Handle changes to the allow-edit-history setting:
// - When allow-edit-history is turned off, set all messages'
// edit_history to `null`. (Otherwise we'd be keeping around
// edit_history data that admins would rather we didn't have…and also,
// that data would get irrecoverably stale as messages get updated.)
// - When allow-edit-history is turned on…probably just leave
// edit_history `null` on messages we know about, don't force `null`
// on new or newly fetched messages, and expect a re-/register
// soon?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As we discussed in yesterday's call, let's simplify this:

We'll plan to treat an allow-edit-history change similar to a restart event (in particular, a restart event where the server version changed, which could mean any number of subtle changes in server behavior), and do a re-fetch of server data soon after it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can add it to the list in

Done.

Comment thread src/api/modelTypes.js Outdated
Comment on lines +755 to +756
* Null if it's coming from a server with FL <118; see comment on
* MessageEdit.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: "null" is a keyword, so keep it case-sensitive:

Suggested change
* Null if it's coming from a server with FL <118; see comment on
* MessageEdit.
* This is null if it's coming from a server with FL <118; see comment on
* MessageEdit.

…r void

We decided to go with `null` for the pre-118 case instead of
undefined/missing. Update a comment to say that, and update a type
cast to not say that servers might send `null`, since they won't.
(That type cast, and another like it, still isn't correct; we'll fix
another issue soon.)
…mments

Looking at the doc again (https://zulip.com/api/get-messages), we
missed some cases where we should expect servers not to include
this:

- message has no edit history
- viewing edit history not allowed

So, reflect that in the type. And add a jsdoc that mentions that,
and some TODOs for how to make this property useful.
@chrisbobbe chrisbobbe force-pushed the pr-prep-maintain-edit-history branch from c8204df to fbe1a05 Compare June 26, 2022 21:44
@chrisbobbe chrisbobbe merged commit fbe1a05 into zulip:main Jun 26, 2022
@chrisbobbe
Copy link
Copy Markdown
Contributor Author

Small comments below, then please merge at will.

Thanks for the review! Merged, with those fixes.

@chrisbobbe chrisbobbe deleted the pr-prep-maintain-edit-history branch June 26, 2022 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 high-priority server release goal Things we should try to coordinate with a major Zulip Server release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants