You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Merge pull request #702 from matrix-org/bwindels/fixreconnectspinner
Fix: show spinner again while recovering from connection error
This commit is contained in:
@@ -40,6 +40,7 @@ BREAKING CHANGE
|
|||||||
---------------
|
---------------
|
||||||
|
|
||||||
* `MatrixClient::startClient` now returns a Promise. No method should be called on the client before that promise resolves. Before this method didn't return anything.
|
* `MatrixClient::startClient` now returns a Promise. No method should be called on the client before that promise resolves. Before this method didn't return anything.
|
||||||
|
* A new `CATCHUP` sync state, emitted by `MatrixClient#"sync"` and returned by `MatrixClient::getSyncState()`, when doing initial sync after the `ERROR` state. See `MatrixClient` documentation for details.
|
||||||
|
|
||||||
Changes in [0.11.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.11.0) (TDB)
|
Changes in [0.11.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.11.0) (TDB)
|
||||||
==================================================================================================
|
==================================================================================================
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ describe("MatrixClient", function() {
|
|||||||
client.startClient();
|
client.startClient();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should transition ERROR -> PREPARED after /sync if prev failed",
|
it("should transition ERROR -> CATCHUP after /sync if prev failed",
|
||||||
function(done) {
|
function(done) {
|
||||||
const expectedStates = [];
|
const expectedStates = [];
|
||||||
acceptKeepalives = false;
|
acceptKeepalives = false;
|
||||||
@@ -403,7 +403,7 @@ describe("MatrixClient", function() {
|
|||||||
|
|
||||||
expectedStates.push(["RECONNECTING", null]);
|
expectedStates.push(["RECONNECTING", null]);
|
||||||
expectedStates.push(["ERROR", "RECONNECTING"]);
|
expectedStates.push(["ERROR", "RECONNECTING"]);
|
||||||
expectedStates.push(["PREPARED", "ERROR"]);
|
expectedStates.push(["CATCHUP", "ERROR"]);
|
||||||
client.on("sync", syncChecker(expectedStates, done));
|
client.on("sync", syncChecker(expectedStates, done));
|
||||||
client.startClient();
|
client.startClient();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3527,6 +3527,12 @@ module.exports.CRYPTO_ENABLED = CRYPTO_ENABLED;
|
|||||||
* a state of SYNCING. <i>This is the equivalent of "syncComplete" in the
|
* a state of SYNCING. <i>This is the equivalent of "syncComplete" in the
|
||||||
* previous API.</i></li>
|
* previous API.</i></li>
|
||||||
*
|
*
|
||||||
|
* <li>CATCHUP: The client has detected the connection to the server might be
|
||||||
|
* available again and will now try to do a sync again. As this sync might take
|
||||||
|
* a long time (depending how long ago was last synced, and general server
|
||||||
|
* performance) the client is put in this mode so the UI can reflect trying
|
||||||
|
* to catch up with the server after losing connection.</li>
|
||||||
|
*
|
||||||
* <li>SYNCING : The client is currently polling for new events from the server.
|
* <li>SYNCING : The client is currently polling for new events from the server.
|
||||||
* This will be called <i>after</i> processing latest events from a sync.</li>
|
* This will be called <i>after</i> processing latest events from a sync.</li>
|
||||||
*
|
*
|
||||||
@@ -3551,10 +3557,10 @@ module.exports.CRYPTO_ENABLED = CRYPTO_ENABLED;
|
|||||||
* |
|
* |
|
||||||
* +----->PREPARED -------> SYNCING <--+
|
* +----->PREPARED -------> SYNCING <--+
|
||||||
* | ^ | ^ |
|
* | ^ | ^ |
|
||||||
* | | | | |
|
* | CATCHUP ----------+ | | |
|
||||||
* | | V | |
|
* | ^ V | |
|
||||||
* null ------+ | +--------RECONNECTING |
|
* null ------+ | +------- RECONNECTING |
|
||||||
* | | V |
|
* | V V |
|
||||||
* +------->ERROR ---------------------+
|
* +------->ERROR ---------------------+
|
||||||
*
|
*
|
||||||
* NB: 'null' will never be emitted by this event.
|
* NB: 'null' will never be emitted by this event.
|
||||||
|
|||||||
@@ -780,6 +780,13 @@ SyncApi.prototype._onSyncError = function(err, syncOptions) {
|
|||||||
// instead, so that clients can observe this state
|
// instead, so that clients can observe this state
|
||||||
// if they wish.
|
// if they wish.
|
||||||
this._startKeepAlives().then(() => {
|
this._startKeepAlives().then(() => {
|
||||||
|
if (this.getSyncState() === 'ERROR') {
|
||||||
|
this._updateSyncState("CATCHUP", {
|
||||||
|
oldSyncToken: null,
|
||||||
|
nextSyncToken: null,
|
||||||
|
catchingUp: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
this._sync(syncOptions);
|
this._sync(syncOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user