Linter fixies

This commit is contained in:
ilya-bkv 2022-12-01 06:26:44 +03:00
parent 4e889a2c67
commit 15ad8bf8dd
3 changed files with 40 additions and 37 deletions

View File

@ -2,6 +2,7 @@ import styles from './DialogCard.module.scss'
import DialogAvatar from './DialogAvatar' import DialogAvatar from './DialogAvatar'
import type { ChatMember } from '../../graphql/types.gen' import type { ChatMember } from '../../graphql/types.gen'
import GroupDialogAvatar from './GroupDialogAvatar' import GroupDialogAvatar from './GroupDialogAvatar'
import { Show } from 'solid-js'
type DialogProps = { type DialogProps = {
online?: boolean online?: boolean
@ -14,34 +15,35 @@ type DialogProps = {
} }
const DialogCard = (props: DialogProps) => { const DialogCard = (props: DialogProps) => {
if (!props.members) return const companions = props.members && props.members.filter((member) => member.slug !== props.ownSlug)
const companions = props.members.filter((member) => member.slug !== props.ownSlug)
return ( return (
<div class={styles.DialogCard} onClick={props.onClick}> <Show when={props.members}>
<div class={styles.avatar}> <div class={styles.DialogCard} onClick={props.onClick}>
{companions.length > 2 ? ( <div class={styles.avatar}>
<GroupDialogAvatar users={companions} /> {companions.length > 2 ? (
) : ( <GroupDialogAvatar users={companions} />
<DialogAvatar name={props.members[0].name} url={props.members[0].userpic} /> ) : (
)} <DialogAvatar name={props.members[0].name} url={props.members[0].userpic} />
</div> )}
<div class={styles.row}> </div>
{companions.length > 1 ? ( <div class={styles.row}>
<div class={styles.name}>{props.title}</div> {companions.length > 1 ? (
) : ( <div class={styles.name}>{props.title}</div>
<div class={styles.name}>{companions[0].name}</div> ) : (
)} <div class={styles.name}>{companions[0].name}</div>
<div class={styles.message}> )}
Указать предпочтительные языки для результатов поиска можно в разделе <div class={styles.message}>
Указать предпочтительные языки для результатов поиска можно в разделе
</div>
</div>
<div class={styles.activity}>
<div class={styles.time}>22:22</div>
<div class={styles.counter}>
<span>12</span>
</div>
</div> </div>
</div> </div>
<div class={styles.activity}> </Show>
<div class={styles.time}>22:22</div>
<div class={styles.counter}>
<span>12</span>
</div>
</div>
</div>
) )
} }

View File

@ -105,7 +105,6 @@ export const InboxView = () => {
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
await loadChats() await loadChats()
console.log('!!! chats:', chats()) console.log('!!! chats:', chats())
}) })
@ -134,6 +133,16 @@ export const InboxView = () => {
showModal('inviteToChat') 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 ( return (
<div class="messages container"> <div class="messages container">
<Modal variant="narrow" name="inviteToChat"> <Modal variant="narrow" name="inviteToChat">
@ -181,15 +190,7 @@ export const InboxView = () => {
</div> </div>
<div class="holder"> <div class="holder">
<div class="dialogs"> <div class="dialogs">
<For <For each={chatsToShow()}>
each={
sortByPerToPer()
? chats().filter((chat) => chat.title.length === 0)
: sortByGroup()
? chats().filter((chat) => chat.title.length > 0)
: chats()
}
>
{(chat) => ( {(chat) => (
<DialogCard <DialogCard
onClick={() => handleOpenChat(chat.id)} onClick={() => handleOpenChat(chat.id)}

View File

@ -22,9 +22,9 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
const [chats, setChats] = createSignal<Chat[]>([]) const [chats, setChats] = createSignal<Chat[]>([])
const loadChats = async () => { const loadChats = async () => {
try { try {
const chats = await apiClient.getChats({ limit: 50, offset: 0 }) const newChats = await apiClient.getChats({ limit: 50, offset: 0 })
setChats( setChats(
chats.sort((x, y) => { newChats.sort((x, y) => {
return x.updatedAt < y.updatedAt ? 1 : -1 return x.updatedAt < y.updatedAt ? 1 : -1
}) })
) )