Merge pull request #1241 from Bilb/fix-our-profile-picture-change

pull/1248/head
Audric Ackermann 5 years ago committed by GitHub
commit edc34649a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2720,7 +2720,7 @@
const ourConversation = window.ConversationController.get(ourNumber);
let profileKey = null;
if (this.get('profileSharing')) {
profileKey = storage.get('profileKey');
profileKey = new Uint8Array(storage.get('profileKey'));
}
const avatarPointer = ourConversation.get('avatarPointer');
const { displayName } = ourConversation.getLokiProfile();

@ -553,7 +553,7 @@
timestamp: Date.now(),
primaryDevicePubKey,
secondaryDevicePubKey: ourPubKey,
requestSignature,
requestSignature: new Uint8Array(requestSignature),
}
);
await window.libsession
@ -616,14 +616,7 @@
);
// We need to send the our profile to the secondary device
const { displayName } = ourConversation.getLokiProfile();
const avatarPointer = ourConversation.get('avatarPointer');
const profileKey = window.storage.get('profileKey');
const lokiProfile = {
displayName,
profileKey,
avatarPointer,
};
const lokiProfile = ourConversation.getOurProfile();
// Try to upload to the file server and then send a message
try {
@ -631,7 +624,10 @@
const requestPairingMessage = new libsession.Messages.Outgoing.DeviceLinkGrantMessage(
{
timestamp: Date.now(),
...authorisation,
primaryDevicePubKey: ourPubKey,
secondaryDevicePubKey: secondaryDeviceStr,
requestSignature: new Uint8Array(requestSignature),
grantSignature: new Uint8Array(grantSignature),
lokiProfile,
}
);

@ -262,14 +262,6 @@ export class DevicePairingDialog extends React.Component<Props, State> {
private requestReceived(secondaryDevicePubKey: string | EventHandlerNonNull) {
// FIFO: push at the front of the array with unshift()
this.state.pubKeyRequests.unshift(secondaryDevicePubKey);
window.pushToast({
title: window.i18n('gotPairingRequest'),
description: `${window.shortenPubkey(
secondaryDevicePubKey
)} ${window.i18n(
'showPairingWordsTitle'
)}: ${window.mnemonic.pubkey_to_secret_words(secondaryDevicePubKey)}`,
});
if (!this.state.currentPubKey) {
this.nextPubKey();
this.stopReceivingRequests();

@ -337,7 +337,7 @@ export class EditProfileDialog extends React.Component<Props, State> {
setProfileName: this.state.profileName,
},
() => {
// Update settinngs in dialog complete;
// Update settings in dialog complete;
// now callback to reloadactions panel avatar
this.props.callback(this.state.avatar);
}

@ -24,6 +24,7 @@ interface Props {
}
export class ActionsPanel extends React.Component<Props, State> {
private ourConversation: any;
constructor(props: Props) {
super(props);
this.state = {
@ -31,6 +32,7 @@ export class ActionsPanel extends React.Component<Props, State> {
};
this.editProfileHandle = this.editProfileHandle.bind(this);
this.refreshAvatarCallback = this.refreshAvatarCallback.bind(this);
}
public componentDidMount() {
@ -42,10 +44,36 @@ export class ActionsPanel extends React.Component<Props, State> {
this.setState({
avatarPath: conversation.getAvatarPath(),
});
// When our primary device updates its avatar, we will need for a message sync to know about that.
// Once we get the avatar update, we need to refresh this react component.
// So we listen to changes on our profile avatar and use the updated avatarPath (done on message received).
this.ourConversation = conversation;
this.ourConversation.on(
'change',
() => {
this.refreshAvatarCallback(this.ourConversation);
},
'refreshAvatarCallback'
);
}
);
}
public refreshAvatarCallback(conversation: any) {
if (conversation.changed?.profileAvatar) {
this.setState({
avatarPath: conversation.getAvatarPath(),
});
}
}
public componentWillUnmount() {
if (this.ourConversation) {
this.ourConversation.off('change', null, 'refreshAvatarCallback');
}
}
public Section = ({
isSelected,
onSelect,

@ -25,6 +25,13 @@ export class DeviceLinkGrantMessage extends DeviceLinkRequestMessage {
requestSignature: params.requestSignature,
});
if (!(params.lokiProfile.profileKey instanceof Uint8Array)) {
throw new TypeError('profileKey must be of type Uint8Array');
}
if (!(params.grantSignature instanceof Uint8Array)) {
throw new TypeError('grantSignature must be of type Uint8Array');
}
this.displayName = params.lokiProfile.displayName;
this.avatarPointer = params.lokiProfile.avatarPointer;
this.profileKey = params.lokiProfile.profileKey;

@ -15,6 +15,16 @@ export class DeviceLinkRequestMessage extends ContentMessage {
constructor(params: DeviceLinkMessageParams) {
super({ timestamp: params.timestamp, identifier: params.identifier });
if (!(params.requestSignature instanceof Uint8Array)) {
throw new TypeError('requestSignature must be of type Uint8Array');
}
if (typeof params.primaryDevicePubKey !== 'string') {
throw new TypeError('primaryDevicePubKey must be of type string');
}
if (typeof params.secondaryDevicePubKey !== 'string') {
throw new TypeError('secondaryDevicePubKey must be of type string');
}
this.primaryDevicePubKey = params.primaryDevicePubKey;
this.secondaryDevicePubKey = params.secondaryDevicePubKey;
this.requestSignature = params.requestSignature;

Loading…
Cancel
Save