From 4a794e90a01ede129111c4a9c2315e66060024fe Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 4 Mar 2021 10:43:17 +1100 Subject: [PATCH] signInWithRecovery = show full screen loader --- .../session/registration/RegistrationTabs.tsx | 6 +++- .../session/registration/SignInTab.tsx | 22 +++++++++++-- ts/session/snode_api/serviceNodeAPI.ts | 15 ++++++++- .../session/unit/sending/MessageQueue_test.ts | 32 +++++++++++-------- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/ts/components/session/registration/RegistrationTabs.tsx b/ts/components/session/registration/RegistrationTabs.tsx index 0ede8350a..7056f5583 100644 --- a/ts/components/session/registration/RegistrationTabs.tsx +++ b/ts/components/session/registration/RegistrationTabs.tsx @@ -207,6 +207,10 @@ export async function signInWithRecovery(signInDetails: { } } +/** + * This is will try to sign in with the user recovery phrase. + * If no ConfigurationMessage is received in 60seconds, the loading will be canceled. + */ export async function signInWithLinking(signInDetails: { userRecoveryPhrase: string; password: string; @@ -236,7 +240,7 @@ export async function signInWithLinking(signInDetails: { displayNameFromNetwork = displayName; } ); - }, 30000); + }, 60000); if (displayNameFromNetwork.length) { // display name, avatars, groups and contacts should already be handled when this event was triggered. window.log.info('We got a displayName from network: '); diff --git a/ts/components/session/registration/SignInTab.tsx b/ts/components/session/registration/SignInTab.tsx index 00638531b..d700c5152 100644 --- a/ts/components/session/registration/SignInTab.tsx +++ b/ts/components/session/registration/SignInTab.tsx @@ -224,9 +224,25 @@ export const SignInTab = () => { handleContinueYourSessionClick={continueYourSession} disabled={!activateContinueButton} /> - - - + {loading && ( + + + + )} + {showTermsAndConditions && } ); diff --git a/ts/session/snode_api/serviceNodeAPI.ts b/ts/session/snode_api/serviceNodeAPI.ts index ea7d610f3..31c0fa899 100644 --- a/ts/session/snode_api/serviceNodeAPI.ts +++ b/ts/session/snode_api/serviceNodeAPI.ts @@ -384,7 +384,20 @@ export async function retrieveNextMessages( // NOTE: Retrieve cannot result in "wrong POW", but we call // `checkResponse` to check for "wrong swarm" - checkResponse(res); + try { + checkResponse(res); + } catch (e) { + window.log.warn( + 'loki_message:::retrieveNextMessages - send error:', + e.code, + e.message + ); + if (e instanceof window.textsecure.WrongSwarmError) { + const { newSwarm } = e; + await updateSnodesFor(params.pubKey, newSwarm); + return []; + } + } if (res.status !== 200) { window.log('retrieve result is not 200'); diff --git a/ts/test/session/unit/sending/MessageQueue_test.ts b/ts/test/session/unit/sending/MessageQueue_test.ts index c8c1dac5c..44113fc73 100644 --- a/ts/test/session/unit/sending/MessageQueue_test.ts +++ b/ts/test/session/unit/sending/MessageQueue_test.ts @@ -39,7 +39,11 @@ describe('MessageQueue', () => { let messageQueueStub: MessageQueue; // Message Sender Stubs - let sendStub: sinon.SinonStub<[RawMessage, (number | undefined)?, (number | undefined)?]>; + let sendStub: sinon.SinonStub<[ + RawMessage, + (number | undefined)?, + (number | undefined)? + ]>; beforeEach(() => { // Utils Stubs @@ -122,19 +126,19 @@ describe('MessageQueue', () => { it('should send a success event if message was sent', done => { const device = TestUtils.generateFakePubKey(); const message = TestUtils.generateChatMessage(); - const waitForMessageSentEvent = async () => new Promise(resolve => { - resolve(); - try { - - expect(messageSentHandlerSuccessStub.callCount).to.be.equal(1); - expect( - messageSentHandlerSuccessStub.lastCall.args[0].identifier - ).to.be.equal(message.identifier); - done(); - } catch (e) { - done(e); - } - }); + const waitForMessageSentEvent = async () => + new Promise(resolve => { + resolve(); + try { + expect(messageSentHandlerSuccessStub.callCount).to.be.equal(1); + expect( + messageSentHandlerSuccessStub.lastCall.args[0].identifier + ).to.be.equal(message.identifier); + done(); + } catch (e) { + done(e); + } + }); void pendingMessageCache .add(device, message, waitForMessageSentEvent)