Merge pull request #1118 from vincentbavitz/fr-fixes

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

@ -1365,6 +1365,11 @@
}); });
Whisper.events.on('deviceUnpairingRequested', async (pubKey, callback) => { Whisper.events.on('deviceUnpairingRequested', async (pubKey, callback) => {
const isSecondaryDevice = !!textsecure.storage.get('isSecondaryDevice');
if (isSecondaryDevice) {
return;
}
await libloki.storage.removePairingAuthorisationForSecondaryPubKey( await libloki.storage.removePairingAuthorisationForSecondaryPubKey(
pubKey pubKey
); );

@ -607,6 +607,7 @@
hasSentFriendRequest: this.hasSentFriendRequest(), hasSentFriendRequest: this.hasSentFriendRequest(),
isBlocked: this.isBlocked(), isBlocked: this.isBlocked(),
isSecondary: !!this.get('secondaryStatus'), isSecondary: !!this.get('secondaryStatus'),
primaryDevice: this.getPrimaryDevicePubKey(),
phoneNumber: format(this.id, { phoneNumber: format(this.id, {
ourRegionCode: regionCode, ourRegionCode: regionCode,
}), }),

@ -321,9 +321,12 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
private renderList() { private renderList() {
const { sentFriendsRequest } = this.props; const { sentFriendsRequest } = this.props;
const friends = window.getFriendsFromContacts(this.props.friends); const friends = window.getFriendsFromContacts(this.props.friends);
const length = Number(sentFriendsRequest.length) + Number(friends.length); const length = Number(sentFriendsRequest.length) + Number(friends.length);
const combined = [...sentFriendsRequest, ...friends];
// Prevent where friends and send FR showing two entries
const combined = [...new Set([...sentFriendsRequest, ...friends])];
const list = ( const list = (
<div className="module-left-pane__list" key={0}> <div className="module-left-pane__list" key={0}>

@ -53,6 +53,8 @@ export type ConversationType = {
isSelected: boolean; isSelected: boolean;
isTyping: boolean; isTyping: boolean;
isFriend?: boolean; isFriend?: boolean;
isSecondary?: boolean;
primaryDevice: string;
hasReceivedFriendRequest?: boolean; hasReceivedFriendRequest?: boolean;
hasSentFriendRequest?: boolean; hasSentFriendRequest?: boolean;
}; };

@ -107,9 +107,9 @@ export const _getLeftPaneLists = (
const conversations: Array<ConversationType> = []; const conversations: Array<ConversationType> = [];
const archivedConversations: Array<ConversationType> = []; const archivedConversations: Array<ConversationType> = [];
const friends: Array<ConversationType> = []; const allFriends: Array<ConversationType> = [];
const receivedFriendsRequest: Array<ConversationListItemPropsType> = []; const allReceivedFriendsRequest: Array<ConversationListItemPropsType> = [];
const sentFriendsRequest: Array<ConversationListItemPropsType> = []; const allSentFriendsRequest: Array<ConversationListItemPropsType> = [];
const max = sorted.length; const max = sorted.length;
let unreadCount = 0; let unreadCount = 0;
@ -125,11 +125,11 @@ export const _getLeftPaneLists = (
} }
if (conversation.isFriend && conversation.activeAt !== undefined) { if (conversation.isFriend && conversation.activeAt !== undefined) {
friends.push(conversation); allFriends.push(conversation);
} }
if (conversation.hasReceivedFriendRequest) { if (conversation.hasReceivedFriendRequest) {
receivedFriendsRequest.push(conversation); allReceivedFriendsRequest.push(conversation);
} else if ( } else if (
unreadCount < 9 && unreadCount < 9 &&
conversation.isFriend && conversation.isFriend &&
@ -138,7 +138,7 @@ export const _getLeftPaneLists = (
unreadCount += conversation.unreadCount; unreadCount += conversation.unreadCount;
} }
if (conversation.hasSentFriendRequest) { if (conversation.hasSentFriendRequest) {
sentFriendsRequest.push(conversation); allSentFriendsRequest.push(conversation);
} }
if (!conversation.activeAt) { if (!conversation.activeAt) {
@ -152,6 +152,32 @@ export const _getLeftPaneLists = (
} }
} }
const filterToPrimary = (
group: Array<ConversationType | ConversationListItemPropsType>
) => {
// Used to ensure that only the primary device gets added to LeftPane filtered groups
const constructedGroup = conversations.filter(c =>
group.some(g => c.id === g.id)
);
// tslint:disable-next-line: no-unnecessary-local-variable
const filteredGroup = constructedGroup.filter(
(c, idx) =>
!(
c.isSecondary &&
constructedGroup.some(
g => !g.isSecondary && g.id === constructedGroup[idx].primaryDevice
)
)
);
return filteredGroup;
};
const friends = filterToPrimary(allFriends);
const receivedFriendsRequest = filterToPrimary(allReceivedFriendsRequest);
const sentFriendsRequest = filterToPrimary(allSentFriendsRequest);
return { return {
conversations, conversations,
archivedConversations, archivedConversations,

@ -19,6 +19,8 @@ describe('state/selectors/conversations', () => {
timestamp: 0, timestamp: 0,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id1',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -35,6 +37,8 @@ describe('state/selectors/conversations', () => {
timestamp: 20, timestamp: 20,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id2',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -51,6 +55,8 @@ describe('state/selectors/conversations', () => {
timestamp: 20, timestamp: 20,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id3',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -67,6 +73,8 @@ describe('state/selectors/conversations', () => {
timestamp: 20, timestamp: 20,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id4',
type: 'direct', type: 'direct',
isMe: false, isMe: false,
@ -83,6 +91,8 @@ describe('state/selectors/conversations', () => {
timestamp: 30, timestamp: 30,
phoneNumber: 'notused', phoneNumber: 'notused',
isArchived: false, isArchived: false,
isSecondary: false,
primaryDevice: 'id5',
type: 'direct', type: 'direct',
isMe: false, isMe: false,

Loading…
Cancel
Save