Skip to content
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

Seamless-Updates - added flow for automatic updates for releases #10857

Merged
merged 6 commits into from
Aug 17, 2024

Conversation

AliceHincu
Copy link
Contributor

This PR contains:

  • The logic of triggering both auto updates and the update notification.
    • Since the update won't be automatically downloaded, the notification won't pop up yet. I set on purpose enableAutoDownload = false. This will be set to true in another PR. I will check how VsCode handles downloads (whether it automatically downloads them or after the user agrees to update).
    • The second reason for this is that I would like to test in another PR the updating flow, and I would like to test in these next two PRs if the versions are correctly identified and if the latest.yml files are correctly generated.
  • Finally managed to use internal logger and shim for different features (setInterval, logging etc).
  • Used an existing feature flag for checking if prereleases should be considered when the user wants to be notified about an update.
  • Deleted "writeUpdateInfo" in package.json because I want to generate "latest-mac.yml".

The reason why I gave the variable the name "initializedShim": inside the logic of fetching prereleases (which will be in the next PR), I can't use the boolean functions that check the platform type (ex: isWindows()), but I can use setInterval() and setTimeout() functions. If I also import it in the file under a different name, I can access the platform check functions, but not the setInterval and setTimeout functions. I'll try to see why this happens in the next PR.

Also, even if all the review changes are implemented, please do not merge this until I fully test on platforms different from Windows.

@AliceHincu AliceHincu changed the title Seamless-Updates - added flow for automatically updates for releases Seamless-Updates - added flow for automatical updates for releases Aug 11, 2024
@AliceHincu AliceHincu changed the title Seamless-Updates - added flow for automatical updates for releases Seamless-Updates - added flow for automatic updates for releases Aug 11, 2024
@@ -462,6 +474,14 @@ export default class ElectronAppWrapper {
this.customProtocolHandler_ ??= handleCustomProtocols(logger);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public initializeAutoUpdaterService(logger: LoggerWrapper, initializedShim: any, devMode: boolean, allowPrereleaseUpdates: boolean) {
if (!shim.isLinux()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here please only list the platforms that are supported, which would be isMacOS and isWindows. Joplin works also on BeOS and maybe others, so it's better to explicitly list what we support instead what we don't support

@@ -462,6 +474,14 @@ export default class ElectronAppWrapper {
this.customProtocolHandler_ ??= handleCustomProtocols(logger);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public initializeAutoUpdaterService(logger: LoggerWrapper, initializedShim: any, devMode: boolean, allowPrereleaseUpdates: boolean) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing, but could you please use the same name as the setting variable for the prerelease boolean. So includePreReleases

public constructor() {
private enableDevMode = true; // force the updater to work in "dev" mode
private enableAutoDownload = false; // automatically download an update when it is found
private allowPrerelease_ = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well - includePreReleases. Unless there's a good reason we should try to use consistent naming everywhere, it makes it easier to search for code afterwards

Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few comments.

Thank you for working on this!

packages/app-desktop/ElectronAppWrapper.ts Outdated Show resolved Hide resolved
Comment on lines 569 to 584
// Note: Auto-update is a misnomer in the code.
// The code below only checks, if a new version is available.
// We only allow Windows and macOS users to automatically check for updates
if (shim.isWindows() || shim.isMac()) {
const runAutoUpdateCheck = () => {
if (Setting.value('autoUpdateEnabled')) {
void checkForUpdates(true, bridge().window(), { includePreReleases: Setting.value('autoUpdate.includePreReleases') });
}
};

// Initial check on startup
shim.setTimeout(() => { runAutoUpdateCheck(); }, 5000);
// Then every x hours
shim.setInterval(() => { runAutoUpdateCheck(); }, 12 * 60 * 60 * 1000);
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have still the same problem - we actually want to keep this code, and it should be enabled by default. The new AutoUpdaterService should be disabled by default.

What I meant with the feature flag is that you should create a new setting, for example featureFlag.autoUpdaterServiceEnabled, which defaults to false. And you use this to enabled/disable the old code and disable/enable the new code.

Have a look in Setting.ts - there are some examples of commented out feature flags (they start with featureFlag.). Create a similar setting value and use it here.

We need this for safety - because if there's any issue with your change, a lot of people won't be notified any more when a new version is available. So by default everybody use the old method, and the user can explicitly enable the new method (like I will do for example)

@laurent22 laurent22 merged commit 7216301 into laurent22:dev Aug 17, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants