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.addMessage(message, true);
contact.lockedResource = msg.from.full; contact.lockedResource = msg.from.full;
} }
@ -262,6 +263,7 @@ module.exports = function (client, app) {
} }
var message = new Message(msg); var message = new Message(msg);
message.acked = true;
contact.addMessage(message, true); contact.addMessage(message, true);
} }
}); });
@ -278,7 +280,7 @@ module.exports = function (client, app) {
original.correct(msg); original.correct(msg);
}); });
client.on('carbon:received', function (carbon) { client.on('carbon:received', function (carbon) {
if (!me.isMe(carbon.from)) return; if (!me.isMe(carbon.from)) return;
@ -317,4 +319,16 @@ module.exports = function (client, app) {
discoCapsQueue.push(pres); 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) { results.forEach(function (result) {
result = result.toJSON(); result = result.toJSON();
var msg = result.mam.forwarded.message; var msg = result.mam.forwarded.message;
if (!msg.id) { if (!msg.id) {
msg.id = uuid.v4(); msg.id = uuid.v4();
} }
@ -221,6 +221,7 @@ module.exports = HumanModel.define({
var message = new Message(msg); var message = new Message(msg);
message.archivedId = result.mam.id; message.archivedId = result.mam.id;
message.acked = true;
self.addMessage(message, false); self.addMessage(message, false);
}); });

View File

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

View File

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

View File

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

View File

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

View File

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