use undefined or ? rather than null

pull/1151/head
Audric Ackermann 5 years ago
parent cb74c9fe1d
commit 2acba52933
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -5,14 +5,14 @@ import { MessageParams } from '../Message';
interface TypingMessageParams extends MessageParams {
isTyping: boolean;
typingTimestamp: number | null;
groupId: string | null;
typingTimestamp?: number;
groupId?: string;
}
export class TypingMessage extends ContentMessage {
private readonly isTyping: boolean;
private readonly typingTimestamp: number | null;
private readonly groupId: string | null;
private readonly typingTimestamp?: number;
private readonly groupId?: string;
constructor(params: TypingMessageParams) {
super({timestamp: params.timestamp, identifier: params.identifier});

@ -11,7 +11,7 @@ export class DeviceLinkGrantMessage extends DeviceLinkRequestMessage {
private readonly displayName: string;
private readonly avatarPointer: string;
private readonly profileKey: Uint8Array;
private readonly grantSignature: Uint8Array | null;
private readonly grantSignature: Uint8Array;
constructor(params: DeviceLinkGrantMessageParams
) {
@ -38,7 +38,7 @@ export class DeviceLinkGrantMessage extends DeviceLinkRequestMessage {
});
}
protected getDataMessage(): SignalService.DataMessage | null {
protected getDataMessage(): SignalService.DataMessage | undefined {
// Send profile name to secondary device and avatarPointer
const profile = new SignalService.DataMessage.LokiProfile();
profile.avatar = this.avatarPointer;

@ -24,8 +24,8 @@ export class DeviceLinkRequestMessage extends ContentMessage {
return 2 * 60 * 1000; // 2 minutes for pairing requests
}
protected getDataMessage(): SignalService.DataMessage | null {
return null;
protected getDataMessage(): SignalService.DataMessage | undefined {
return undefined;
}
protected getPairingAuthorisationMessage(): SignalService.PairingAuthorisationMessage {
@ -40,7 +40,7 @@ export class DeviceLinkRequestMessage extends ContentMessage {
protected contentProto(): SignalService.Content {
return new SignalService.Content({
pairingAuthorisation: this.getPairingAuthorisationMessage(),
dataMessage: this.getDataMessage() || null,
dataMessage: this.getDataMessage(),
});
}
}

@ -10,8 +10,6 @@ describe('TypingMessage', () => {
timestamp: Date.now(),
identifier: '123456',
isTyping: true,
typingTimestamp: null,
groupId: null,
});
const plainText = message.plainTextBuffer();
const decoded = SignalService.Content.toObject(SignalService.Content.decode(plainText));
@ -23,8 +21,6 @@ describe('TypingMessage', () => {
timestamp: Date.now(),
identifier: '123456',
isTyping: false,
typingTimestamp: null,
groupId: null,
});
const plainText = message.plainTextBuffer();
const decoded = SignalService.Content.toObject(SignalService.Content.decode(plainText));
@ -37,7 +33,6 @@ describe('TypingMessage', () => {
identifier: '123456',
isTyping: true,
typingTimestamp: 111111111,
groupId: null,
});
const plainText = message.plainTextBuffer();
const decoded = SignalService.Content.toObject(SignalService.Content.decode(plainText));
@ -50,8 +45,6 @@ describe('TypingMessage', () => {
timestamp: Date.now(),
identifier: '123456',
isTyping: true,
typingTimestamp: null,
groupId: null,
});
const plainText = message.plainTextBuffer();
const decoded = SignalService.Content.toObject(SignalService.Content.decode(plainText));
@ -65,7 +58,6 @@ describe('TypingMessage', () => {
timestamp: Date.now(),
identifier: '123456',
isTyping: true,
typingTimestamp: null,
groupId,
});
const plainText = message.plainTextBuffer();
@ -80,8 +72,6 @@ describe('TypingMessage', () => {
timestamp: Date.now(),
identifier: '123456',
isTyping: true,
typingTimestamp: null,
groupId: null,
});
expect(message.ttl()).to.equal(60 * 1000);
});

Loading…
Cancel
Save