From 15ad8bf8dd16e1db6eb6a33ebbefc0be140d1062 Mon Sep 17 00:00:00 2001 From: ilya-bkv Date: Thu, 1 Dec 2022 06:26:44 +0300 Subject: [PATCH] Linter fixies --- src/components/Inbox/DialogCard.tsx | 52 +++++++++++++++-------------- src/components/Views/Inbox.tsx | 21 ++++++------ src/context/inbox.tsx | 4 +-- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/components/Inbox/DialogCard.tsx b/src/components/Inbox/DialogCard.tsx index 557dcb0b..45483cf5 100644 --- a/src/components/Inbox/DialogCard.tsx +++ b/src/components/Inbox/DialogCard.tsx @@ -2,6 +2,7 @@ import styles from './DialogCard.module.scss' import DialogAvatar from './DialogAvatar' import type { ChatMember } from '../../graphql/types.gen' import GroupDialogAvatar from './GroupDialogAvatar' +import { Show } from 'solid-js' type DialogProps = { online?: boolean @@ -14,34 +15,35 @@ type DialogProps = { } const DialogCard = (props: DialogProps) => { - if (!props.members) return - const companions = props.members.filter((member) => member.slug !== props.ownSlug) + const companions = props.members && props.members.filter((member) => member.slug !== props.ownSlug) return ( -
-
- {companions.length > 2 ? ( - - ) : ( - - )} -
-
- {companions.length > 1 ? ( -
{props.title}
- ) : ( -
{companions[0].name}
- )} -
- Указать предпочтительные языки для результатов поиска можно в разделе + +
+
+ {companions.length > 2 ? ( + + ) : ( + + )} +
+
+ {companions.length > 1 ? ( +
{props.title}
+ ) : ( +
{companions[0].name}
+ )} +
+ Указать предпочтительные языки для результатов поиска можно в разделе +
+
+
+
22:22
+
+ 12 +
-
-
22:22
-
- 12 -
-
-
+ ) } diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx index 93fb5cd6..497604c5 100644 --- a/src/components/Views/Inbox.tsx +++ b/src/components/Views/Inbox.tsx @@ -105,7 +105,6 @@ export const InboxView = () => { } catch (error) { console.log(error) } - await loadChats() console.log('!!! chats:', chats()) }) @@ -134,6 +133,16 @@ export const InboxView = () => { showModal('inviteToChat') } + const chatsToShow = () => { + if (sortByPerToPer()) { + return chats().filter((chat) => chat.title.trim().length === 0) + } else if (sortByGroup()) { + return chats().filter((chat) => chat.title.trim().length > 0) + } else { + return chats() + } + } + return (
@@ -181,15 +190,7 @@ export const InboxView = () => {
- chat.title.length === 0) - : sortByGroup() - ? chats().filter((chat) => chat.title.length > 0) - : chats() - } - > + {(chat) => ( handleOpenChat(chat.id)} diff --git a/src/context/inbox.tsx b/src/context/inbox.tsx index e9969c6f..f502e24d 100644 --- a/src/context/inbox.tsx +++ b/src/context/inbox.tsx @@ -22,9 +22,9 @@ export const InboxProvider = (props: { children: JSX.Element }) => { const [chats, setChats] = createSignal([]) const loadChats = async () => { try { - const chats = await apiClient.getChats({ limit: 50, offset: 0 }) + const newChats = await apiClient.getChats({ limit: 50, offset: 0 }) setChats( - chats.sort((x, y) => { + newChats.sort((x, y) => { return x.updatedAt < y.updatedAt ? 1 : -1 }) )