Sort messages by sent_at
This commit is contained in:
parent
5710c410c7
commit
033492a200
|
@ -2339,6 +2339,7 @@ async function getUnreadByConversation(conversationId) {
|
|||
return map(rows, row => jsonToObject(row.json));
|
||||
}
|
||||
|
||||
// Note: Sorting here is necessary for getting the last message (with limit 1)
|
||||
async function getMessagesByConversation(
|
||||
conversationId,
|
||||
{ limit = 100, receivedAt = Number.MAX_VALUE, type = '%' } = {}
|
||||
|
@ -2349,7 +2350,7 @@ async function getMessagesByConversation(
|
|||
conversationId = $conversationId AND
|
||||
received_at < $received_at AND
|
||||
type LIKE $type
|
||||
ORDER BY received_at DESC
|
||||
ORDER BY sent_at DESC
|
||||
LIMIT $limit;
|
||||
`,
|
||||
{
|
||||
|
|
|
@ -2514,11 +2514,11 @@
|
|||
Whisper.MessageCollection = Backbone.Collection.extend({
|
||||
model: Whisper.Message,
|
||||
comparator(left, right) {
|
||||
if (left.get('received_at') === right.get('received_at')) {
|
||||
return (left.get('sent_at') || 0) - (right.get('sent_at') || 0);
|
||||
if (left.get('sent_at') === right.get('sent_at')) {
|
||||
return (left.get('received_at') || 0) - (right.get('received_at') || 0);
|
||||
}
|
||||
|
||||
return (left.get('received_at') || 0) - (right.get('received_at') || 0);
|
||||
return (left.get('sent_at') || 0) - (right.get('sent_at') || 0);
|
||||
},
|
||||
initialize(models, options) {
|
||||
if (options) {
|
||||
|
|
|
@ -226,9 +226,12 @@
|
|||
// Send
|
||||
const options = { messageType: 'pairing-request' };
|
||||
const p = new Promise((resolve, reject) => {
|
||||
|
||||
const timestamp = Date.now();
|
||||
|
||||
const outgoingMessage = new textsecure.OutgoingMessage(
|
||||
null, // server
|
||||
Date.now(), // timestamp,
|
||||
timestamp,
|
||||
[recipientPubKey], // numbers
|
||||
content, // message
|
||||
true, // silent
|
||||
|
|
Loading…
Reference in New Issue