-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add discard option #42
Conversation
Thanks for the contribution! Before we can merge this, we need @NickChokas to sign the Salesforce Inc. Contributor License Agreement. |
👋 @NickChokas Thanks so much for this contribution and for this great addition. Would you mind signing the CLA agreement? You should see it linked above on this page. |
👋 srajiang - Absolutely! I think it should be good actually: |
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 is super slick! And the code looks great! Left a few comments with some thoughts, but I think all of it can be ignored without problem. Giving an approval now and can merge soon, but will wait a bit for adjustments if you want to make those.
Thanks a ton for sending this in! ❤️
// If the user selects to discard the draft message | ||
if (action.selected_option.value == "discard_message_overflow") { |
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.
IMO it makes sense to break both the edit_message_overflow
and discard_message_overflow
into separate functions since, once the action.selected_option.value
is decided, these branches end with exit or error.
It'd make openDraftEditView
act more as a handler which might make parsing a bit easier, but perhaps not... This is personal preference for sure, so your call on this change!
// Delete the draft from the 'drafts' Datstore | ||
const deleteResp = await client.apps.datastore.delete({ | ||
datastore: DraftDatastore.name, | ||
id: id, | ||
}); |
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.
Without getting too deep in thought, I might opt to delete from the datastore before deleting the message in case something goes wrong with the datastore. In either case an error from either of these gets us into a weird state, so I don't think this has to be changed, but would rather the datastore act as a source of drafting truths if possible!
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.
Ahh yeah that makes sense to me. I'll move the Delete Datastore operation before the Slack Message Deletion 👌
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.
Thanks for the update! Realizing now that moving the datastore check first might also let us return
from the function early and avoid deleting the chat message after an error 😳
I'm thinking a try
/ catch
wrapping this function could be interesting, then throwing errors instead of returning early 🤔 But an early return
works well too!
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.
All awesome changes, thank you! 👏 This is looking great and about ready to merge but some small things popped out after those changes for me.
Left a few comments around handling more error cases that I think are worth considering, mostly around guarding against strange function behavior and all. Once that seems alright, I believe this'll be a sure way to delete drafts 💪
// Delete the draft from the 'drafts' Datstore | ||
const deleteResp = await client.apps.datastore.delete({ | ||
datastore: DraftDatastore.name, | ||
id: id, | ||
}); |
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.
Thanks for the update! Realizing now that moving the datastore check first might also let us return
from the function early and avoid deleting the chat message after an error 😳
I'm thinking a try
/ catch
wrapping this function could be interesting, then throwing errors instead of returning early 🤔 But an early return
works well too!
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.
Thank you for adding the try
/ catch
! This is getting so close to the ideal control flow IMO ✨ Left one more comment around a throw
for earlier returns, but all else looks great!
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.
Awesome! Appreciate all of these updates so much, this is a super nice enhancement to add 👏
Tested this and it all works as expected and feels nice! Error handling all looks good too so I think it's time to merge 🚀
Thanks again! This was fun! |
Type of change (place an x in the [ ] that applies)
Summary
The goal of this PR is to add a "Discard" option to the Draft Message overflow menu, giving the user the option to quickly Delete the Draft if it's not needed. The added logic in
create_draft/interactivity_handler.ts
will Delete the message from the Draft Slack Channel and also delete the respective record from thedrafts.ts
Datastore.Requirements (place an x in each [ ] that applies)