From 850233bc9e2188e9a846d3d21e874b4d63164b13 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 10 Feb 2021 10:31:48 +1100 Subject: [PATCH] review PR --- js/modules/backup.js | 2 +- js/modules/data.d.ts | 6 +++--- .../conversation/SessionCompositionBox.tsx | 2 +- ts/receiver/queuedJob.ts | 2 +- .../unit/crypto/MessageEncrypter_test.ts | 12 +++++------- ts/test/session/unit/utils/Promise_test.ts | 17 +++++++++++------ 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/js/modules/backup.js b/js/modules/backup.js index 6c8344469..d3f5bae5b 100644 --- a/js/modules/backup.js +++ b/js/modules/backup.js @@ -196,7 +196,7 @@ async function importConversationsFromJSON(conversations, options) { ); // eslint-disable-next-line no-await-in-loop await window.Signal.Data.saveConversation(migrated, { - Conversation: window.Wh, + Conversation: window.models.Conversation.ConversationModel, }); } diff --git a/js/modules/data.d.ts b/js/modules/data.d.ts index 71aea19c9..d81863f44 100644 --- a/js/modules/data.d.ts +++ b/js/modules/data.d.ts @@ -1,4 +1,5 @@ import { KeyPair } from '../../libtextsecure/libsignal-protocol'; +import { MessageCollection } from '../../ts/models/message'; import { HexKeyPair } from '../../ts/receiver/closedGroups'; import { PubKey } from '../../ts/session/types'; import { ConversationType } from '../../ts/state/ducks/conversations'; @@ -242,8 +243,7 @@ export function getUnreadByConversation( { MessageCollection }?: any ): Promise; export function getUnreadCountByConversation( - conversationId: string, - { MessageCollection }?: any + conversationId: string ): Promise; export function removeAllMessagesInConversation( conversationId: string, @@ -261,7 +261,7 @@ export function getMessageBySender( export function getMessagesBySender( { source, sourceDevice }: { source: any; sourceDevice: any }, { Message }: { Message: any } -): Promise; +): Promise; export function getMessageIdsFromServerIds( serverIds: any, conversationId: any diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index 95f390601..08c38720b 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -98,7 +98,7 @@ const sendMessageStyle = { input: { overflow: 'auto', maxHeight: 70, - wordBreak: 'break-all', + wordBreak: 'break-word', padding: '0px', margin: '0px', }, diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index 88152bf76..adc8c8614 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -54,7 +54,7 @@ async function handleGroups( // Check if anyone got kicked: const removedMembers = _.difference(oldMembers, attributes.members); - const ourDeviceWasRemoved = removedMembers.some(async member => + const ourDeviceWasRemoved = removedMembers.some(member => UserUtils.isUsFromCache(member) ); diff --git a/ts/test/session/unit/crypto/MessageEncrypter_test.ts b/ts/test/session/unit/crypto/MessageEncrypter_test.ts index a3fcbc011..4e38afef5 100644 --- a/ts/test/session/unit/crypto/MessageEncrypter_test.ts +++ b/ts/test/session/unit/crypto/MessageEncrypter_test.ts @@ -167,13 +167,11 @@ describe('MessageEncrypter', () => { it('should throw an error for anything else than Fallback or ClosedGroup', () => { const data = crypto.randomBytes(10); - expect( - MessageEncrypter.encrypt( - TestUtils.generateFakePubKey(), - data, - EncryptionType.Signal - ) - ).to.be.rejectedWith(Error); + return MessageEncrypter.encrypt( + TestUtils.generateFakePubKey(), + data, + EncryptionType.Signal + ).should.eventually.be.rejectedWith(Error); }); }); }); diff --git a/ts/test/session/unit/utils/Promise_test.ts b/ts/test/session/unit/utils/Promise_test.ts index 1bc04261c..abf73a2c9 100644 --- a/ts/test/session/unit/utils/Promise_test.ts +++ b/ts/test/session/unit/utils/Promise_test.ts @@ -8,6 +8,7 @@ import { PromiseUtils } from '../../../../session/utils'; // tslint:disable-next-line: no-require-imports no-var-requires import chaiAsPromised from 'chai-as-promised'; chai.use(chaiAsPromised as any); +chai.should(); const { expect } = chai; @@ -51,10 +52,10 @@ describe('Promise Utils', () => { }; const promise = PromiseUtils.poll(task, {}); - await promise; expect(pollSpy.callCount).to.equal(1); expect(completionSpy.callCount).to.equal(1); + return promise; }); it('can timeout a task', () => { @@ -64,9 +65,11 @@ describe('Promise Utils', () => { const promise = PromiseUtils.poll(task, { timeoutMs: 1 }); - promise.should.eventually.be.rejectedWith('Periodic check timeout'); expect(pollSpy.callCount).to.equal(1); expect(completionSpy.callCount).to.equal(0); + return promise.should.eventually.be.rejectedWith( + 'Periodic check timeout' + ); }); it('will recur according to interval option', async () => { @@ -105,9 +108,9 @@ describe('Promise Utils', () => { const promise = PromiseUtils.waitForTask(task); - await promise; expect(waitForTaskSpy.callCount).to.equal(1); expect(completionSpy.callCount).to.equal(1); + return promise; }); it('can timeout a task', () => { @@ -117,9 +120,9 @@ describe('Promise Utils', () => { const promise = PromiseUtils.waitForTask(task, 1); - promise.should.eventually.be.rejectedWith('Task timed out.'); expect(waitForTaskSpy.callCount).to.equal(1); expect(completionSpy.callCount).to.equal(0); + return promise.should.eventually.be.rejectedWith('Task timed out.'); }); }); @@ -127,17 +130,19 @@ describe('Promise Utils', () => { it('can wait for check', async () => { const check = () => true; const promise = PromiseUtils.waitUntil(check); - await promise; expect(waitUntilSpy.callCount).to.equal(1); + return promise; }); it('can timeout a check', () => { const check = () => false; const promise = PromiseUtils.waitUntil(check, 1); - promise.should.eventually.be.rejectedWith('Periodic check timeout'); expect(waitUntilSpy.callCount).to.equal(1); + return promise.should.eventually.be.rejectedWith( + 'Periodic check timeout' + ); }); }); });