review PR

This commit is contained in:
Audric Ackermann 2021-02-10 10:31:48 +11:00
parent 8eb1507fcf
commit 850233bc9e
6 changed files with 22 additions and 19 deletions

View file

@ -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,
});
}

View file

@ -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<any>;
export function getUnreadCountByConversation(
conversationId: string,
{ MessageCollection }?: any
conversationId: string
): Promise<any>;
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<window.models.Message.MessageCollection>;
): Promise<MessageCollection>;
export function getMessageIdsFromServerIds(
serverIds: any,
conversationId: any

View file

@ -98,7 +98,7 @@ const sendMessageStyle = {
input: {
overflow: 'auto',
maxHeight: 70,
wordBreak: 'break-all',
wordBreak: 'break-word',
padding: '0px',
margin: '0px',
},

View file

@ -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)
);

View file

@ -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);
});
});
});

View file

@ -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'
);
});
});
});