Update the friends when changing the username or avatar

pull/1/head
yflory 6 years ago
parent 250d9f3bc6
commit 9b5104c59e

@ -78,5 +78,27 @@ define([
});
};
Msg.updateMyData = function (store, curve) {
if (store.messenger) {
store.messenger.updateMyData();
}
var myData = createData(store.proxy);
var todo = function (friend) {
if (!friend || !friend.notifications) { return; }
myData.channel = friend.channel;
store.mailbox.sendTo('UPDATE_DATA', myData, {
channel: friend.notifications,
curvePublic: friend.curvePublic
}, function (obj) {
if (obj && obj.error) { console.error(obj); }
});
};
if (curve) {
var friend = getFriend(store.proxy, curve);
return void todo(friend);
}
eachFriend(store.proxy.friends || {}, todo);
};
return Msg;
});

@ -66,7 +66,7 @@ define([
}
broadcast([clientId], "UPDATE_METADATA");
if (Array.isArray(path) && path[0] === 'profile' && store.messenger) {
store.messenger.updateMyData();
Messaging.updateMyData(store);
}
onSync(cb);
};
@ -644,7 +644,7 @@ define([
}
store.proxy[Constants.displayNameKey] = value;
broadcast([clientId], "UPDATE_METADATA");
if (store.messenger) { store.messenger.updateMyData(); }
Messaging.updateMyData(store);
onSync(cb);
};

@ -152,6 +152,7 @@ define([
Object.keys(msg.content).forEach(function (key) {
friend[key] = msg.content[key];
});
ctx.updateMetadata();
cb(true);
};

Loading…
Cancel
Save