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) => {
const isSecondaryDevice = !!textsecure.storage.get('isSecondaryDevice');
if (isSecondaryDevice) {
return;
}
await libloki.storage.removePairingAuthorisationForSecondaryPubKey(
pubKey
);

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

@ -321,9 +321,12 @@ export class LeftPaneContactSection extends React.Component<Props, State> {
private renderList() {
const { sentFriendsRequest } = this.props;
const friends = window.getFriendsFromContacts(this.props.friends);
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 = (
<div className="module-left-pane__list" key={0}>

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

@ -107,9 +107,9 @@ export const _getLeftPaneLists = (
const conversations: Array<ConversationType> = [];
const archivedConversations: Array<ConversationType> = [];
const friends: Array<ConversationType> = [];
const receivedFriendsRequest: Array<ConversationListItemPropsType> = [];
const sentFriendsRequest: Array<ConversationListItemPropsType> = [];
const allFriends: Array<ConversationType> = [];
const allReceivedFriendsRequest: Array<ConversationListItemPropsType> = [];
const allSentFriendsRequest: Array<ConversationListItemPropsType> = [];
const max = sorted.length;
let unreadCount = 0;
@ -125,11 +125,11 @@ export const _getLeftPaneLists = (
}
if (conversation.isFriend && conversation.activeAt !== undefined) {
friends.push(conversation);
allFriends.push(conversation);
}
if (conversation.hasReceivedFriendRequest) {
receivedFriendsRequest.push(conversation);
allReceivedFriendsRequest.push(conversation);
} else if (
unreadCount < 9 &&
conversation.isFriend &&
@ -138,7 +138,7 @@ export const _getLeftPaneLists = (
unreadCount += conversation.unreadCount;
}
if (conversation.hasSentFriendRequest) {
sentFriendsRequest.push(conversation);
allSentFriendsRequest.push(conversation);
}
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 {
conversations,
archivedConversations,

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

Loading…
Cancel
Save