remove typing indicator when we get a dataMessage

This commit is contained in:
Audric Ackermann 2021-01-18 11:53:35 +11:00
parent 72c96ea998
commit 21c62c167e
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4
8 changed files with 19 additions and 27 deletions

View File

@ -469,10 +469,6 @@
await window.Signal.Data.removeMessage(message.id, {
Message: Whisper.Message,
});
const conversation = message.getConversation();
if (conversation) {
await conversation.updateLastMessage();
}
})
);
window.log.info('Cleanup: complete');

View File

@ -93,7 +93,9 @@ export interface ConversationModel
block: any;
copyPublicKey: any;
getAvatar: any;
notifyTyping: any;
notifyTyping: (
{ isTyping, sender } = { isTyping: boolean, sender: string }
) => any;
setSecondaryStatus: any;
queueJob: any;
onUpdateGroupName: any;

View File

@ -1801,9 +1801,7 @@
})
);
},
notifyTyping(options = {}) {
const { isTyping, sender, senderDevice } = options;
notifyTyping({ isTyping, sender }) {
// We don't do anything with typing messages from our other devices
if (sender === this.ourNumber) {
return;
@ -1826,10 +1824,8 @@
}
}
const identifier = `${sender}.${senderDevice}`;
this.contactTypingTimers = this.contactTypingTimers || {};
const record = this.contactTypingTimers[identifier];
const record = this.contactTypingTimers[sender];
if (record) {
clearTimeout(record.timer);
@ -1840,16 +1836,13 @@
// 'change' causes a re-render of this conversation's list item in the left pane
if (isTyping) {
this.contactTypingTimers[identifier] = this.contactTypingTimers[
identifier
] || {
this.contactTypingTimers[sender] = this.contactTypingTimers[sender] || {
timestamp: Date.now(),
sender,
senderDevice,
};
this.contactTypingTimers[identifier].timer = setTimeout(
this.clearContactTypingTimer.bind(this, identifier),
this.contactTypingTimers[sender].timer = setTimeout(
this.clearContactTypingTimer.bind(this, sender),
15 * 1000
);
if (!record) {
@ -1858,7 +1851,7 @@
this.commit();
}
} else {
delete this.contactTypingTimers[identifier];
delete this.contactTypingTimers[sender];
if (record) {
// User was previously typing, and is no longer. State change!
this.trigger('typing-update');
@ -1867,13 +1860,13 @@
}
},
clearContactTypingTimer(identifier) {
clearContactTypingTimer(sender) {
this.contactTypingTimers = this.contactTypingTimers || {};
const record = this.contactTypingTimers[identifier];
const record = this.contactTypingTimers[sender];
if (record) {
clearTimeout(record.timer);
delete this.contactTypingTimers[identifier];
delete this.contactTypingTimers[sender];
// User was previously typing, but timed out or we received message. State change!
this.trigger('typing-update');

View File

@ -3,7 +3,6 @@
dcodeIO,
Backbone,
_,
libsignal,
textsecure,
stringObject,
BlockedNumberController

View File

@ -15,7 +15,6 @@
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="components.js"></script>
<script type="text/javascript" src="../../libtextsecure/test/in_memory_signal_protocol_store.js"></script>
<script type="text/javascript" src="../../libloki/proof-of-work.js"></script>
<script type="text/javascript" src="../../libtextsecure/helpers.js" data-cover></script>
<script type="text/javascript" src="../../libtextsecure/storage.js" data-cover></script>

View File

@ -14,7 +14,6 @@
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="in_memory_signal_protocol_store.js"></script>
<script type="text/javascript" src="../components.js"></script>
<script type="text/javascript" src="../libsignal-protocol.js"></script>

View File

@ -511,7 +511,7 @@ async function handleTypingMessage(
const typingMessage = iTypingMessage as SignalService.TypingMessage;
const { timestamp, groupId, action } = typingMessage;
const { timestamp, action } = typingMessage;
const { source } = envelope;
await removeFromCache(envelope);
@ -548,11 +548,9 @@ async function handleTypingMessage(
const started = action === SignalService.TypingMessage.Action.STARTED;
if (conversation) {
const senderDevice = 1;
conversation.notifyTyping({
isTyping: started,
sender: source,
senderDevice,
});
}
}

View File

@ -458,6 +458,12 @@ async function handleRegularMessage(
if (source !== ourNumber && primarySource) {
message.set({ source: primarySource.key });
}
// we just received a message from that user so we reset the typing indicator for this convo
conversation.notifyTyping({
isTyping: false,
sender: primarySource.key,
});
}
async function handleExpirationTimerUpdate(