-
-
Notifications
You must be signed in to change notification settings - Fork 663
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
edit message : allow cancellation of edit #3823
Conversation
@gnprice @ray-kraesig please review. |
e194bbb
to
42a5734
Compare
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.
(The commit summary and message also need to be updated to refer to #2757. It does fix that bug, as the videos show.)
src/nav/navActions.js
Outdated
export const navigateBack = () => (dispatch: Dispatch, getState: GetState): NavigationAction => | ||
dispatch(StackActions.pop({ n: getSameRoutesCount(getState()) })); | ||
export const navigateBack = () => (dispatch: Dispatch, getState: GetState): NavigationAction => { | ||
dispatch(cancelEditMessage()); |
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.
This will call cancelEditMessage
on every attempted back navigation, not just the ones where it's relevant. That's a huge hack. Calling this function should be limited to when the user is actually in the edit-message state.
Also, preferably, hitting back in that context should exit the "edit message" state, but not the current narrow.
(#2757 is pretty bad misbehavior, so I wouldn't be completely unwilling to accept such a hack, but it would need to be very well-documented – at the very least, a) here, b) at cancelEditMessage
itself, and c) at any existing reducers for this dispatch
. However, it's easy to check the relevant condition even from here, so that's a moot point.
Checking it here is still a hack that needs documenting, and one I expect we'll have issues with when we upgrade react-navigation; but that's going to require rethinking a number of things anyway.)
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.
Fixed!
42a5734
to
4dc5b15
Compare
4dc5b15
to
bd20239
Compare
As noted previously, both the code and the commit need documentation: the former in comments, the latter in the commit summary. |
bd20239
to
cfd223a
Compare
@ray-kraesig have made the requested changes. Please review, thanks. |
It is not possible to cancel editing a message. Fix that to allow message edit cancellation on back navigation attempt. Fixes zulip#2757.
cfd223a
to
97e6e46
Compare
/** | ||
* If a message is currently being edited, cancel the edit. Otherwise, | ||
* navigate back. | ||
*/ |
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.
The code change below is very much a hack.
Its associated comment should thus start with HACK:
, or some similar marker of grave concern, and then continue with what the right thing to do is (or is believed to be) and why this has been done here instead of that there. Similarly, some documentation of this hack's existence should be present in ComposeBox, ActionSheet, and/or some other component responsible for the edit message state.
(Also, this is function-documentation-style comment formatting [0] [1] [2], rather than ordinary comment formatting.)
@ray-kraesig, When you mentioned
I looked at other locations where we could dispatch I think that the change can be instead made in the following places, to check if an edit is in progress, and cancel it, instead of navigating back:
So, should I revert changes in If not, I can not think of an answer to |
This would be strictly worse. Instead of one component that shouldn't know anything about editing checking our editing state, we'd have two disconnected components that shouldn't know anything about editing checking our editing state. The right thing to do will be some form of making editing affect our navigation state (which is designed to allow other components to affect it), rather than making navigation affect our editing state (which should be entirely local to the editing components). However...
... in retrospect, this is not something that should be asked of a new contributor. Unfortunately, it's the most important part of a patch like this. Closing. (I'll try to ensure this PR is referenced if we end up with a temporary fix similar to this.) |
Fixes #2757
Before:
Now: