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; return Msg;
}); });

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

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

Loading…
Cancel
Save