-
-
Notifications
You must be signed in to change notification settings - Fork 278
Single message drafts #772
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
Conversation
7da16d3
to
7db0d39
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.
@kaustubh-nair While this is limited to one draft and one session (ie. isn't saved), this promises to be useful in terms of keeping one message 'available' while browsing around others 👍
There is the overlap commit with #746 to consider, but this seems fairly straightforward given the limited scope (not saving during/between sessions or on crashing, no server interaction)
There is currently the minor 'surprise' of a second draft overwriting another with no notice, ie. one just containing one letter (or a space) will overwrite the previous. Perhaps have a yes/no popup to check with the user?
7db0d39
to
dd648e5
Compare
f172d25
to
67266a8
Compare
@kaustubh-nair I just pushed the first commit as c7026b3 with a reworded general commit text. I'm marking this as not needing review after our discussion on czo, but let me know if you want more details or discussion. This should allow @preetmishra to implement #708 more simply too. |
8b5f166
to
ac9e187
Compare
ac9e187
to
5f9d138
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.
@kaustubh-nair This looks good 👍 See my comments on czo re commit text and key choice - these comments are more code-related after reading in more detail.
@@ -285,6 +286,10 @@ def react_to_message(self, | |||
response = self.client.add_reaction(reaction_to_toggle_spec) | |||
display_error_if_present(response, self.controller) | |||
|
|||
def save_draft(self, message: Message) -> None: | |||
self.draft = message | |||
self.controller.view.set_footer_text("Saved message as draft", 3) |
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.
Should this line go in the core popup method?
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.
@neiljp You mean in PopUpConfirmationView
?
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.
In the function that is called when 'yes' is selected.
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.
model.save_draft()
is the method that is called when 'yes' is selected? I'm confused 🤔
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.
save_draft
is the method that's called currently, but I was wondering if we should call the set_footer_text
from the popup too. We already have a lot of ui-coupled code in the model, which I'd like to move away from, but let's discuss and that can be something we do later.
This commit removes the return statement since it is not being used anywhere. Updated the type of callback function passed in PopUpConfirmationView appropriately.
99698ae
to
ce55965
Compare
@neiljp Thanks for the review, PR updated! |
ce55965
to
72a1c46
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.
@kaustubh-nair The changes from czo look OK 👍 However, there are a number of aspects that seem to have been missed from the last review and there are a few other points that I think we need to address before merging.
zulipterminal/config/keys.py
Outdated
('OPEN_DRAFT', { | ||
'keys': {'d'}, | ||
'help_text': 'Open draft message saved in this session', | ||
'key_category': 'general', | ||
}), |
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.
I'd suggest we want this below the about menu entry?
@@ -285,6 +286,10 @@ def react_to_message(self, | |||
response = self.client.add_reaction(reaction_to_toggle_spec) | |||
display_error_if_present(response, self.controller) | |||
|
|||
def save_draft(self, message: Message) -> None: | |||
self.draft = message | |||
self.controller.view.set_footer_text("Saved message as draft", 3) |
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.
In the function that is called when 'yes' is selected.
074a36e
to
4e144e5
Compare
This adds support for a minimal draft message feature, storing a single draft message. The draft is stored for each session, and server-side storage will be added later when the API endpoints are available. It functions as follows: * On pressing SAVE_AS_DRAFT(`meta s`), a popup is shown confirming whether the message should be saved as a draft. This is not permitted when a message is being edited, or the current message is the same as a saved draft. The pop-up is bypassed when there is no saved draft. * The saved draft can be opened for editing by using the OPEN_DRAFT(`d`) key.
4e144e5
to
22d2e5b
Compare
@neiljp Thanks for the review, PR updated. |
@kaustubh-nair This will be useful, thanks for working on this! 👍 I just merged this with a slight adjustment to the README to match the order of the hotkeys in the help menu 🎉 |
This PR adds support for a minimal draft message feature, storing a single
draft message when
meta s
is pressed.