-
-
Couldn't load subscription status.
- Fork 677
Mostly handle topic edits / stream moves #5259
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
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
de76082
api types: Move update_message event into a proper event type
gnprice c3f0e70
example data: Add mkActionEventUpdateMessage
gnprice 442f182
event [nfc]: Keep update_message event verbatim on action, don't spread
gnprice 6263a98
api [nfc]: Factor out messageMoved to look at update_message events
gnprice 8d6c1a3
event [nfc]: Compute messageMoved early on update_message
gnprice e65e973
event: Sort message_ids in update_message events
gnprice 055f45d
message: Stop maintaining edit history we never show
gnprice 527e563
api: Update Message type on topic_links; stop maintaining subject_links
gnprice 4622dd0
message [nfc]: Take whole per-account state in reducer
gnprice b8469d9
message: Handle update_message making stream/topic changes
gnprice 7fe4ba5
ChatScreen [nfc]: Simplify reasoning about scheduled-fetch effect
gnprice 9d543c3
ChatScreen [nfc]: Factor out small callback scheduleFetch
gnprice bc81c42
reactUtils: Add useEdgeTriggeredEffect
gnprice 6582764
ChatScreen: Schedule fetch if list suddenly empty
gnprice 245ebf4
message: Handle update_message in narrows/caughtUp, simply
gnprice 1a45db2
nav: Update ChatScreen narrow on topic move
gnprice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * Functions to interpret some data from the API. | ||
| * | ||
| * @flow strict-local | ||
| */ | ||
| import invariant from 'invariant'; | ||
|
|
||
| import type { UpdateMessageEvent } from './eventTypes'; | ||
| import * as logging from '../utils/logging'; | ||
|
|
||
| export type MessageMove = $ReadOnly<{| | ||
| orig_stream_id: number, | ||
| new_stream_id: number, | ||
| orig_topic: string, | ||
| new_topic: string, | ||
| |}>; | ||
|
|
||
| /** | ||
| * Determine if and where this edit moved the message. | ||
| * | ||
| * If a move did occur, returns the relevant information in a form with a | ||
| * consistent naming convention. | ||
| * | ||
| * Returns null if the message stayed at the same conversation. | ||
| */ | ||
| export function messageMoved(event: UpdateMessageEvent): null | MessageMove { | ||
| // The API uses "new" for the stream IDs and "orig" for the topics. | ||
| // Put them both in a consistent naming convention. | ||
| const orig_stream_id = event.stream_id; | ||
| if (orig_stream_id == null) { | ||
| // Not stream messages, or else a pure content edit (no stream/topic change.) | ||
| // TODO(server-5.0): Simplify comment: since FL 112 this means it's | ||
| // just not a stream message. | ||
| return null; | ||
| } | ||
| const new_stream_id = event.new_stream_id ?? orig_stream_id; | ||
| const orig_topic = event.orig_subject; | ||
| const new_topic = event.subject ?? orig_topic; | ||
|
|
||
| if (new_topic === orig_topic && new_stream_id === orig_stream_id) { | ||
| // Stream and topic didn't change. | ||
| return null; | ||
| } | ||
|
|
||
| if (orig_topic == null) { | ||
| // `orig_subject` is documented to be present when either the | ||
| // stream or topic changed. | ||
| logging.warn('Got update_message event with stream/topic change and no orig_subject'); | ||
| return null; | ||
| } | ||
| invariant(new_topic != null, 'new_topic must be non-nullish when orig_topic is, by `??`'); | ||
|
|
||
| return { orig_stream_id, new_stream_id, orig_topic, new_topic }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
EventTypesis an unused import at this commit