Skip to content

Commit 563d1dc

Browse files
authored
Merge pull request element-hq#4335 from vector-im/rav/fix_token_redirect
onLoadCompleted is now onTokenLoginCompleted
2 parents 0608c67 + 5a8a41a commit 563d1dc

2 files changed

Lines changed: 15 additions & 17 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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ describe('loading:', function () {
4848
// the mounted MatrixChat
4949
let matrixChat;
5050

51-
// a promise which resolves when the MatrixChat calls onLoadCompleted
52-
let loadCompletePromise;
51+
// a promise which resolves when the MatrixChat calls onTokenLoginCompleted
52+
let tokenLoginCompletePromise;
5353

5454
beforeEach(function() {
5555
test_utils.beforeEach(this);
@@ -100,8 +100,8 @@ describe('loading:', function () {
100100
toString: function() { return this.search + this.hash; },
101101
};
102102

103-
let loadCompleteDefer = q.defer();
104-
loadCompletePromise = loadCompleteDefer.promise;
103+
let tokenLoginCompleteDefer = q.defer();
104+
tokenLoginCompletePromise = tokenLoginCompleteDefer.promise;
105105

106106
function onNewScreen(screen) {
107107
console.log(Date.now() + " newscreen "+screen);
@@ -136,7 +136,7 @@ describe('loading:', function () {
136136
realQueryParams={params}
137137
startingFragmentQueryParams={fragParts.params}
138138
enableGuest={true}
139-
onLoadCompleted={loadCompleteDefer.resolve}
139+
onTokenLoginCompleted={tokenLoginCompleteDefer.resolve}
140140
initialScreenAfterLogin={getScreenFromLocation(windowLocation)}
141141
makeRegistrationUrl={() => {throw new Error('Not implemented');}}
142142
/>, parentDiv
@@ -517,12 +517,12 @@ describe('loading:', function () {
517517

518518
return httpBackend.flush();
519519
}).then(() => {
520-
// at this point, MatrixChat should fire onLoadCompleted, which
520+
// at this point, MatrixChat should fire onTokenLoginCompleted, which
521521
// makes index.js reload the app. We're not going to attempt to
522522
// simulate the reload - just check that things are left in the
523523
// right state for the reloaded app.
524524

525-
return loadCompletePromise;
525+
return tokenLoginCompletePromise;
526526
}).then(() => {
527527
// check that the localstorage has been set up in such a way that
528528
// the reloaded app can pick up where we leave off.

0 commit comments

Comments
 (0)