remove typing indicator when we get a dataMessage

pull/1434/head
Audric Ackermann 4 years ago
parent 72c96ea998
commit 21c62c167e
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

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

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

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

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

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

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

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

@ -458,6 +458,12 @@ async function handleRegularMessage(
if (source !== ourNumber && primarySource) { if (source !== ourNumber && primarySource) {
message.set({ source: primarySource.key }); 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( async function handleExpirationTimerUpdate(

Loading…
Cancel
Save