|
|
@ -162,8 +162,16 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var parsedMsg = JSON.parse(msg);
|
|
|
|
var parsedMsg = JSON.parse(msg);
|
|
|
|
if (parsedMsg[0] === Types.message) {
|
|
|
|
if (parsedMsg[0] === Types.message) {
|
|
|
|
parsedMsg.shift();
|
|
|
|
// TODO validate messages here
|
|
|
|
channel.messages.push([sig, parsedMsg]);
|
|
|
|
var res = {
|
|
|
|
|
|
|
|
type: parsedMsg[0], //Types.message,
|
|
|
|
|
|
|
|
sig: sig,
|
|
|
|
|
|
|
|
channel: parsedMsg[1],
|
|
|
|
|
|
|
|
time: parsedMsg[2],
|
|
|
|
|
|
|
|
text: parsedMsg[3],
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
channel.messages.push(res);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var proxy;
|
|
|
|
var proxy;
|
|
|
@ -493,24 +501,22 @@ define([
|
|
|
|
var $msg, msg, date, name;
|
|
|
|
var $msg, msg, date, name;
|
|
|
|
var last = typeof(channel.lastDisplayed) === 'number'? channel.lastDisplayed: -1;
|
|
|
|
var last = typeof(channel.lastDisplayed) === 'number'? channel.lastDisplayed: -1;
|
|
|
|
for (var i = last + 1; i<messages.length; i++) {
|
|
|
|
for (var i = last + 1; i<messages.length; i++) {
|
|
|
|
msg = messages[i][1]; // 0 is the hash, 1 the array
|
|
|
|
msg = messages[i];
|
|
|
|
$msg = $('<div>', {'class': 'message'}).appendTo($messages);
|
|
|
|
$msg = $('<div>', {'class': 'message'}).appendTo($messages);
|
|
|
|
|
|
|
|
|
|
|
|
// date
|
|
|
|
// date
|
|
|
|
date = msg[1] ? new Date(msg[1]).toLocaleString() : '?';
|
|
|
|
date = msg.time ? new Date(msg.time).toLocaleString(): '?';
|
|
|
|
//$('<div>', {'class':'date'}).text(date).appendTo($msg);
|
|
|
|
//$('<div>', {'class':'date'}).text(date).appendTo($msg);
|
|
|
|
$msg.attr('title', date);
|
|
|
|
$msg.attr('title', date);
|
|
|
|
|
|
|
|
|
|
|
|
// name
|
|
|
|
// name
|
|
|
|
if (msg[0] !== channel.lastSender) {
|
|
|
|
if (msg.channel !== channel.lastSender) {
|
|
|
|
name = getFriend(common, msg[0]).displayName;
|
|
|
|
name = getFriend(common, msg.channel).displayName;
|
|
|
|
$('<div>', {'class':'sender'}).text(name).appendTo($msg);
|
|
|
|
$('<div>', {'class':'sender'}).text(name).appendTo($msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
channel.lastSender = msg[0];
|
|
|
|
channel.lastSender = msg.channel;
|
|
|
|
|
|
|
|
|
|
|
|
// content
|
|
|
|
$('<div>', {'class':'content'}).html(parseMessage(msg.text)).appendTo($msg);
|
|
|
|
//$('<div>', {'class':'content'}).text(msg[2]).appendTo($msg);
|
|
|
|
|
|
|
|
$('<div>', {'class':'content'}).html(parseMessage(msg[2])).appendTo($msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$messages.scrollTop($messages[0].scrollHeight);
|
|
|
|
$messages.scrollTop($messages[0].scrollHeight);
|
|
|
|
channel.lastDisplayed = i-1;
|
|
|
|
channel.lastDisplayed = i-1;
|
|
|
@ -518,7 +524,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
if (messages.length > 10) {
|
|
|
|
if (messages.length > 10) {
|
|
|
|
var lastKnownMsg = messages[messages.length - 11];
|
|
|
|
var lastKnownMsg = messages[messages.length - 11];
|
|
|
|
data.lastKnownHash = lastKnownMsg[0];
|
|
|
|
channel.setLastMessageRead(lastKnownMsg.sig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// Display a new channel
|
|
|
|
// Display a new channel
|
|
|
@ -680,6 +686,9 @@ define([
|
|
|
|
removeUI: function () { removeUI(data.curvePublic); },
|
|
|
|
removeUI: function () { removeUI(data.curvePublic); },
|
|
|
|
updateUI: function (types) { updateUI(data.curvePublic, types); },
|
|
|
|
updateUI: function (types) { updateUI(data.curvePublic, types); },
|
|
|
|
updateStatus: function () { updateStatus(data.curvePublic); },
|
|
|
|
updateStatus: function () { updateStatus(data.curvePublic); },
|
|
|
|
|
|
|
|
setLastMessageRead: function (hash) {
|
|
|
|
|
|
|
|
data.lastKnownHash = hash;
|
|
|
|
|
|
|
|
},
|
|
|
|
getMessagesSinceDisconnect: function () {
|
|
|
|
getMessagesSinceDisconnect: function () {
|
|
|
|
getChannelMessagesSince(network, chan, data, keys);
|
|
|
|
getChannelMessagesSince(network, chan, data, keys);
|
|
|
|
},
|
|
|
|
},
|
|
|
|