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"
margin="0 var(--margins-md)"
alignItems="flex-start"
minWidth="0"
>
<StyledName data-testid={'contact'} maxName={maxNameWidth}>
{ourName || memberName}

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

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

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

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

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

@ -64,6 +64,7 @@ const BlockedEntries = (props: {
onSelect={addToSelected}
onUnselect={removeFromSelected}
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
import { GroupPubkeyType } from 'libsession_util_nodejs';
import _, { isEmpty } from 'lodash';
import _, { isArray, isEmpty } from 'lodash';
import { ConversationModel } from '../models/conversation';
import { ConversationAttributes } from '../models/conversationAttributes';
import { MessageCollection, MessageModel } from '../models/message';
@ -285,6 +285,9 @@ async function getAllMessagesWithAttachmentsInConversationSentBefore(args: {
}): Promise<Array<MessageModel>> {
const msgAttrs = await channels.getAllMessagesWithAttachmentsInConversationSentBefore(args);
if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return [];
}
return msgAttrs.map((msg: any) => new MessageModel(msg));
}
@ -578,7 +581,7 @@ async function findAllMessageFromSendersInConversation(
): Promise<Array<MessageModel>> {
const msgAttrs = await channels.findAllMessageFromSendersInConversation(args);
if (!msgAttrs || isEmpty(msgAttrs)) {
if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return [];
}
@ -590,7 +593,7 @@ async function findAllMessageHashesInConversation(
): Promise<Array<MessageModel>> {
const msgAttrs = await channels.findAllMessageHashesInConversation(args);
if (!msgAttrs || isEmpty(msgAttrs)) {
if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return [];
}
@ -602,7 +605,7 @@ async function findAllMessageHashesInConversationMatchingAuthor(
): Promise<Array<MessageModel>> {
const msgAttrs = await channels.findAllMessageHashesInConversationMatchingAuthor(args);
if (!msgAttrs || isEmpty(msgAttrs)) {
if (!msgAttrs || isEmpty(msgAttrs) || !isArray(msgAttrs)) {
return [];
}

@ -673,6 +673,18 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
});
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()) {
const chatMessageMediumGroup = new VisibleMessage(chatMessageParams);
const closedGroupVisibleMessage = new ClosedGroupVisibleMessage({

@ -316,7 +316,8 @@ const _getContacts = (
): Array<ReduxConversationType> => {
return sortedConversations.filter(convo => {
// 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
export const getSortedContacts = createSelector(
const getSortedContacts = createSelector(
getContacts,
(contacts: Array<ReduxConversationType>): Array<DirectContactsByNameType> => {
const us = UserUtils.getOurPubKeyStrFromCache();

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

Loading…
Cancel
Save