-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: add custom dialog option #126
feat: add custom dialog option #126
Conversation
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.
Needs semicolons to match coding style.
I think I added all the missing semicolons, did I forget someone? |
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.
Some general feedback on the approach:
@ArthurLobopro have you considered instead exposing an API that allows users to hook in their own custom dialog code?
I wonder if a more generalized approach would be better than adding individual API options for the individual buttons.
@erickzhao I think the most people that want to change something on the dialog only wants to change the update message to something different (Like the Issue #116 ) or in another language (this is my case). Somehow, a way to do my own custom dialog can be interesting I think. How would you implements that? |
I think the possibility to localize the text is a reasonable feature, and should probably be supported without requiring users to re-implement the dialog all together. For customizing the dialog more deeply, though, we could look at providing a hook, say update-electron-app/src/index.ts Lines 186 to 202 in 0637390
Then to do localization the user would do: updateElectronApp({
...,
onNotifyUser: makeUserNotifier({
restartButtonText: 'Restart!!'
})
}) And if they wanted to more deeply customize the notify they have a hook to do whatever they'd like: updateElectronApp({
...,
onNotifyUser: (event, releaseNotes, releaseName, releaseDate, updateURL) => {
if (releaseName === 'AwesomeRelease') {
// Do fireworks
}
}
}) |
@dsanders11 great idea! @erickzhao what do you think about that? |
I realize if we provide the hook we will lose the logger context, because the logger is declared inside the update-electron-app/src/index.ts Lines 154 to 156 in 0637390
To solve it I think we can add a listener just to log it: autoUpdater.on(
'update-downloaded',
(event, releaseNotes, releaseName, releaseDate, updateURL) => {
log('update-downloaded', [event, releaseNotes, releaseName, releaseDate, updateURL]);
},
);
autoUpdater.on(
'update-downloaded',
(event, releaseNotes, releaseName, releaseDate, updateURL) => {
const { title, restartButtonText, laterButtonText, detail } = opts.dialog;
const dialogOpts = {
type: 'info',
buttons: [restartButtonText, laterButtonText],
title,
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail,
};
dialog.showMessageBox(dialogOpts).then(({ response }) => {
if (response === 0) autoUpdater.quitAndInstall();
});
},); |
I found another thing. When we create the dialog, we pick the dialog API from electron in the options update-electron-app/src/index.ts Line 124 in 0637390
update-electron-app/src/index.ts Line 132 in 0637390
But to create a separated function to create the notifier, maybe we will need to import directly from electron. |
It looks like this is just an undocumented option for testing purposes (I'm not familiar with this code base, but that's my take from a quick read), so it could similarly be an undocumented option on updateElectronApp({
...,
onNotifyUser: (info) => {
const { event, releaseNotes, releaseName, releaseDate, updateURL } = info;
// info.electron is an undocumented value for tests
if (releaseName === 'AwesomeRelease') {
// Do fireworks
}
}
}) |
I don't know why this error happens. The Electron namespace is already referenced here: update-electron-app/src/index.ts Line 207 in 1c9e970
|
Can someone test it on Windows or Macos? I am using Linux on my PC. |
Do we had any progress here? |
Any update here? I'm looking for some way to be able to show release notes in update dialog. |
@doctorXWrites Just waiting for approval, but maybe the reviewer forgot this PR because Github stops showing PRs with no activity after 2 weeks. I will mark he here to confirm this |
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.
I have a few things to change that I'm planning on pushing up. Sorry for the wait @ArthurLobopro!
@erickzhao No problem, I'm available to help if necessary |
Okay, all PRs have been merged, will write tests for my implementation changes and request reviews from other maintainers. |
Hey @ArthurLobopro, I just pushed up all changes and rebased against The biggest difference is that the default implementation for Do you mind giving this a spin to test it out? |
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.
Looking good!
🎉 This PR is included in version 3.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hello, how you merged the PR #105 I rewrite the PR #97 to avoid merge conflicts. I am unable to test the feature on windows or macos so if someone can test it I will be grateful :)
Closes #116