mirror of
https://github.com/lux-tel/session-desktop.git
synced 2026-10-30 20:33:24 +00:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { ContentMessageNoProfile } from '..';
|
|
import { Constants } from '../../..';
|
|
import { SignalService } from '../../../../protobuf';
|
|
import { MessageParams } from '../Message';
|
|
|
|
type TypingMessageParams = MessageParams & {
|
|
isTyping: boolean;
|
|
};
|
|
|
|
export class TypingMessage extends ContentMessageNoProfile {
|
|
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 override contentProto(): SignalService.Content {
|
|
// Note: typing messages are not disappearing messages
|
|
const content = super.makeNonDisappearingContentProto();
|
|
|
|
const typingMessage = new SignalService.TypingMessage();
|
|
typingMessage.action = this.isTyping
|
|
? SignalService.TypingMessage.Action.STARTED
|
|
: SignalService.TypingMessage.Action.STOPPED;
|
|
typingMessage.timestamp = this.createAtNetworkTimestamp;
|
|
|
|
content.typingMessage = typingMessage;
|
|
|
|
return content;
|
|
}
|
|
}
|