Fix sending and receiving profile.

Don't delete profile after if we set the display name to empty.
pull/61/head
Mikunj 7 years ago
parent 610a305e23
commit 18d638fdbf

@ -580,19 +580,19 @@
onOk: async (newName) => {
// Update our profiles accordingly'
const trimmed = newName && newName.trim();
let newProfile = null;
// If we get an empty name then unset the name property
// Otherwise update it
const newProfile = profile || {};
if (_.isEmpty(trimmed)) {
await storage.removeLocalProfile();
delete newProfile.name;
} else {
newProfile = {
...(profile || {}),
name: {
displayName: trimmed,
},
};
await storage.saveLocalProfile(newProfile);
newProfile.name = {
displayName: trimmed,
}
}
await storage.saveLocalProfile(newProfile);
appView.inboxView.trigger('updateProfile');
// Update the conversation if we have it

@ -918,7 +918,7 @@ MessageReceiver.prototype.extend({
p = this.handleEndSession(envelope.source);
}
return p.then(() =>
this.processDecrypted(envelope, msg, envelope.source).then(async message => {
this.processDecrypted(envelope, msg, envelope.source).then(message => {
const groupId = message.group && message.group.id;
const isBlocked = this.isGroupBlocked(groupId);
const isMe = envelope.source === textsecure.storage.user.getNumber();
@ -932,8 +932,7 @@ MessageReceiver.prototype.extend({
if (!isMe && conversation) {
let profile = null;
if (message.profile) {
const name = JSON.parse(message.profile.name.encodeJSON());
profile = { name };
profile = JSON.parse(message.profile.encodeJSON());
}
// Update the conversation

@ -135,7 +135,8 @@ Message.prototype = {
if (this.profile) {
const contact = new textsecure.protobuf.DataMessage.Contact();
contact.name = this.profile.name;
if (this.profile.name)
contact.name = this.profile.name;
proto.profile = contact;
}

Loading…
Cancel
Save