telepathyClient: fix duplicate copy of first message in a chat
The chat-history-fill-in code had logic to avoid appending two messages when a message appeared in both the log and the pending messages. But it wasn't working because of an incorrect object field name. Additionally, the code was previously keeping the copy of the message from the log, and suppressing the copy from pending. But that meant that once the previous bug was fixed, it would think it had only shown old messages, and so it would create a source but not notify it. So fix it to suppress the log message and show the pending message. https://bugzilla.gnome.org/show_bug.cgi?id=645612
This commit is contained in:
parent
9b4dbd0e83
commit
d2de0865bf
@ -245,36 +245,35 @@ Source.prototype = {
|
|||||||
let [success, events] = logManager.get_filtered_events_finish(result);
|
let [success, events] = logManager.get_filtered_events_finish(result);
|
||||||
|
|
||||||
let logMessages = events.map(makeMessageFromTplEvent);
|
let logMessages = events.map(makeMessageFromTplEvent);
|
||||||
|
|
||||||
|
let pendingTpMessages = this._channel.get_pending_messages();
|
||||||
|
let pendingMessages = pendingTpMessages.map(function (tpMessage) { return makeMessageFromTpMessage(tpMessage, NotificationDirection.RECEIVED); });
|
||||||
|
|
||||||
for (let i = 0; i < logMessages.length; i++) {
|
for (let i = 0; i < logMessages.length; i++) {
|
||||||
this._notification.appendMessage(logMessages[i], true);
|
let logMessage = logMessages[i];
|
||||||
}
|
let isPending = false;
|
||||||
|
|
||||||
let pendingMessages = this._channel.get_pending_messages();
|
// Skip any log messages that are also in pendingMessages
|
||||||
let hasPendingMessage = false;
|
for (let j = 0; j < pendingMessages.length; j++) {
|
||||||
for (let i = 0; i < pendingMessages.length; i++) {
|
let pending = pendingMessages[j];
|
||||||
let message = makeMessageFromTpMessage(pendingMessages[i], NotificationDirection.RECEIVED);
|
if (logMessage.timestamp == pending.timestamp && logMessage.text == pending.text) {
|
||||||
|
isPending = true;
|
||||||
// Skip any pending messages that are in the logs.
|
break;
|
||||||
let inLog = false;
|
|
||||||
for (let j = 0; j < logMessages.length; j++) {
|
|
||||||
let logMessage = logMessages[j];
|
|
||||||
if (logMessage.timestamp == message.timestamp && logMessage.text == message.body) {
|
|
||||||
inLog = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inLog)
|
if (!isPending)
|
||||||
continue;
|
this._notification.appendMessage(logMessage, true);
|
||||||
|
|
||||||
this._notification.appendMessage(message, true);
|
|
||||||
hasPendingMessage = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < pendingMessages.length; i++)
|
||||||
|
this._notification.appendMessage(pendingMessages[i], true);
|
||||||
|
|
||||||
// Only show the timestamp if we have at least one message.
|
// Only show the timestamp if we have at least one message.
|
||||||
if (hasPendingMessage || logMessages.length > 0)
|
if (pendingMessages.length > 0 || logMessages.length > 0)
|
||||||
this._notification.appendTimestamp();
|
this._notification.appendTimestamp();
|
||||||
|
|
||||||
if (hasPendingMessage)
|
if (pendingMessages.length > 0)
|
||||||
this.notify();
|
this.notify();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user