Repository navigation
feat: add signal option to dialog.showMessageBox - #26102
Conversation
|
I don't love this ID system. Perhaps we could use something like AbortSignal? https://w3ctag.github.io/design-principles/#aborting |
I did not know it exists, it is a better design than a custom ID system. So I think the new API would look like this? const controller = new AbortController();
dialog.showMessageBox(win, {
signal: controller.signal,
message: 'message',
})
controller.abort();There are 2 downsides though:
So I think maybe we can invent our own const controller = new dialog.MessageBoxAbortController()
dialog.showMessageBox(win, {
signal: controller.signal,
message: 'message',
})
controller.abort();
// future extensions.
controller.close({button: 1}) |
|
I'm not convinced we need the option to "pretend" that a particular button was pressed. User code can handle that plumbing by itself if needed, e.g. const controller = new AbortController()
let abortedSignal = null
dialog.showMessageBox(win, {
signal: controller.signal,
message: 'message'
}).then(status => {
if (status == null)
status = abortedSignal
})
abortedSignal = 1
controller.abort();as for Node adding its own, it seems like they are planning to match the DOM implementation (similar to their implementation of |
|
I'm going to wait for the next major upgrade of Node in Electron, adding typescript declarations for our own |
97d0eff to
1e3e800
Compare
a088707 to
c1fd58a
Compare
|
I have updated this PR to use |
|
Release Notes Persisted
|
|
I was unable to backport this PR to "14-x-y" cleanly; |
|
@MarshallOfSound The |
* mac: add dialog.closeMessageBox API * win: Implement dialog.closeMessageBox * mac: Return cancelId with closeMessageBox * gtk: Implement dialog.closeMessageBox * win: Fix 32bit build * win: Reduce the scope of lock * fix: Build error after rebase * feat: Use AbortSignal to close message box * chore: silently handle duplicate ID * win: Add more notes about the threads * chore: apply reviews * fix: base::NoDestructor should be warpped in function * chore: fix style on windows
* mac: add dialog.closeMessageBox API * win: Implement dialog.closeMessageBox * mac: Return cancelId with closeMessageBox * gtk: Implement dialog.closeMessageBox * win: Fix 32bit build * win: Reduce the scope of lock * fix: Build error after rebase * feat: Use AbortSignal to close message box * chore: silently handle duplicate ID * win: Add more notes about the threads * chore: apply reviews * fix: base::NoDestructor should be warpped in function * chore: fix style on windows
Description of Change
This PR adds a
signaloption to close message box, once this API is approved, I'll implement same API to close file dialogs. Refs #5577.Duplicate code
There are some duplicate code when checking dialog IDs, which I would like to refactor after adding the API for closing file dialogs. Optimizing them in this PR is too early.
Checklist
npm testpassesRelease Notes
Notes: Add
signaloption todialog.showMessageBox.