From 6df1574b8beeb3f6838f1ba7096019e0fcea9083 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 16 Jun 2017 15:05:14 +0100 Subject: [PATCH 1/2] onLoadCompleted is now onTokenLoginCompleted --- src/vector/index.js | 18 ++++++++---------- test/app-tests/loading.js | 8 +++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 9f1620516..da03327da 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -216,18 +216,16 @@ function getConfig() { return deferred.promise; } -function onLoadCompleted() { +function onTokenLoginCompleted() { // if we did a token login, we're now left with the token, hs and is // url as query params in the url; a little nasty but let's redirect to // clear them. - if (window.location.search) { - var parsedUrl = url.parse(window.location.href); - parsedUrl.search = ""; - var formatted = url.format(parsedUrl); - console.log("Redirecting to " + formatted + " to drop loginToken " + - "from queryparams"); - window.location.href = formatted; - } + var parsedUrl = url.parse(window.location.href); + parsedUrl.search = ""; + var formatted = url.format(parsedUrl); + console.log("Redirecting to " + formatted + " to drop loginToken " + + "from queryparams"); + window.location.href = formatted; } async function loadApp() { @@ -288,7 +286,7 @@ async function loadApp() { realQueryParams={params} startingFragmentQueryParams={fragparts.params} enableGuest={true} - onLoadCompleted={onLoadCompleted} + onTokenLoginCompleted={onTokenLoginCompleted} initialScreenAfterLogin={getScreenFromLocation(window.location)} defaultDeviceDisplayName={PlatformPeg.get().getDefaultDeviceDisplayName()} />, diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index a323a2626..04c68377a 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -47,7 +47,7 @@ describe('loading:', function () { // the mounted MatrixChat let matrixChat; - // a promise which resolves when the MatrixChat calls onLoadCompleted + // a promise which resolves when the MatrixChat calls onTokenLoginCompleted let loadCompletePromise; beforeEach(function() { @@ -135,7 +135,7 @@ describe('loading:', function () { realQueryParams={params} startingFragmentQueryParams={fragParts.params} enableGuest={true} - onLoadCompleted={loadCompleteDefer.resolve} + onTokenLoginCompleted={loadCompleteDefer.resolve} initialScreenAfterLogin={getScreenFromLocation(windowLocation)} makeRegistrationUrl={() => {throw new Error('Not implemented');}} />, parentDiv @@ -360,6 +360,8 @@ describe('loading:', function () { loadApp({ uriFragment: "#/login", }); + + return q.delay(1); }); it('shows a login view', function() { @@ -513,7 +515,7 @@ describe('loading:', function () { return httpBackend.flush(); }).then(() => { - // at this point, MatrixChat should fire onLoadCompleted, which + // at this point, MatrixChat should fire onTokenLoginCompleted, which // makes index.js reload the app. We're not going to attempt to // simulate the reload - just check that things are left in the // right state for the reloaded app. From 60be24c66553adae0897f0a2197f886c21f71f47 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 19 Jun 2017 09:04:24 +0100 Subject: [PATCH 2/2] Rename promise --- test/app-tests/loading.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/app-tests/loading.js b/test/app-tests/loading.js index 04c68377a..974bd8974 100644 --- a/test/app-tests/loading.js +++ b/test/app-tests/loading.js @@ -48,7 +48,7 @@ describe('loading:', function () { let matrixChat; // a promise which resolves when the MatrixChat calls onTokenLoginCompleted - let loadCompletePromise; + let tokenLoginCompletePromise; beforeEach(function() { test_utils.beforeEach(this); @@ -99,8 +99,8 @@ describe('loading:', function () { toString: function() { return this.search + this.hash; }, }; - let loadCompleteDefer = q.defer(); - loadCompletePromise = loadCompleteDefer.promise; + let tokenLoginCompleteDefer = q.defer(); + tokenLoginCompletePromise = tokenLoginCompleteDefer.promise; function onNewScreen(screen) { console.log(Date.now() + " newscreen "+screen); @@ -135,7 +135,7 @@ describe('loading:', function () { realQueryParams={params} startingFragmentQueryParams={fragParts.params} enableGuest={true} - onTokenLoginCompleted={loadCompleteDefer.resolve} + onTokenLoginCompleted={tokenLoginCompleteDefer.resolve} initialScreenAfterLogin={getScreenFromLocation(windowLocation)} makeRegistrationUrl={() => {throw new Error('Not implemented');}} />, parentDiv @@ -520,7 +520,7 @@ describe('loading:', function () { // simulate the reload - just check that things are left in the // right state for the reloaded app. - return loadCompletePromise; + return tokenLoginCompletePromise; }).then(() => { // check that the localstorage has been set up in such a way that // the reloaded app can pick up where we leave off.