Skip to content

Commit 18ba9bd

Browse files
committed
Use new sync-started event when available
It's faster than waiting for the first sync request to have finished (or failed)
1 parent bd18cd3 commit 18ba9bd

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/widget.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ class Widget {
5858
case 'ready':
5959
this.setState(this.state);
6060
break;
61+
case 'sync-started':
62+
this.handleSyncStarted();
63+
break;
64+
// For backward compatibility with rs.js <= 2.0.0-beta.6
6165
case 'sync-req-done':
62-
this.syncInProgress = true;
63-
this.rsSyncButton.classList.add("rs-rotate");
64-
setTimeout(() => {
65-
if (!this.syncInProgress) return;
66-
this.rsConnectedLabel.textContent = 'Synchronizing';
67-
}, 1000);
66+
this.handleSyncStarted();
6867
break;
6968
case 'sync-done':
7069
if (this.online && !msg.completed) return;
@@ -500,6 +499,15 @@ class Widget {
500499
this.close();
501500
}
502501

502+
handleSyncStarted () {
503+
this.syncInProgress = true;
504+
this.rsSyncButton.classList.add("rs-rotate");
505+
setTimeout(() => {
506+
if (!this.syncInProgress) return;
507+
this.rsConnectedLabel.textContent = 'Synchronizing';
508+
}, 1000);
509+
}
510+
503511
handleDiscoveryError (error) {
504512
let msgContainer = document.querySelector('.rs-sign-in-error');
505513
msgContainer.innerHTML = error.message;

0 commit comments

Comments
 (0)