feat: promisify dialog.showSaveDialog() (#17054)

* feat: promisify dialog.showSaveDialog()

* address some feedback from review

* filename => filePath

* fix last filename => filePath
This commit is contained in:
Shelley Vohr 2019-03-05 13:48:20 -08:00 committed by GitHub
parent 92c9dbc179
commit 6cb7b8d3a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 166 additions and 135 deletions

View file

@ -56,8 +56,16 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
}
void ShowSaveDialog(const file_dialog::DialogSettings& settings) {
auto callback = base::Bind(&FileSelectHelper::OnSaveDialogDone, this);
file_dialog::ShowSaveDialog(settings, callback);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
atom::util::Promise promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
file_dialog::ShowSaveDialog(settings, std::move(promise));
ignore_result(handle->Then(
context,
v8::Local<v8::Function>::Cast(mate::ConvertToV8(
isolate, base::Bind(&FileSelectHelper::OnSaveDialogDone, this)))));
}
private: