Clear sync error and start sync after logging in in prefs (#2802)
Also fixes an existing error due to an argumentless call to Zotero.Sync.Runner.updateIcons() in ZoteroPane.
This commit is contained in:
parent
f9a0622c30
commit
c1bb910d1c
3 changed files with 27 additions and 1 deletions
|
@ -182,6 +182,17 @@ Zotero_Preferences.Sync = {
|
|||
Zotero.Sync.Runner.deleteAPIKey();
|
||||
return;
|
||||
}
|
||||
|
||||
// It shouldn't be possible for a sync to be in progress if the user wasn't logged in,
|
||||
// but check to be sure
|
||||
if (!Zotero.Sync.Runner.syncInProgress) {
|
||||
// Clear any displayed sync errors
|
||||
Zotero.Sync.Runner.updateIcons([]);
|
||||
}
|
||||
window.addEventListener('beforeunload', () => {
|
||||
Zotero.Sync.Runner.setSyncTimeout(1);
|
||||
});
|
||||
|
||||
this.displayFields(json.username);
|
||||
}),
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ var ZoteroPane = new function()
|
|||
if (index == 0) {
|
||||
Zotero.Sync.Server.sync({
|
||||
onSuccess: function () {
|
||||
Zotero.Sync.Runner.updateIcons();
|
||||
Zotero.Sync.Runner.updateIcons([]);
|
||||
|
||||
ps.alert(
|
||||
null,
|
||||
|
|
|
@ -98,7 +98,22 @@ describe("Sync Preferences", function () {
|
|||
yield assert.eventually.equal(Zotero.Sync.Data.Local.getAPIKey(), apiKey);
|
||||
assert.equal(doc.getElementById('sync-unauthorized').getAttribute('hidden'), 'true');
|
||||
});
|
||||
|
||||
it("should clear sync errors from the toolbar after logging in", async function () {
|
||||
let win = await loadZoteroPane();
|
||||
after(function () {
|
||||
win.close();
|
||||
});
|
||||
|
||||
let syncError = win.document.getElementById('zotero-tb-sync-error');
|
||||
|
||||
Zotero.Sync.Runner.updateIcons(new Error("a sync error"));
|
||||
assert.isFalse(syncError.hidden);
|
||||
|
||||
getAPIKeyFromCredentialsStub.resolves(apiResponse);
|
||||
await setCredentials("Username", "correctPassword");
|
||||
assert.isTrue(syncError.hidden);
|
||||
});
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue