Skip to content

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

Closed
wants to merge 2 commits into from
Closed

Conversation

kaustubh-nair
Copy link
Member

@kaustubh-nair kaustubh-nair commented Aug 12, 2020

This PR adds support for a minimal draft message feature, storing a single
draft message when meta s is pressed.

@zulipbot zulipbot added the size: M [Automatic label added by zulipbot] label Aug 12, 2020
@kaustubh-nair kaustubh-nair added the PR needs review PR requires feedback to proceed label Aug 12, 2020
Copy link
Collaborator

@neiljp neiljp left a 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?

@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Aug 13, 2020
@zulipbot zulipbot added size: L [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Aug 13, 2020
@kaustubh-nair kaustubh-nair force-pushed the drafts_v1 branch 2 times, most recently from f172d25 to 67266a8 Compare August 13, 2020 17:43
@kaustubh-nair kaustubh-nair added the PR needs review PR requires feedback to proceed label Aug 13, 2020
@neiljp
Copy link
Collaborator

neiljp commented Aug 13, 2020

@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.

@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Aug 13, 2020
@neiljp neiljp added this to the Next Release milestone Aug 16, 2020
@kaustubh-nair kaustubh-nair force-pushed the drafts_v1 branch 3 times, most recently from 8b5f166 to ac9e187 Compare August 22, 2020 18:51
@kaustubh-nair kaustubh-nair added the PR needs review PR requires feedback to proceed label Aug 22, 2020
Copy link
Collaborator

@neiljp neiljp left a 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)
Copy link
Collaborator

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?

Copy link
Member Author

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?

Copy link
Collaborator

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.

Copy link
Member Author

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 🤔

Copy link
Collaborator

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.

@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Aug 23, 2020
This commit removes the return statement since it is not being used
anywhere. Updated the type of callback function passed in
PopUpConfirmationView appropriately.
@kaustubh-nair kaustubh-nair force-pushed the drafts_v1 branch 2 times, most recently from 99698ae to ce55965 Compare August 23, 2020 16:37
@kaustubh-nair
Copy link
Member Author

@neiljp Thanks for the review, PR updated!

Copy link
Collaborator

@neiljp neiljp left a 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.

Comment on lines 26 to 30
('OPEN_DRAFT', {
'keys': {'d'},
'help_text': 'Open draft message saved in this session',
'key_category': 'general',
}),
Copy link
Collaborator

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)
Copy link
Collaborator

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.

@neiljp neiljp removed the PR needs review PR requires feedback to proceed label Aug 24, 2020
@kaustubh-nair kaustubh-nair force-pushed the drafts_v1 branch 2 times, most recently from 074a36e to 4e144e5 Compare August 24, 2020 09:03
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.
@kaustubh-nair
Copy link
Member Author

@neiljp Thanks for the review, PR updated.

@neiljp
Copy link
Collaborator

neiljp commented Aug 27, 2020

@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 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback wanted size: L [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants