Skip to content

Commit bd1b06c

Browse files
author
Weblate
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 7cbfa22 + 98f8be4 commit bd1b06c

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

‎src/vector/index.js‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,16 @@ function getConfig() {
216216
return deferred.promise;
217217
}
218218

219-
function onLoadCompleted() {
219+
function onTokenLoginCompleted() {
220220
// if we did a token login, we're now left with the token, hs and is
221221
// url as query params in the url; a little nasty but let's redirect to
222222
// clear them.
223-
if (window.location.search) {
224-
var parsedUrl = url.parse(window.location.href);
225-
parsedUrl.search = "";
226-
var formatted = url.format(parsedUrl);
227-
console.log("Redirecting to " + formatted + " to drop loginToken " +
228-
"from queryparams");
229-
window.location.href = formatted;
230-
}
223+
var parsedUrl = url.parse(window.location.href);
224+
parsedUrl.search = "";
225+
var formatted = url.format(parsedUrl);
226+
console.log("Redirecting to " + formatted + " to drop loginToken " +
227+
"from queryparams");
228+
window.location.href = formatted;
231229
}
232230

233231
async function loadApp() {
@@ -288,7 +286,7 @@ async function loadApp() {
288286
realQueryParams={params}
289287
startingFragmentQueryParams={fragparts.params}
290288
enableGuest={true}
291-
onLoadCompleted={onLoadCompleted}
289+
onTokenLoginCompleted={onTokenLoginCompleted}
292290
initialScreenAfterLogin={getScreenFromLocation(window.location)}
293291
defaultDeviceDisplayName={PlatformPeg.get().getDefaultDeviceDisplayName()}
294292
/>,

‎test/app-tests/loading.js‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import jssdk from 'matrix-js-sdk';
2929
import sdk from 'matrix-react-sdk';
3030
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
3131
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
32+
import {VIEWS} from 'matrix-react-sdk/lib/components/structures/MatrixChat';
3233

3334
import * as test_utils from '../test-utils';
3435
import MockHttpBackend from '../mock-request';
@@ -47,7 +48,7 @@ describe('loading:', function () {
4748
// the mounted MatrixChat
4849
let matrixChat;
4950

50-
// a promise which resolves when the MatrixChat calls onLoadCompleted
51+
// a promise which resolves when the MatrixChat calls onTokenLoginCompleted
5152
let loadCompletePromise;
5253

5354
beforeEach(function() {
@@ -135,7 +136,7 @@ describe('loading:', function () {
135136
realQueryParams={params}
136137
startingFragmentQueryParams={fragParts.params}
137138
enableGuest={true}
138-
onLoadCompleted={loadCompleteDefer.resolve}
139+
onTokenLoginCompleted={loadCompleteDefer.resolve}
139140
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
140141
makeRegistrationUrl={() => {throw new Error('Not implemented');}}
141142
/>, parentDiv
@@ -153,8 +154,8 @@ describe('loading:', function () {
153154
.check((r) => {syncRequest = r;})
154155
.respond(200, response);
155156

156-
console.log("waiting for /sync");
157157
for (let attempts = 10; attempts > 0; attempts--) {
158+
console.log(Date.now() + " waiting for /sync");
158159
if (syncRequest) {
159160
return syncRequest;
160161
}
@@ -179,12 +180,12 @@ describe('loading:', function () {
179180
return httpBackend.flush();
180181
}).then(() => {
181182
// Wait for another trip around the event loop for the UI to update
182-
return q.delay(1);
183+
return q.delay(10);
183184
}).then(() => {
184185
// we expect a single <Login> component following session load
185186
ReactTestUtils.findRenderedComponentWithType(
186187
matrixChat, sdk.getComponent('structures.login.Login'));
187-
expect(windowLocation.hash).toEqual("");
188+
expect(windowLocation.hash).toEqual("#/login");
188189
}).done(done, done);
189190
});
190191

@@ -205,7 +206,7 @@ describe('loading:', function () {
205206
return httpBackend.flush();
206207
}).then(() => {
207208
// Wait for another trip around the event loop for the UI to update
208-
return q.delay(1);
209+
return q.delay(10);
209210
}).then(() => {
210211
return completeLogin(matrixChat);
211212
}).then(() => {
@@ -360,6 +361,9 @@ describe('loading:', function () {
360361
loadApp({
361362
uriFragment: "#/login",
362363
});
364+
365+
// give the UI a chance to display
366+
return q.delay(50);
363367
});
364368

365369
it('shows a login view', function() {
@@ -513,7 +517,7 @@ describe('loading:', function () {
513517

514518
return httpBackend.flush();
515519
}).then(() => {
516-
// at this point, MatrixChat should fire onLoadCompleted, which
520+
// at this point, MatrixChat should fire onTokenLoginCompleted, which
517521
// makes index.js reload the app. We're not going to attempt to
518522
// simulate the reload - just check that things are left in the
519523
// right state for the reloaded app.
@@ -589,7 +593,8 @@ function awaitSyncingSpinner(matrixChat, retryLimit, retryCount) {
589593
retryCount = 0;
590594
}
591595

592-
if (matrixChat.state.loading || matrixChat.state.loggingIn) {
596+
if (matrixChat.state.view === VIEWS.LOADING ||
597+
matrixChat.state.view === VIEWS.LOGGING_IN) {
593598
console.log(Date.now() + " Awaiting sync spinner: still loading.");
594599
if (retryCount >= retryLimit) {
595600
throw new Error("MatrixChat still not loaded after " +
@@ -628,8 +633,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
628633
retryCount = 0;
629634
}
630635

631-
if (matrixChat.state.loading ||
632-
!(matrixChat.state.loggedIn && matrixChat.state.ready)) {
636+
if (matrixChat.state.view !== VIEWS.LOGGED_IN || !matrixChat.state.ready) {
633637
console.log(Date.now() + " Awaiting room view: not ready yet.");
634638
if (retryCount >= retryLimit) {
635639
throw new Error("MatrixChat still not ready after " +

0 commit comments

Comments
 (0)