1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-22 17:22:22 -05:00

Add and track pending state for messages.

This commit is contained in:
Lance Stout 2013-09-24 02:05:10 -07:00
parent dc1b55ed60
commit 3924bdd74f
8 changed files with 34 additions and 15 deletions

View File

@ -248,6 +248,7 @@ module.exports = function (client, app) {
});
}
message.acked = true;
contact.addMessage(message, true);
contact.lockedResource = msg.from.full;
}
@ -262,6 +263,7 @@ module.exports = function (client, app) {
}
var message = new Message(msg);
message.acked = true;
contact.addMessage(message, true);
}
});
@ -278,7 +280,7 @@ module.exports = function (client, app) {
original.correct(msg);
});
client.on('carbon:received', function (carbon) {
if (!me.isMe(carbon.from)) return;
@ -317,4 +319,16 @@ module.exports = function (client, app) {
discoCapsQueue.push(pres);
}
});
client.on('stanza:acked', function (stanza) {
if (stanza.body) {
var contact = me.getContact(stanza.to, stanza.from);
if (contact) {
var msg = contact.messages.get(stanza.id);
if (msg) {
msg.acked = true;
}
}
}
});
};

File diff suppressed because one or more lines are too long

View File

@ -201,7 +201,7 @@ module.exports = HumanModel.define({
results.forEach(function (result) {
result = result.toJSON();
var msg = result.mam.forwarded.message;
if (!msg.id) {
msg.id = uuid.v4();
}
@ -221,6 +221,7 @@ module.exports = HumanModel.define({
var message = new Message(msg);
message.archivedId = result.mam.id;
message.acked = true;
self.addMessage(message, false);
});

View File

@ -45,6 +45,7 @@ module.exports = HumanModel.define({
deps: ['created'],
fn: function () {
if (this.created) {
console.log(this.created);
var month = this.created.getMonth();
var day = this.created.getDate();
var hour = this.created.getHours();
@ -59,6 +60,12 @@ module.exports = HumanModel.define({
}
return undefined;
}
},
pending: {
deps: ['acked'],
fn: function () {
return !this.acked;
}
}
},
session: {
@ -71,7 +78,7 @@ module.exports = HumanModel.define({
if (this.from.full !== msg.from.full) return false;
delete msg.id;
this.set(msg);
this._created = Date.now();
this.edited = true;

View File

@ -6,14 +6,5 @@ var Message = require('./message');
module.exports = BaseCollection.extend({
type: 'messages',
model: Message,
comparator: function (msg1, msg2) {
if (msg1.created < msg2.created) {
return -1;
}
if (msg1.created > msg2.created) {
return 1;
}
return 0;
}
model: Message
});

View File

@ -14,7 +14,7 @@ module.exports = HumanView.extend({
classBindings: {
mine: '.message',
receiptReceived: '.message',
acked: '.message',
pending: '.message',
delayed: '.message',
edited: '.message'
},

View File

@ -108,6 +108,9 @@
.timestamp:before
content: 'edited '
&.pending
background-color: red
.body
display: inline
word-break: break-word

View File

@ -723,6 +723,9 @@ h4 {
.messages .message.edited .timestamp:before {
content: 'edited ';
}
.messages .message.pending {
background-color: #f00;
}
.messages .message .body {
display: inline;
word-break: break-word;