Chat list filters
This commit is contained in:
parent
a6a0b804b7
commit
a319404851
|
@ -7,12 +7,6 @@ import { hideModal } from '../../stores/ui'
|
||||||
import { useInbox } from '../../context/inbox'
|
import { useInbox } from '../../context/inbox'
|
||||||
|
|
||||||
type inviteUser = Author & { selected: boolean }
|
type inviteUser = Author & { selected: boolean }
|
||||||
type query =
|
|
||||||
| {
|
|
||||||
theme: string
|
|
||||||
members: string[]
|
|
||||||
}
|
|
||||||
| undefined
|
|
||||||
type Props = {
|
type Props = {
|
||||||
users: Author[]
|
users: Author[]
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ type Props = {
|
||||||
online?: boolean
|
online?: boolean
|
||||||
size?: 'small'
|
size?: 'small'
|
||||||
bordered?: boolean
|
bordered?: boolean
|
||||||
className: string
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const colors = [
|
const colors = [
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import styles from './DialogCard.module.scss'
|
import styles from './DialogCard.module.scss'
|
||||||
import DialogAvatar from './DialogAvatar'
|
import DialogAvatar from './DialogAvatar'
|
||||||
import type { Author, Chat, ChatMember, User } from '../../graphql/types.gen'
|
import type { ChatMember } from '../../graphql/types.gen'
|
||||||
import { apiClient } from '../../utils/apiClient'
|
|
||||||
import { t } from '../../utils/intl'
|
|
||||||
import { useInbox } from '../../context/inbox'
|
|
||||||
import GroupDialogAvatar from './GroupDialogAvatar'
|
import GroupDialogAvatar from './GroupDialogAvatar'
|
||||||
|
|
||||||
type DialogProps = {
|
type DialogProps = {
|
||||||
|
@ -20,13 +17,12 @@ const DialogCard = (props: DialogProps) => {
|
||||||
return (
|
return (
|
||||||
<div class={styles.DialogCard}>
|
<div class={styles.DialogCard}>
|
||||||
<div class={styles.avatar}>
|
<div class={styles.avatar}>
|
||||||
{companions.length > 1 ? (
|
{companions.length > 2 ? (
|
||||||
<GroupDialogAvatar users={companions} />
|
<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>
|
||||||
|
|
||||||
<div class={styles.row}>
|
<div class={styles.row}>
|
||||||
{companions.length > 1 ? (
|
{companions.length > 1 ? (
|
||||||
<div class={styles.name}>{props.title}</div>
|
<div class={styles.name}>{props.title}</div>
|
||||||
|
|
|
@ -10,12 +10,11 @@ import { createClient } from '@urql/core'
|
||||||
import Message from '../Inbox/Message'
|
import Message from '../Inbox/Message'
|
||||||
import { loadRecipients, loadChats } from '../../stores/inbox'
|
import { loadRecipients, loadChats } from '../../stores/inbox'
|
||||||
import { t } from '../../utils/intl'
|
import { t } from '../../utils/intl'
|
||||||
import '../../styles/Inbox.scss'
|
|
||||||
import { useInbox } from '../../context/inbox'
|
|
||||||
import { Modal } from '../Nav/Modal'
|
import { Modal } from '../Nav/Modal'
|
||||||
import { showModal } from '../../stores/ui'
|
import { showModal } from '../../stores/ui'
|
||||||
import InviteUser from '../Inbox/InviteUser'
|
|
||||||
import CreateModalContent from '../Inbox/CreateModalContent'
|
import CreateModalContent from '../Inbox/CreateModalContent'
|
||||||
|
import { clsx } from 'clsx'
|
||||||
|
import '../../styles/Inbox.scss'
|
||||||
|
|
||||||
const OWNER_ID = '501'
|
const OWNER_ID = '501'
|
||||||
const client = createClient({
|
const client = createClient({
|
||||||
|
@ -65,6 +64,8 @@ export const InboxView = () => {
|
||||||
const [cashedRecipients, setCashedRecipients] = createSignal<Author[]>([])
|
const [cashedRecipients, setCashedRecipients] = createSignal<Author[]>([])
|
||||||
const [postMessageText, setPostMessageText] = createSignal('')
|
const [postMessageText, setPostMessageText] = createSignal('')
|
||||||
const [loading, setLoading] = createSignal<boolean>(false)
|
const [loading, setLoading] = createSignal<boolean>(false)
|
||||||
|
const [sortByGroup, setSortByGroup] = createSignal<boolean>(false)
|
||||||
|
const [sortByPerToPer, setSortByPerToPer] = createSignal<boolean>(false)
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
const currentSlug = createMemo(() => session()?.user?.slug)
|
const currentSlug = createMemo(() => session()?.user?.slug)
|
||||||
|
|
||||||
|
@ -112,7 +113,6 @@ export const InboxView = () => {
|
||||||
try {
|
try {
|
||||||
const response = await loadChats()
|
const response = await loadChats()
|
||||||
setChats(response as unknown as Chat[])
|
setChats(response as unknown as Chat[])
|
||||||
console.log('!!! chats:', response)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
@ -158,16 +158,46 @@ export const InboxView = () => {
|
||||||
|
|
||||||
<div class="chat-list__types">
|
<div class="chat-list__types">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li
|
||||||
<strong>{t('All')}</strong>
|
class={clsx({ ['selected']: !sortByPerToPer() && !sortByGroup() })}
|
||||||
|
onClick={() => {
|
||||||
|
setSortByPerToPer(false)
|
||||||
|
setSortByGroup(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>{t('All')}</span>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class={clsx({ ['selected']: sortByPerToPer() })}
|
||||||
|
onClick={() => {
|
||||||
|
setSortByPerToPer(true)
|
||||||
|
setSortByGroup(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>{t('Personal')}</span>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
class={clsx({ ['selected']: sortByGroup() })}
|
||||||
|
onClick={() => {
|
||||||
|
setSortByGroup(true)
|
||||||
|
setSortByPerToPer(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>{t('Groups')}</span>
|
||||||
</li>
|
</li>
|
||||||
<li>{t('Personal')}</li>
|
|
||||||
<li>{t('Groups')}</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="holder">
|
<div class="holder">
|
||||||
<div class="dialogs">
|
<div class="dialogs">
|
||||||
<For each={chats()}>
|
<For
|
||||||
|
each={
|
||||||
|
sortByPerToPer()
|
||||||
|
? chats().filter((chat) => chat.title.length === 0)
|
||||||
|
: sortByGroup()
|
||||||
|
? chats().filter((chat) => chat.title.length > 0)
|
||||||
|
: chats()
|
||||||
|
}
|
||||||
|
>
|
||||||
{(chat) => <DialogCard title={chat.title} members={chat.members} ownSlug={currentSlug()} />}
|
{(chat) => <DialogCard title={chat.title} members={chat.members} ownSlug={currentSlug()} />}
|
||||||
</For>
|
</For>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -111,14 +111,16 @@ main {
|
||||||
li {
|
li {
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
color: #696969;
|
color: #696969;
|
||||||
}
|
cursor: pointer;
|
||||||
|
&.selected {
|
||||||
strong {
|
span {
|
||||||
border-bottom: 3px solid;
|
border-bottom: 3px solid;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.interlocutor {
|
.interlocutor {
|
||||||
height: 56px;
|
height: 56px;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user