handle user renames
This commit is contained in:
@@ -395,9 +395,9 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (typeof(idx) !== 'undefined') {
|
if (typeof(idx) !== 'undefined') {
|
||||||
console.error('found old message at %s', idx);
|
//console.error('found old message at %s', idx);
|
||||||
} else {
|
} else {
|
||||||
console.error("did not find desired message");
|
//console.error("did not find desired message");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO improve performance
|
// TODO improve performance
|
||||||
@@ -439,9 +439,8 @@ define([
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (parsedMsg[0] === Types.update) {
|
if (parsedMsg[0] === Types.update) {
|
||||||
// TODO emit update event
|
|
||||||
|
|
||||||
if (parsedMsg[1] === proxy.curvePublic) { return; }
|
if (parsedMsg[1] === proxy.curvePublic) { return; }
|
||||||
|
var curvePublic = parsedMsg[1];
|
||||||
var newdata = parsedMsg[3];
|
var newdata = parsedMsg[3];
|
||||||
var data = getFriend(proxy, parsedMsg[1]);
|
var data = getFriend(proxy, parsedMsg[1]);
|
||||||
var types = [];
|
var types = [];
|
||||||
@@ -451,13 +450,19 @@ define([
|
|||||||
data[k] = newdata[k];
|
data[k] = newdata[k];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//channel.updateUI(types);
|
|
||||||
|
eachHandler('update', function (f) {
|
||||||
|
f(clone(newdata), curvePublic);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsedMsg[0] === Types.unfriend) {
|
if (parsedMsg[0] === Types.unfriend) {
|
||||||
|
console.log('UNFRIEND');
|
||||||
removeFromFriendList(proxy, realtime, channel.friendEd, function () {
|
removeFromFriendList(proxy, realtime, channel.friendEd, function () {
|
||||||
channel.wc.leave(Types.unfriend);
|
channel.wc.leave(Types.unfriend);
|
||||||
//channel.removeUI();
|
//channel.removeUI();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -483,6 +488,9 @@ define([
|
|||||||
channel.wc.bcast(cryptMsg).then(function () {
|
channel.wc.bcast(cryptMsg).then(function () {
|
||||||
// TODO send event
|
// TODO send event
|
||||||
//channel.refresh();
|
//channel.refresh();
|
||||||
|
eachHandler('update', function (f) {
|
||||||
|
f(myData, myData.curvePublic);
|
||||||
|
});
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ define([
|
|||||||
|
|
||||||
var m = function (md) {
|
var m = function (md) {
|
||||||
var d = h('div.content');
|
var d = h('div.content');
|
||||||
d.innerHTML = Marked(md || '');
|
try {
|
||||||
|
d.innerHTML = Marked(md || '');
|
||||||
|
} catch (e) {
|
||||||
|
console.error(md);
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
return d;
|
return d;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,7 +87,7 @@ define([
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
});
|
}, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
markup.chatbox = function (curvePublic, data) {
|
markup.chatbox = function (curvePublic, data) {
|
||||||
@@ -106,6 +111,11 @@ define([
|
|||||||
fetching = false;
|
fetching = false;
|
||||||
if (e) { return void console.error(e); }
|
if (e) { return void console.error(e); }
|
||||||
history.forEach(function (msg) {
|
history.forEach(function (msg) {
|
||||||
|
if (msg.type !== 'MSG') {
|
||||||
|
// handle other types of messages?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
channel.messages.unshift(msg);
|
channel.messages.unshift(msg);
|
||||||
var el_message = markup.message(msg);
|
var el_message = markup.message(msg);
|
||||||
$messagebox.prepend(el_message);
|
$messagebox.prepend(el_message);
|
||||||
@@ -386,7 +396,15 @@ define([
|
|||||||
|
|
||||||
// change in your friend list
|
// change in your friend list
|
||||||
messenger.on('update', function (info, curvePublic) {
|
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 () {
|
Cryptpad.onDisplayNameChanged(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user