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 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 (
<div class={styles.DialogCard} onClick={props.onClick}>
<div class={styles.avatar}>
{companions.length > 2 ? (
<GroupDialogAvatar users={companions} />
) : (
<DialogAvatar name={props.members[0].name} url={props.members[0].userpic} />
)}
</div>
<div class={styles.row}>
{companions.length > 1 ? (
<div class={styles.name}>{props.title}</div>
) : (
<div class={styles.name}>{companions[0].name}</div>
)}
<div class={styles.message}>
Указать предпочтительные языки для результатов поиска можно в разделе
<Show when={props.members}>
<div class={styles.DialogCard} onClick={props.onClick}>
<div class={styles.avatar}>
{companions.length > 2 ? (
<GroupDialogAvatar users={companions} />
) : (
<DialogAvatar name={props.members[0].name} url={props.members[0].userpic} />
)}
</div>
<div class={styles.row}>
{companions.length > 1 ? (
<div class={styles.name}>{props.title}</div>
) : (
<div class={styles.name}>{companions[0].name}</div>
)}
<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 class={styles.activity}>
<div class={styles.time}>22:22</div>
<div class={styles.counter}>
<span>12</span>
</div>
</div>
</div>
</Show>
)
}

View File

@ -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 (
<div class="messages container">
<Modal variant="narrow" name="inviteToChat">
@ -181,15 +190,7 @@ export const InboxView = () => {
</div>
<div class="holder">
<div class="dialogs">
<For
each={
sortByPerToPer()
? chats().filter((chat) => chat.title.length === 0)
: sortByGroup()
? chats().filter((chat) => chat.title.length > 0)
: chats()
}
>
<For each={chatsToShow()}>
{(chat) => (
<DialogCard
onClick={() => handleOpenChat(chat.id)}

View File

@ -22,9 +22,9 @@ export const InboxProvider = (props: { children: JSX.Element }) => {
const [chats, setChats] = createSignal<Chat[]>([])
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
})
)