Prevent subsequent sync attempts until getTimePosition returns. (#238)

Fixes #237.
This commit is contained in:
John Cass 2017-10-07 06:12:19 +02:00 committed by GitHub
parent b122785e31
commit 4879c3e3ce
3 changed files with 14 additions and 4 deletions

View File

@ -105,6 +105,13 @@ Project resources
Changelog
=========
(UNRELEASED)
------------
**Fixes**
- Prevent excessive calls to the Mopidy server while buffering. (Fixes: `#237 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/237>`_).
v2.4.0 (2017-03-15)
-------------------

View File

@ -106,8 +106,10 @@
// check in the timeout callback than doing another function call.
clearTimeout(this._scheduleID)
this._isSyncScheduled = false
if (milliseconds >= 0) {
this._scheduleID = setTimeout($.proxy(function () { this._isSyncScheduled = true }, this), milliseconds)
}
}
SyncedProgressTimer.prototype._doSync = function (position, duration) {
var ready = !(duration === Infinity && position === 0) // Timer has been properly initialized.
@ -116,6 +118,8 @@
return
}
this._scheduleSync(-1) // Ensure that only one sync process is active at a time.
var _this = this
_this._mopidy.playback.getTimePosition().then(function (targetPosition) {
if (_this.syncState === SyncedProgressTimer.SYNC_STATE.NOT_SYNCED) {
@ -179,8 +183,7 @@
SyncedProgressTimer.prototype.stop = function () {
this._progressTimer.stop()
clearTimeout(this._scheduleID)
this._isSyncScheduled = false
this._scheduleSync(-1)
if (this.syncState !== SyncedProgressTimer.SYNC_STATE.SYNCED && this._previousSyncPosition) {
// Timer was busy trying to sync when it was stopped, fallback to displaying the last synced position on screen.
this.positionNode.nodeValue = SyncedProgressTimer.format(this._previousSyncPosition)

View File

@ -1,6 +1,6 @@
CACHE MANIFEST
# 2017-02-26:v1
# 2017-04-14:v1
NETWORK:
*