mirror of
https://github.com/Foundry376/Mailspring.git
synced 2026-01-06 08:56:09 +08:00
fix(autoupdater): Change feed URL when Nylas ID or accounts changes
Test Plan: Tested locally. Reviewers: juan, evan Reviewed By: juan, evan Differential Revision: https://phab.nylas.com/D3178
This commit is contained in:
parent
afc20f255a
commit
c908a1633c
2 changed files with 33 additions and 2 deletions
|
|
@ -4,14 +4,17 @@ url = require 'url'
|
|||
describe "AutoUpdateManager", ->
|
||||
beforeEach ->
|
||||
@nylasIdentityId = null
|
||||
@accounts = [{email_address: 'ben@nylas.com'},{email_address: 'mark@nylas.com'}]
|
||||
@specMode = true
|
||||
@config =
|
||||
set: jasmine.createSpy('config.set')
|
||||
get: (key) =>
|
||||
if key is 'nylas.accounts'
|
||||
return [{email_address: 'ben@nylas.com'},{email_address: 'mark@nylas.com'}]
|
||||
return @accounts
|
||||
if key is 'nylas.identity.id'
|
||||
return @nylasIdentityId
|
||||
onDidChange: (key, callback) =>
|
||||
callback()
|
||||
|
||||
describe "with attached commit version", ->
|
||||
it "correctly sets the feedURL", ->
|
||||
|
|
@ -46,3 +49,14 @@ describe "AutoUpdateManager", ->
|
|||
spyOn(m, "setupAutoUpdater")
|
||||
{query} = url.parse(m.feedURL, true)
|
||||
expect(query.id).toEqual(@nylasIdentityId)
|
||||
|
||||
describe "when an update identity is added", ->
|
||||
it "should update the feed URL", ->
|
||||
m = new AutoUpdateManager("3.222.1", @config, @specMode)
|
||||
spyOn(m, "setupAutoUpdater")
|
||||
{query} = url.parse(m.feedURL, true)
|
||||
expect(query.id).toEqual('anonymous')
|
||||
@nylasIdentityId = '1'
|
||||
m._updateFeedURL()
|
||||
{query} = url.parse(m.feedURL, true)
|
||||
expect(query.id).toEqual(@nylasIdentityId)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,21 @@ export default class AutoUpdateManager extends EventEmitter {
|
|||
this.config = config;
|
||||
this.specMode = specMode;
|
||||
|
||||
this._updateFeedURL();
|
||||
|
||||
this.config.onDidChange(
|
||||
'nylas.identity.id',
|
||||
this._updateFeedURL
|
||||
);
|
||||
this.config.onDidChange(
|
||||
'nylas.accounts',
|
||||
this._updateFeedURL
|
||||
);
|
||||
|
||||
process.nextTick(() => this.setupAutoUpdater());
|
||||
}
|
||||
|
||||
_updateFeedURL = () => {
|
||||
let updaterId = this.config.get("nylas.identity.id");
|
||||
if (!updaterId) {
|
||||
updaterId = "anonymous";
|
||||
|
|
@ -46,7 +61,9 @@ export default class AutoUpdateManager extends EventEmitter {
|
|||
this.feedURL = `https://edgehill.nylas.com/update-check?platform=${process.platform}&arch=${process.arch}&version=${this.version}&id=${updaterId}&emails=${updaterEmails}`;
|
||||
}
|
||||
|
||||
process.nextTick(() => this.setupAutoUpdater());
|
||||
if (autoUpdater) {
|
||||
autoUpdater.setFeedURL(this.feedURL)
|
||||
}
|
||||
}
|
||||
|
||||
setupAutoUpdater() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue