Save draft and close compose window

Skip to first unread message

Ahmad

unread,
Apr 13, 2018, 12:41:09 PM4/13/18
to InboxSDK
Hi all - we're migrating to InboxSDK in preparation for the new Gmail UI. As a side: many thanks for making InboxSDK available to us & the awesome support here.

Question: is there a way to:
1. Force save a draft when a button in the Compose window is clicked?
2. Close the Compose window once the save is successful?

Cheers,
Ahmad

Chris Cowan

unread,
Apr 13, 2018, 1:15:38 PM4/13/18
to InboxSDK
If you just close the draft, Gmail should continue saving it. Our composeView.close() method acts the same as the user clicking the X button on the window.

Ahmad

unread,
Apr 13, 2018, 1:21:00 PM4/13/18
to InboxSDK
That part is clear, however I need to guarantee that latest changes have been committed to the Drafts, since a remote background process will pick it up and process it. So essentially need a call back upon DraftSave.

Chris Cowan

unread,
Apr 13, 2018, 1:25:48 PM4/13/18
to InboxSDK
Oh that makes sense.
The promise returned by getDraftID() won't return before the draft is saved. (The draft ID is determined by the Gmail server, so we couldn't give it before it's saved on the server.)

Ahmad

unread,
Apr 13, 2018, 5:00:43 PM4/13/18
to InboxSDK
Experimented a bit. getDraftID does indeed return the draft id after it is saved for the *first time*, however there is still a risk that the remote background service would pickup the draft from Gmail's servers before the *last* draft changes complete.

A kludge solution would be to build a finger print/hash of the email payload on the client side, send it to the remote background service as part of the API call (along with draft id), and have it compare the hash with the content of the getDraftID message before processing. But it's quite a kludge.

Is there a way to ensure that the *last* draft changes were successful before handing things off to the remote background service? 

Thanks for taking the time on this.

Omar Ismail

unread,
Apr 13, 2018, 7:40:05 PM4/13/18
to ahmada...@gmail.com, InboxSDK
The compose won't emit its destroy event until the last draft save is complete. So use both getting the draftId and the composeView getting destroyed as signals that the draft is saved.

We have found in around 0.2% of cases that immediately hitting the backend Gmail API with that draft id can result in a 404 but it should appear there after a couple of seconds if you want to retry.

--
You received this message because you are subscribed to the Google Groups "InboxSDK" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inboxsdk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inboxsdk/18c33fd2-ecd6-49a2-817c-29fd0cbe1a36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ahmad

unread,
May 7, 2018, 8:39:31 AM5/7/18
to InboxSDK
Thanks Omar.

We can programatically close a Compose box `view.close()`, which will emit the destroy event (I assume that even when we do it programatically, it still will wait until last draft save is complete). But is there a way to do this for inline replies?

Omar Ismail

unread,
May 7, 2018, 1:42:43 PM5/7/18
to Ahmad AlNaimi, InboxSDK
There is no way to do this from inline replies

Reply all
Reply to author
Forward
0 new messages