You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-04 05:02:41 +03:00
Merge pull request #76 from matrix-org/dbkr/sync_gutwrench_less
Change the sync state tracking slightly to gut-wrench client a bit less
This commit is contained in:
@@ -174,8 +174,8 @@ function MatrixClient(opts) {
|
||||
setupCallEventHandler(this);
|
||||
this._supportsVoip = true;
|
||||
}
|
||||
this._syncState = null;
|
||||
this._syncingRetry = null;
|
||||
this._syncApi = null;
|
||||
this._peekSync = null;
|
||||
this._isGuest = false;
|
||||
this._ongoingScrollbacks = {};
|
||||
@@ -244,7 +244,8 @@ MatrixClient.prototype.supportsVoip = function() {
|
||||
* @see module:client~MatrixClient#event:"sync"
|
||||
*/
|
||||
MatrixClient.prototype.getSyncState = function() {
|
||||
return this._syncState;
|
||||
if (!this._syncApi) { return null; }
|
||||
return this._syncApi.getSyncState();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2924,8 +2925,13 @@ MatrixClient.prototype.startClient = function(opts) {
|
||||
// periodically poll for turn servers if we support voip
|
||||
checkTurnServers(this);
|
||||
|
||||
var syncApi = new SyncApi(this, opts);
|
||||
syncApi.sync();
|
||||
if (this._syncApi) {
|
||||
// This shouldn't happen since we thought the client was not running
|
||||
console.error("Still have sync object whilst not running: stopping old one");
|
||||
this._syncApi.stop();
|
||||
}
|
||||
this._syncApi = new SyncApi(this, opts);
|
||||
this._syncApi.sync();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2935,7 +2941,8 @@ MatrixClient.prototype.startClient = function(opts) {
|
||||
MatrixClient.prototype.stopClient = function() {
|
||||
this.clientRunning = false;
|
||||
// TODO: f.e. Room => self.store.storeRoom(room) ?
|
||||
// TODO: Actually stop the SyncApi
|
||||
this._syncApi.stop();
|
||||
this._syncApi = null;
|
||||
};
|
||||
|
||||
function setupCallEventHandler(client) {
|
||||
@@ -3277,9 +3284,14 @@ module.exports.CRYPTO_ENABLED = CRYPTO_ENABLED;
|
||||
* the server for updates. This may be called multiple times even if the state is
|
||||
* already ERROR. <i>This is the equivalent of "syncError" in the previous
|
||||
* API.</i></li>
|
||||
* <li>STOPPED: The client has stopped syncing with server due to stopClient
|
||||
* being called.
|
||||
* </li>
|
||||
* </ul>
|
||||
* State transition diagram:
|
||||
* <pre>
|
||||
* +---->STOPPED
|
||||
* |
|
||||
* +----->PREPARED -------> SYNCING <--+
|
||||
* | ^ | |
|
||||
* null ------+ | +---------------+ |
|
||||
@@ -3305,13 +3317,15 @@ module.exports.CRYPTO_ENABLED = CRYPTO_ENABLED;
|
||||
* for a second time or more.</li>
|
||||
* <li><code>SYNCING -> SYNCING</code> : Occurs when the client has performed a live
|
||||
* update. This is called <i>after</i> processing.</li>
|
||||
* <li><code>* -> STOPPED</code> : Occurs once the client has stopped syncing or
|
||||
* trying to sync after stopClient has been called.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @event module:client~MatrixClient#"sync"
|
||||
* @param {string} state An enum representing the syncing state. One of "PREPARED",
|
||||
* "SYNCING", "ERROR".
|
||||
* "SYNCING", "ERROR", "STOPPED".
|
||||
* @param {?string} prevState An enum representing the previous syncing state.
|
||||
* One of "PREPARED", "SYNCING", "ERROR" <b>or null</b>.
|
||||
* One of "PREPARED", "SYNCING", "ERROR", "STOPPED" <b>or null</b>.
|
||||
* @param {?Object} data Data about this transition.
|
||||
* @param {MatrixError} data.err The matrix error if <code>state=ERROR</code>.
|
||||
* @example
|
||||
|
||||
Reference in New Issue
Block a user