fix: we want the sorting order to be jumpy for groups

apparently
pull/3281/head
Audric Ackermann 5 months ago
parent bb820eff38
commit 143759ff92
No known key found for this signature in database

@ -323,6 +323,7 @@ export const MemberListItem = ({
flexDirection="column" flexDirection="column"
margin="0 var(--margins-md)" margin="0 var(--margins-md)"
alignItems="flex-start" alignItems="flex-start"
minWidth="0"
> >
<StyledName data-testid={'contact'} maxName={maxNameWidth}> <StyledName data-testid={'contact'} maxName={maxNameWidth}>
{ourName || memberName} {ourName || memberName}

@ -44,6 +44,7 @@ export const renderUserMentionRow = (suggestion: SuggestionDataItem) => {
pubkey={`${suggestion.id}`} pubkey={`${suggestion.id}`}
inMentions={true} inMentions={true}
dataTestId="mentions-popup-row" dataTestId="mentions-popup-row"
maxNameWidth="100%"
/> />
); );
}; };

@ -206,6 +206,7 @@ const InviteContactsDialogInner = (props: Props) => {
onSelect={addTo} onSelect={addTo}
onUnselect={removeFrom} onUnselect={removeFrom}
disableBg={true} disableBg={true}
maxNameWidth="100%"
/> />
)) ))
) : ( ) : (

@ -104,6 +104,7 @@ export const RemoveModeratorsDialog = (props: Props) => {
setModsToRemove(updatedList); setModsToRemove(updatedList);
}} }}
disableBg={true} disableBg={true}
maxNameWidth="100%"
/> />
))} ))}
</div> </div>

@ -86,6 +86,7 @@ const MemberList = (props: {
disableBg={true} disableBg={true}
displayGroupStatus={isV2Group && weAreAdmin} displayGroupStatus={isV2Group && weAreAdmin}
groupPk={convoId} groupPk={convoId}
maxNameWidth="100%"
/> />
); );
})} })}

@ -228,6 +228,7 @@ export const OverlayClosedGroupV2 = () => {
onSelect={addToSelected} onSelect={addToSelected}
onUnselect={removeFromSelected} onUnselect={removeFromSelected}
disableBg={true} disableBg={true}
maxNameWidth="100%"
/> />
)) ))
)} )}
@ -345,6 +346,7 @@ export const OverlayLegacyClosedGroup = () => {
onUnselect={removeFromSelected} onUnselect={removeFromSelected}
withBorder={false} withBorder={false}
disabled={loading} disabled={loading}
maxNameWidth="100%"
/> />
)) ))
)} )}

@ -64,6 +64,7 @@ const BlockedEntries = (props: {
onSelect={addToSelected} onSelect={addToSelected}
onUnselect={removeFromSelected} onUnselect={removeFromSelected}
disableBg={true} disableBg={true}
maxNameWidth="100%"
/> />
); );
})} })}

@ -1,7 +1,7 @@
// eslint:disable: no-require-imports no-var-requires one-variable-per-declaration no-void-expression function-name // eslint:disable: no-require-imports no-var-requires one-variable-per-declaration no-void-expression function-name
import { GroupPubkeyType } from 'libsession_util_nodejs'; import { GroupPubkeyType } from 'libsession_util_nodejs';
import _, { isEmpty } from 'lodash'; import _, { isArray, isEmpty } from 'lodash';
import { ConversationModel } from '../models/conversation'; import { ConversationModel } from '../models/conversation';
import { ConversationAttributes } from '../models/conversationAttributes'; import { ConversationAttributes } from '../models/conversationAttributes';
import { MessageCollection, MessageModel } from '../models/message'; import { MessageCollection, MessageModel } from '../models/message';
@ -285,6 +285,9 @@ async function getAllMessagesWithAttachmentsInConversationSentBefore(args: {
}): Promise<Array<MessageModel>> { }): Promise<Array<MessageModel>> {
const msgAttrs = await channels.getAllMessagesWithAttachmentsInConversationSentBefore(args); const msgAttrs = await channels.getAllMessagesWithAttachmentsInConversationSentBefore(args);
if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return [];
}
return msgAttrs.map((msg: any) => new MessageModel(msg)); return msgAttrs.map((msg: any) => new MessageModel(msg));
} }
@ -578,7 +581,7 @@ async function findAllMessageFromSendersInConversation(
): Promise<Array<MessageModel>> { ): Promise<Array<MessageModel>> {
const msgAttrs = await channels.findAllMessageFromSendersInConversation(args); const msgAttrs = await channels.findAllMessageFromSendersInConversation(args);
if (!msgAttrs || isEmpty(msgAttrs)) { if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return []; return [];
} }
@ -590,7 +593,7 @@ async function findAllMessageHashesInConversation(
): Promise<Array<MessageModel>> { ): Promise<Array<MessageModel>> {
const msgAttrs = await channels.findAllMessageHashesInConversation(args); const msgAttrs = await channels.findAllMessageHashesInConversation(args);
if (!msgAttrs || isEmpty(msgAttrs)) { if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return []; return [];
} }
@ -602,7 +605,7 @@ async function findAllMessageHashesInConversationMatchingAuthor(
): Promise<Array<MessageModel>> { ): Promise<Array<MessageModel>> {
const msgAttrs = await channels.findAllMessageHashesInConversationMatchingAuthor(args); const msgAttrs = await channels.findAllMessageHashesInConversationMatchingAuthor(args);
if (!msgAttrs || isEmpty(msgAttrs)) { if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return []; return [];
} }

@ -673,6 +673,18 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
}); });
return; return;
} }
if (this.isClosedGroupV2()) {
// we need the return await so that errors are caught in the catch {}
await this.sendMessageToGroupV2(chatMessageParams);
await Reactions.handleMessageReaction({
reaction,
sender: UserUtils.getOurPubKeyStrFromCache(),
you: true,
});
return;
}
if (this.isClosedGroup()) { if (this.isClosedGroup()) {
const chatMessageMediumGroup = new VisibleMessage(chatMessageParams); const chatMessageMediumGroup = new VisibleMessage(chatMessageParams);
const closedGroupVisibleMessage = new ClosedGroupVisibleMessage({ const closedGroupVisibleMessage = new ClosedGroupVisibleMessage({

@ -316,7 +316,8 @@ const _getContacts = (
): Array<ReduxConversationType> => { ): Array<ReduxConversationType> => {
return sortedConversations.filter(convo => { return sortedConversations.filter(convo => {
// a private conversation not approved is a message request. Include them in the list of contacts // a private conversation not approved is a message request. Include them in the list of contacts
return !convo.isBlocked && convo.isPrivate && !convo.isMe; // Note: we filter out non 05-pubkeys as we don't want blinded message request to be part of this list
return !convo.isBlocked && convo.isPrivate && !convo.isMe && PubKey.is05Pubkey(convo.id);
}); });
}; };
@ -481,7 +482,7 @@ export type DirectContactsByNameType = {
}; };
// make sure that createSelector is called here so this function is memoized // make sure that createSelector is called here so this function is memoized
export const getSortedContacts = createSelector( const getSortedContacts = createSelector(
getContacts, getContacts,
(contacts: Array<ReduxConversationType>): Array<DirectContactsByNameType> => { (contacts: Array<ReduxConversationType>): Array<DirectContactsByNameType> => {
const us = UserUtils.getOurPubKeyStrFromCache(); const us = UserUtils.getOurPubKeyStrFromCache();

@ -232,18 +232,27 @@ export function useMemberPromoteSending(groupPk: GroupPubkeyType, memberPk: Pubk
} }
type MemberStateGroupV2WithSending = MemberStateGroupV2 | 'INVITE_SENDING' | 'PROMOTION_SENDING'; type MemberStateGroupV2WithSending = MemberStateGroupV2 | 'INVITE_SENDING' | 'PROMOTION_SENDING';
type MemberWithV2Sending = Pick<GroupMemberGet, 'pubkeyHex'> & {
memberStatus: MemberStateGroupV2WithSending;
};
export function useStateOf03GroupMembers(convoId?: string) { export function useStateOf03GroupMembers(convoId?: string) {
const us = UserUtils.getOurPubKeyStrFromCache(); const us = UserUtils.getOurPubKeyStrFromCache();
let unsortedMembers = useSelector((state: StateType) => getMembersOfGroup(state, convoId)); let unsortedMembers = useSelector((state: StateType) => getMembersOfGroup(state, convoId));
const invitesSendingPk = useMembersInviteSending(convoId); const invitesSendingPk = useMembersInviteSending(convoId);
const promotionsSendingPk = useMembersPromoteSending(convoId); const promotionsSendingPk = useMembersPromoteSending(convoId);
let invitesSending = compact( let invitesSending: Array<MemberWithV2Sending> = compact(
invitesSendingPk.map(sending => unsortedMembers.find(m => m.pubkeyHex === sending)) invitesSendingPk
); .map(sending => unsortedMembers.find(m => m.pubkeyHex === sending))
const promotionSending = compact( .map(m => {
promotionsSendingPk.map(sending => unsortedMembers.find(m => m.pubkeyHex === sending)) return m ? { ...m, memberStatus: 'INVITE_SENDING' as const } : null;
})
); );
const promotionSending: Array<MemberWithV2Sending> = compact( promotionsSendingPk
.map(sending => unsortedMembers.find(m => m.pubkeyHex === sending))
.map(m => {
return m ? { ...m, memberStatus: 'PROMOTION_SENDING' as const } : null;
}));
// promotionSending has priority against invitesSending, so removing anything in invitesSending found in promotionSending // promotionSending has priority against invitesSending, so removing anything in invitesSending found in promotionSending
invitesSending = differenceBy(invitesSending, promotionSending, value => value.pubkeyHex); invitesSending = differenceBy(invitesSending, promotionSending, value => value.pubkeyHex);
@ -283,7 +292,6 @@ export function useStateOf03GroupMembers(convoId?: string) {
unsortedWithStatuses.push(...promotionSending); unsortedWithStatuses.push(...promotionSending);
unsortedWithStatuses.push(...differenceBy(invitesSending, promotionSending)); unsortedWithStatuses.push(...differenceBy(invitesSending, promotionSending));
unsortedWithStatuses.push(...differenceBy(unsortedMembers, invitesSending, promotionSending)); unsortedWithStatuses.push(...differenceBy(unsortedMembers, invitesSending, promotionSending));
const names = useConversationsNicknameRealNameOrShortenPubkey( const names = useConversationsNicknameRealNameOrShortenPubkey(
unsortedWithStatuses.map(m => m.pubkeyHex) unsortedWithStatuses.map(m => m.pubkeyHex)
); );
@ -336,6 +344,5 @@ export function useStateOf03GroupMembers(convoId?: string) {
index++; index++;
return sortingOrder; return sortingOrder;
}); });
return sorted; return sorted;
} }

Loading…
Cancel
Save