optimize stranger list

This commit is contained in:
BlowaterNostr 2023-09-27 20:04:01 +00:00
parent ea741e69ff
commit 2a104cd303
2 changed files with 21 additions and 20 deletions

View File

@ -27,12 +27,18 @@ export class ConversationLists implements ConversationListRetriever {
) {}
*getStrangers() {
for (const userInfo of this.convoSummaries.values()) {
for (const convoSummary of this.convoSummaries.values()) {
if (
userInfo.newestEventReceivedByMe == undefined ||
userInfo.newestEventSendByMe == undefined
(
convoSummary.newestEventReceivedByMe == undefined ||
convoSummary.newestEventSendByMe == undefined
) &&
!(
convoSummary.newestEventReceivedByMe == undefined &&
convoSummary.newestEventSendByMe == undefined
)
) {
yield userInfo;
yield convoSummary;
}
}
}

View File

@ -42,22 +42,17 @@ type Props = {
hasNewMessages: Set<string>;
};
export function ConversationList(props: Props) {
let listToRender: ConversationSummary[] = [];
switch (props.selectedContactGroup) {
case "Contacts":
listToRender = Array.from(props.convoListRetriever.getContacts());
break;
case "Strangers":
listToRender = Array.from(props.convoListRetriever.getStrangers());
break;
case "Group":
listToRender = Array.from(props.convoListRetriever.getGroupChat());
break;
const contacts = Array.from(props.convoListRetriever.getContacts());
const strangers = Array.from(props.convoListRetriever.getStrangers());
// const groups = Array.from(props.convoListRetriever.getGroupChat());
let listToRender = contacts;
if (props.selectedContactGroup == "Strangers") {
listToRender = strangers;
}
const contactsToRender = [];
const convoListToRender = [];
for (const contact of listToRender) {
contactsToRender.push({
convoListToRender.push({
userInfo: contact,
isMarked: props.hasNewMessages.has(contact.pubkey.hex),
});
@ -118,7 +113,7 @@ export function ConversationList(props: Props) {
});
}}
>
Contacts
Contacts: {contacts.length}
</li>
<li class={tw`w-[0.05rem] h-full bg-[#2F3136]`}></li>
<li
@ -134,7 +129,7 @@ export function ConversationList(props: Props) {
});
}}
>
Strangers
Strangers: {strangers.length}
</li>
{
/* <li
@ -156,7 +151,7 @@ export function ConversationList(props: Props) {
</ul>
<ContactGroup
contacts={Array.from(contactsToRender.values())}
contacts={Array.from(convoListToRender.values())}
currentSelected={props.currentSelected}
emit={props.emit}
/>