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) => { onOk: async (newName) => {
// Update our profiles accordingly' // Update our profiles accordingly'
const trimmed = newName && newName.trim(); 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)) { if (_.isEmpty(trimmed)) {
await storage.removeLocalProfile(); delete newProfile.name;
} else { } else {
newProfile = { newProfile.name = {
...(profile || {}), displayName: trimmed,
name: { }
displayName: trimmed,
},
};
await storage.saveLocalProfile(newProfile);
} }
await storage.saveLocalProfile(newProfile);
appView.inboxView.trigger('updateProfile'); appView.inboxView.trigger('updateProfile');
// Update the conversation if we have it // Update the conversation if we have it

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

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

Loading…
Cancel
Save