fix: show note to self and outgoing message requests in contact list

pull/3137/head
yougotwill 1 year ago
parent 8260f0481b
commit f5951f911f

@ -6,12 +6,13 @@ import styled, { CSSProperties } from 'styled-components';
import {
DirectContactsByNameType,
getDirectContactsByName,
getDirectContactsCount,
getContactsCount,
} from '../../../../state/selectors/conversations';
import { leftPaneListWidth } from '../../LeftPane';
import { StyledLeftPaneList } from '../../LeftPaneList';
import { StyledChooseActionTitle } from './ActionRow';
import { ContactRow, ContactRowBreak } from './ContactRow';
import { UserUtils } from '../../../../session/utils';
const StyledContactSection = styled.div`
display: flex;
@ -90,6 +91,11 @@ const ContactListItemSection = () => {
directContactsByNameWithBreaks.push(m);
});
directContactsByNameWithBreaks.unshift({
id: UserUtils.getOurPubKeyStrFromCache(),
displayName: window.i18n('noteToSelf'),
});
const length = Number(directContactsByNameWithBreaks.length);
return (
@ -118,7 +124,7 @@ const ContactListItemSection = () => {
};
export const ContactsListWithBreaks = () => {
const contactsCount = useSelector(getDirectContactsCount);
const contactsCount = useSelector(getContactsCount);
return (
<StyledContactSection>

@ -297,18 +297,12 @@ const _getLeftPaneConversationIds = (
.map(m => m.id);
};
const _getPrivateFriendsConversations = (
const _getContacts = (
sortedConversations: Array<ReduxConversationType>
): Array<ReduxConversationType> => {
return sortedConversations.filter(convo => {
return (
convo.isPrivate &&
!convo.isMe &&
!convo.isBlocked &&
convo.isApproved &&
convo.didApproveMe &&
convo.activeAt !== undefined
);
// a private conversation not approved is a message request. Include them in the list of contacts
return !convo.isBlocked && convo.isPrivate && !convo.isMe;
});
};
@ -437,7 +431,6 @@ export const getUnreadConversationRequests = createSelector(
* - approved (or message requests are disabled)
* - active_at is set to something truthy
*/
export const getLeftPaneConversationIds = createSelector(
getSortedConversations,
_getLeftPaneConversationIds
@ -450,10 +443,16 @@ export const getLeftPaneConversationIdsCount = createSelector(
}
);
const getDirectContacts = createSelector(getSortedConversations, _getPrivateFriendsConversations);
/**
* Returns all the conversation ids of contacts which are
* - private
* - not me
* - not blocked
*/
const getContacts = createSelector(getSortedConversations, _getContacts);
export const getDirectContactsCount = createSelector(
getDirectContacts,
export const getContactsCount = createSelector(
getContacts,
(contacts: Array<ReduxConversationType>) => contacts.length
);
@ -464,7 +463,7 @@ export type DirectContactsByNameType = {
// make sure that createSelector is called here so this function is memoized
export const getDirectContactsByName = createSelector(
getDirectContacts,
getContacts,
(contacts: Array<ReduxConversationType>): Array<DirectContactsByNameType> => {
const us = UserUtils.getOurPubKeyStrFromCache();
const extractedContacts = contacts
@ -475,10 +474,12 @@ export const getDirectContactsByName = createSelector(
displayName: m.nickname || m.displayNameInProfile,
};
});
const extractedContactsNoDisplayName = sortBy(
extractedContacts.filter(m => !m.displayName),
'id'
);
const extractedContactsWithDisplayName = sortBy(
extractedContacts.filter(m => Boolean(m.displayName)),
m => m.displayName?.toLowerCase()

Loading…
Cancel
Save