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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Seamless-Updates - added feature flag for enabling AutoUpdaterService
  • Loading branch information
AliceHincu committed Aug 15, 2024
commit 7862d92843bea087a34b6bfa306c0b9a0824734b
7 changes: 7 additions & 0 deletions packages/app-desktop/ElectronAppWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export default class ElectronAppWrapper {
}

public quit() {
this.stopLookingForUpdates();
this.electronApp_.quit();
}

Expand Down Expand Up @@ -474,6 +475,12 @@ export default class ElectronAppWrapper {
}
}

public stopLookingForUpdates() {
if (this.updaterService_ !== null) {
this.updaterService_.stopPeriodicUpdateCheck();
}
}

public getCustomProtocolHandler() {
return this.customProtocolHandler_;
}
Expand Down
33 changes: 27 additions & 6 deletions packages/app-desktop/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const globalCommands = appCommands.concat(libCommands);
import editorCommandDeclarations from './gui/NoteEditor/editorCommandDeclarations';
import PerFolderSortOrderService from './services/sortOrder/PerFolderSortOrderService';
import ShareService from '@joplin/lib/services/share/ShareService';
import checkForUpdates from './checkForUpdates';
import { AppState } from './app.reducer';
import syncDebugLog from '@joplin/lib/services/synchronizer/syncDebugLog';
import eventManager, { EventName } from '@joplin/lib/eventManager';
Expand Down Expand Up @@ -566,6 +567,24 @@ class Application extends BaseApplication {
value: Setting.value('flagOpenDevTools'),
});

// 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 (!Setting.value('featureFlag.autoUpdaterServiceEnabled')) {
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);
}
}

initializeUserFetcher();
shim.setInterval(() => { void userFetcher(); }, 1000 * 60 * 60);

Expand Down Expand Up @@ -669,12 +688,14 @@ class Application extends BaseApplication {
SearchEngine.instance().scheduleSyncTables();
});

bridge().electronApp().initializeAutoUpdaterService(
Logger.create('AutoUpdaterService'),
shim,
Setting.value('env') === 'dev',
Setting.value('autoUpdate.includePreReleases'),
);
if (Setting.value('featureFlag.autoUpdaterServiceEnabled')) {
bridge().electronApp().initializeAutoUpdaterService(
Logger.create('AutoUpdaterService'),
shim,
Setting.value('env') === 'dev',
Setting.value('autoUpdate.includePreReleases'),
);
}

// setTimeout(() => {
// void populateDatabase(reg.db(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class AutoUpdaterService implements AutoUpdaterServiceInterface {

public stopPeriodicUpdateCheck = (): void => {
if (this.updatePollInterval_) {
clearInterval(this.updatePollInterval_);
this.initializedShim_.clearInterval(this.updatePollInterval_);
this.updatePollInterval_ = null;
}
};
Expand Down
12 changes: 12 additions & 0 deletions packages/lib/models/settings/builtInMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,18 @@ const builtInMetadata = (Setting: typeof SettingType) => {
appTypes: [AppType.Mobile],
},

'featureFlag.autoUpdaterServiceEnabled': {
value: true,
type: SettingItemType.Bool,
public: true,
storage: SettingStorage.File,
label: () => 'Enable auto-updates',
description: () => 'Enable this feature to receive notifications about updates and install them instead of manually downloading them. Restart app to start receiving auto-updates.',
section: 'application',
isGlobal: true,
},


// 'featureFlag.syncAccurateTimestamps': {
// value: false,
// type: SettingItemType.Bool,
Expand Down
Loading