handle user renames

pull/1/head
ansuz 7 years ago
parent f9cdbe66a0
commit 22d754d514

@ -395,9 +395,9 @@ define([
});
if (typeof(idx) !== 'undefined') {
console.error('found old message at %s', idx);
//console.error('found old message at %s', idx);
} else {
console.error("did not find desired message");
//console.error("did not find desired message");
}
// TODO improve performance
@ -439,9 +439,8 @@ define([
return true;
}
if (parsedMsg[0] === Types.update) {
// TODO emit update event
if (parsedMsg[1] === proxy.curvePublic) { return; }
var curvePublic = parsedMsg[1];
var newdata = parsedMsg[3];
var data = getFriend(proxy, parsedMsg[1]);
var types = [];
@ -451,13 +450,19 @@ define([
data[k] = newdata[k];
}
});
//channel.updateUI(types);
eachHandler('update', function (f) {
f(clone(newdata), curvePublic);
});
return;
}
if (parsedMsg[0] === Types.unfriend) {
console.log('UNFRIEND');
removeFromFriendList(proxy, realtime, channel.friendEd, function () {
channel.wc.leave(Types.unfriend);
//channel.removeUI();
});
return;
}
@ -483,6 +488,9 @@ define([
channel.wc.bcast(cryptMsg).then(function () {
// TODO send event
//channel.refresh();
eachHandler('update', function (f) {
f(myData, myData.curvePublic);
});
}, function (err) {
console.error(err);
});

@ -13,7 +13,12 @@ define([
var m = function (md) {
var d = h('div.content');
d.innerHTML = Marked(md || '');
try {
d.innerHTML = Marked(md || '');
} catch (e) {
console.error(md);
console.error(e);
}
return d;
};
@ -82,7 +87,7 @@ define([
return a;
}
return b;
});
}, []);
};
markup.chatbox = function (curvePublic, data) {
@ -106,6 +111,11 @@ define([
fetching = false;
if (e) { return void console.error(e); }
history.forEach(function (msg) {
if (msg.type !== 'MSG') {
// handle other types of messages?
return;
}
channel.messages.unshift(msg);
var el_message = markup.message(msg);
$messagebox.prepend(el_message);
@ -386,7 +396,15 @@ define([
// change in your friend list
messenger.on('update', function (info, curvePublic) {
curvePublic = curvePublic;
console.log(info, curvePublic);
var name = displayNames[curvePublic] = info.displayName;
// update label in friend list
find.inList(curvePublic).find('.name').text(name);
// update title bar and messages
$messages.find(dataQuery(curvePublic) + ' .header .name, div.message'+
dataQuery(curvePublic) + ' div.sender').text(name).text(name);
});
Cryptpad.onDisplayNameChanged(function () {

Loading…
Cancel
Save