-
Notifications
You must be signed in to change notification settings - Fork 246
feat(auto-update-manager): show a system prompt about mismatched arch on apple arm on application start COMPASS-9592 #7133
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e1e219a
feat(auto-update-manager): show a system prompt about mismatched arch…
gribnoysup 4cdfbb2
chore(auto-update-manager): error handling and wait for app ready
gribnoysup 322b128
chore(compass): replace direct download with open external
gribnoysup a038c23
chore(auto-update-manager): share download logic, normalize url building
gribnoysup 4ee47fb
chore(auto-update-manager): auto open on download
gribnoysup 9a1e640
fix(auto-update-mananger): convert path to file url
gribnoysup 3f53d4e
chore(compass): adjust unit test for new download behavior
gribnoysup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -827,11 +827,53 @@ class CompassAutoUpdateManager { | |
| this.setState(AutoUpdateManagerState.RestartDismissed); | ||
| } | ||
|
|
||
| private static _init( | ||
| private static checkForMismatchedMacOSArch() { | ||
| const mismatchedOnArm = | ||
| isMismatchedArchDarwin() && getSystemArch() === 'arm64'; | ||
|
|
||
| if (!mismatchedOnArm) { | ||
| return; | ||
| } | ||
|
|
||
| void dialog | ||
| .showMessageBox({ | ||
| icon: COMPASS_ICON, | ||
| message: 'Mismatched architecture detected', | ||
| detail: | ||
| 'You are currently using a build of Compass that is not optimized for Apple Silicon processors. This version might have significat performance issues when used. ' + | ||
| 'Would you like to download the version of Compass optimized for Apple Silicon processors now?', | ||
| buttons: [ | ||
| 'Download Compass for Apple Silicon (Recommended)', | ||
| 'Not now', | ||
| ], | ||
| cancelId: 1, | ||
| }) | ||
| .then(({ response }) => { | ||
| if (response === 0) { | ||
| return dl.download( | ||
| BrowserWindow.getAllWindows()[0], | ||
| `https://compass.mongodb.com/api/v2/download/${this.autoUpdateOptions.version}/compass/${this.autoUpdateOptions.channel}/darwin-arm64` | ||
| ); | ||
|
||
| } | ||
| }) | ||
| .catch((err) => { | ||
| log.warn( | ||
| mongoLogId(1_001_000_362), | ||
| 'AutoUpdateManager', | ||
| 'Failed to download Compass for a mismatched macos arch', | ||
Anemy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { error: err.message } | ||
| ); | ||
| }); | ||
| } | ||
|
|
||
| private static async _init( | ||
| compassApp: typeof CompassApplication, | ||
| options: Partial<AutoUpdateManagerOptions> = {} | ||
| ): void { | ||
| ): Promise<void> { | ||
| await app.whenReady(); | ||
|
|
||
| this.fetch = (url: string) => compassApp.httpClient.fetch(url); | ||
|
|
||
| compassApp.addExitHandler(() => { | ||
| this.stop(); | ||
| return Promise.resolve(); | ||
|
|
@@ -867,6 +909,8 @@ class CompassAutoUpdateManager { | |
| ...options, | ||
| }; | ||
|
|
||
| this.checkForMismatchedMacOSArch(); | ||
|
|
||
| // TODO(COMPASS-7232): If auto-updates are not supported, then there is | ||
| // still a menu item to check for updates and then if it finds an update but | ||
| // auto-updates aren't supported it will still display a popup with an | ||
|
|
@@ -961,13 +1005,13 @@ class CompassAutoUpdateManager { | |
| ); | ||
| } | ||
|
|
||
| static init( | ||
| static async init( | ||
| compassApp: typeof CompassApplication, | ||
| options: Partial<AutoUpdateManagerOptions> = {} | ||
| ): void { | ||
| ): Promise<void> { | ||
| if (!this.initCalled) { | ||
| this.initCalled = true; | ||
| this._init(compassApp, options); | ||
| await this._init(compassApp, options); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think the performance issue is bad enough that it deserves a system prompt and not a toast or something similar, but I'm open to the feedback here