Merge pull request #580 from BeaudanBrown/is-secondary-device

isSecondary flag
pull/589/head
Beaudan Campbell-Brown 6 years ago committed by GitHub
commit 26a5b6c6fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1008,6 +1008,12 @@
"message": "Send a message",
"description": "Placeholder text in the message entry field"
},
"sendMessageDisabledSecondary": {
"message":
"This pubkey belongs to a secondary device. You should never see this message",
"description":
"Placeholder text in the message entry field when it is disabled because a secondary device conversation is visible"
},
"sendMessageDisabled": {
"message": "Waiting for friend request approval",
"description":

@ -469,6 +469,7 @@
mentionedUs: this.get('mentionedUs') || false,
showFriendRequestIndicator: this.isPendingFriendRequest(),
isBlocked: this.isBlocked(),
isSecondary: !!this.get('secondaryStatus'),
phoneNumber: format(this.id, {
ourRegionCode: regionCode,
@ -691,6 +692,17 @@
throw new Error('Invalid friend request state');
}
},
isSecondaryDevice() {
return !!this.get('secondaryStatus');
},
async setSecondaryStatus(newStatus) {
if (this.get('secondaryStatus') !== newStatus) {
this.set({ secondaryStatus: newStatus });
await window.Signal.Data.updateConversation(this.id, this.attributes, {
Conversation: Whisper.Conversation,
});
}
},
async setFriendRequestStatus(newStatus) {
// Ensure that the new status is a valid FriendStatusEnum value
if (!(newStatus in Object.values(FriendRequestStatusEnum))) {

@ -436,6 +436,9 @@
case 'disabled':
placeholder = i18n('sendMessageDisabled');
break;
case 'secondary':
placeholder = i18n('sendMessageDisabledSecondary');
break;
default:
placeholder = i18n('sendMessage');
break;

@ -155,7 +155,9 @@
},
user: {
regionCode: window.storage.get('regionCode'),
ourNumber: textsecure.storage.user.getNumber(),
ourNumber:
window.storage.get('primaryDevicePubKey') ||
textsecure.storage.user.getNumber(),
isSecondaryDevice: !!window.storage.get('isSecondaryDevice'),
i18n: window.i18n,
},

@ -157,8 +157,14 @@
);
}
function savePairingAuthorisation(authorisation) {
return window.Signal.Data.createOrUpdatePairingAuthorisation(authorisation);
async function savePairingAuthorisation(authorisation) {
// Ensure that we have a conversation for all the devices
const conversation = await ConversationController.getOrCreateAndWait(
authorisation.secondaryDevicePubKey,
'private'
);
await conversation.setSecondaryStatus(true);
await window.Signal.Data.createOrUpdatePairingAuthorisation(authorisation);
}
function removePairingAuthorisationForSecondaryPubKey(pubKey) {

@ -1107,6 +1107,7 @@ MessageReceiver.prototype.extend({
// along with each friend request.
window.storage.remove('secondaryDeviceStatus');
window.storage.put('isSecondaryDevice', true);
window.storage.put('primaryDevicePubKey', primaryDevicePubKey);
Whisper.events.trigger('secondaryDeviceRegistration');
// Update profile name
if (dataMessage && dataMessage.profile) {

@ -41,6 +41,7 @@ export type PropsData = {
isOnline?: boolean;
hasNickname?: boolean;
isFriendItem?: boolean;
isSecondary?: boolean;
};
type PropsHousekeeping = {

@ -55,7 +55,15 @@ export class LeftPane extends React.Component<Props, any> {
const { conversations, friends } = this.props;
const { currentTab } = this.state;
return currentTab === 'conversations' ? conversations : friends;
let conversationList =
currentTab === 'conversations' ? conversations : friends;
if (conversationList !== undefined) {
conversationList = conversationList.filter(
conversation => !conversation.isSecondary
);
}
return conversationList;
}
public renderTabs(): JSX.Element {

Loading…
Cancel
Save