Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/flat-schools-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

feat: allow overriding AppUpdater.isStagingMatch
23 changes: 20 additions & 3 deletions packages/electron-updater/src/AppUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
this.configOnDisk = new Lazy<any>(() => this.loadUpdateConfig())
}

protected _isUpdateSupported: VerifyUpdateSupport = (updateInfo: UpdateInfo): boolean | Promise<boolean> => this.checkIfUpdateSupported(updateInfo)
Comment thread
mmaietta marked this conversation as resolved.
protected _isUpdateSupported: VerifyUpdateSupport = updateInfo => this.checkIfUpdateSupported(updateInfo)

/**
* Allows developer to override default logic for determining if an update is supported.
Expand All @@ -220,6 +220,23 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
}
}

protected _isUserWithinRollout: VerifyUpdateSupport = updateInfo => this.isStagingMatch(updateInfo)

/**
* Allows developer to override default logic for determining if the user is below the rollout threshold.
* The default logic compares the staging percentage with numerical representation of user ID.
* An override can define custom logic, or bypass it if needed.
*/
get isUserWithinRollout(): VerifyUpdateSupport {
return this._isUserWithinRollout
}

set isUserWithinRollout(value: VerifyUpdateSupport) {
if (value) {
this._isUserWithinRollout = value
}
}

private clientPromise: Promise<Provider<any>> | null = null

protected readonly stagingUserIdPromise = new Lazy<string>(() => this.getOrCreateStagingUserId())
Expand Down Expand Up @@ -417,8 +434,8 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
return false
}

const isStagingMatch = await this.isStagingMatch(updateInfo)
if (!isStagingMatch) {
const isUserWithinRollout = await Promise.resolve(this.isUserWithinRollout(updateInfo))
if (!isUserWithinRollout) {
return false
}

Expand Down