You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/ts/session/messages/outgoing/controlMessage/TypingMessage.ts

41 lines
1.1 KiB
TypeScript

import { ContentMessage } from '..';
import { Constants } from '../../..';
import { SignalService } from '../../../../protobuf';
import { MessageParams } from '../Message';
interface TypingMessageParams extends MessageParams {
isTyping: boolean;
}
export class TypingMessage extends ContentMessage {
public readonly isTyping: boolean;
constructor(params: TypingMessageParams) {
super({
createAtNetworkTimestamp: params.createAtNetworkTimestamp,
identifier: params.identifier,
});
this.isTyping = params.isTyping;
}
public ttl(): number {
return Constants.TTL_DEFAULT.TYPING_MESSAGE;
}
public contentProto(): SignalService.Content {
return super.makeContentProto({ typingMessage: this.typingProto() });
}
protected typingProto(): SignalService.TypingMessage {
const action = this.isTyping
? SignalService.TypingMessage.Action.STARTED
: SignalService.TypingMessage.Action.STOPPED;
const typingMessage = new SignalService.TypingMessage();
typingMessage.action = action;
typingMessage.timestamp = this.createAtNetworkTimestamp;
return typingMessage;
}
}