Merge with dev
This commit is contained in:
parent
16dfe9d57b
commit
724ab4717d
|
@ -25,10 +25,10 @@ const colors = [
|
|||
]
|
||||
|
||||
const getById = (letter: string) =>
|
||||
colors[Math.abs(Number(BigInt(letter.toLowerCase().charCodeAt(0) - 97) % BigInt(colors.length)))]
|
||||
colors[Math.abs(Number(BigInt(letter.toLowerCase().codePointAt(0) - 97) % BigInt(colors.length)))]
|
||||
|
||||
const DialogAvatar = (props: Props) => {
|
||||
const nameFirstLetter = props.name.substring(0, 1)
|
||||
const nameFirstLetter = props.name.slice(0, 1)
|
||||
const randomBg = createMemo(() => {
|
||||
return getById(nameFirstLetter)
|
||||
})
|
||||
|
|
|
@ -2,35 +2,23 @@ import './DialogCard.module.scss'
|
|||
import styles from './DialogCard.module.scss'
|
||||
import DialogAvatar from './DialogAvatar'
|
||||
import type { Author } from '../../graphql/types.gen'
|
||||
import { useAuthStore } from '../../stores/auth'
|
||||
import { createEffect, createSignal } from 'solid-js'
|
||||
import { apiClient } from '../../utils/apiClient'
|
||||
|
||||
const { session } = useAuthStore()
|
||||
|
||||
type Props = {
|
||||
online?: boolean
|
||||
message?: string
|
||||
counter?: number
|
||||
ownerSlug: Author['slug']
|
||||
} & Author
|
||||
|
||||
const createChat = async ({ title, members }: { title?: string; members?: string[] }): Promise<void> => {
|
||||
await apiClient.createChat({ title, members })
|
||||
}
|
||||
|
||||
const DialogCard = (props: Props) => {
|
||||
const [currentUser, setCurrentUser] = createSignal(undefined)
|
||||
createEffect(() => {
|
||||
setCurrentUser(session()?.user?.slug)
|
||||
})
|
||||
|
||||
const handleOpenChat = async () => {
|
||||
try {
|
||||
const test = await apiClient.createChat({
|
||||
title: 'test chat',
|
||||
members: [props.slug, currentUser()]
|
||||
members: [props.slug, props.ownerSlug]
|
||||
})
|
||||
console.log('!!! test:', test)
|
||||
console.log('!!! test:', test.data)
|
||||
} catch (err) {
|
||||
console.log('!!! errr:', err)
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ import { useAuthorsStore } from '../../stores/zine/authors'
|
|||
import '../../styles/Inbox.scss'
|
||||
// Для моков
|
||||
import { createClient } from '@urql/core'
|
||||
import { findAndLoadGraphQLConfig } from '@graphql-codegen/cli'
|
||||
import { useAuthStore } from '../../stores/auth'
|
||||
import { useSession } from '../../context/session'
|
||||
|
||||
const OWNER_ID = '501'
|
||||
const client = createClient({
|
||||
|
@ -61,11 +60,15 @@ export const InboxView = () => {
|
|||
const [authors, setAuthors] = createSignal<Author[]>([])
|
||||
const [postMessageText, setPostMessageText] = createSignal('')
|
||||
const [loading, setLoading] = createSignal<boolean>(false)
|
||||
const [currentSlug, setCurrentSlug] = createSignal<Author['slug'] | undefined>(undefined)
|
||||
|
||||
const { session } = useSession()
|
||||
const { sortedAuthors } = useAuthorsStore()
|
||||
|
||||
createEffect(() => {
|
||||
setAuthors(sortedAuthors())
|
||||
console.log('!!! session():', session())
|
||||
setCurrentSlug(session()?.user?.slug)
|
||||
})
|
||||
|
||||
// Поиск по диалогам
|
||||
|
@ -118,7 +121,6 @@ export const InboxView = () => {
|
|||
setPostMessageText(event.target.value)
|
||||
}
|
||||
|
||||
// TODO: get user session
|
||||
return (
|
||||
<div class="messages container">
|
||||
<div class="row">
|
||||
|
@ -137,7 +139,13 @@ export const InboxView = () => {
|
|||
<div class="dialogs">
|
||||
<For each={authors()}>
|
||||
{(author) => (
|
||||
<DialogCard id={author.id} name={author.name} slug={author.slug} online={true} />
|
||||
<DialogCard
|
||||
ownerSlug={currentSlug()}
|
||||
id={author.id}
|
||||
name={author.name}
|
||||
slug={author.slug}
|
||||
online={true}
|
||||
/>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
|
|
|
@ -35,7 +35,6 @@ export type Author = {
|
|||
}
|
||||
|
||||
export type AuthorStat = {
|
||||
commented?: Maybe<Scalars['Int']>
|
||||
followers?: Maybe<Scalars['Int']>
|
||||
followings?: Maybe<Scalars['Int']>
|
||||
rating?: Maybe<Scalars['Int']>
|
||||
|
@ -367,7 +366,6 @@ export type Query = {
|
|||
recentAll: Array<Maybe<Shout>>
|
||||
recentCandidates: Array<Maybe<Shout>>
|
||||
recentCommented: Array<Maybe<Shout>>
|
||||
recentLayoutShouts: Array<Maybe<Shout>>
|
||||
recentPublished: Array<Maybe<Shout>>
|
||||
recentReacted: Array<Maybe<Shout>>
|
||||
searchChats: Result
|
||||
|
@ -384,9 +382,7 @@ export type Query = {
|
|||
signOut: AuthResult
|
||||
topAuthors: Array<Maybe<Author>>
|
||||
topCommented: Array<Maybe<Shout>>
|
||||
topLayoutShouts: Array<Maybe<Shout>>
|
||||
topMonth: Array<Maybe<Shout>>
|
||||
topMonthLayoutShouts: Array<Maybe<Shout>>
|
||||
topOverall: Array<Maybe<Shout>>
|
||||
topPublished: Array<Maybe<Shout>>
|
||||
topicsAll: Array<Maybe<Topic>>
|
||||
|
@ -474,12 +470,6 @@ export type QueryRecentCommentedArgs = {
|
|||
offset: Scalars['Int']
|
||||
}
|
||||
|
||||
export type QueryRecentLayoutShoutsArgs = {
|
||||
amount?: InputMaybe<Scalars['Int']>
|
||||
layout: Scalars['String']
|
||||
offset?: InputMaybe<Scalars['Int']>
|
||||
}
|
||||
|
||||
export type QueryRecentPublishedArgs = {
|
||||
limit: Scalars['Int']
|
||||
offset: Scalars['Int']
|
||||
|
@ -565,23 +555,11 @@ export type QueryTopCommentedArgs = {
|
|||
offset: Scalars['Int']
|
||||
}
|
||||
|
||||
export type QueryTopLayoutShoutsArgs = {
|
||||
amount?: InputMaybe<Scalars['Int']>
|
||||
layout: Scalars['String']
|
||||
offset?: InputMaybe<Scalars['Int']>
|
||||
}
|
||||
|
||||
export type QueryTopMonthArgs = {
|
||||
limit: Scalars['Int']
|
||||
offset: Scalars['Int']
|
||||
}
|
||||
|
||||
export type QueryTopMonthLayoutShoutsArgs = {
|
||||
amount?: InputMaybe<Scalars['Int']>
|
||||
layout: Scalars['String']
|
||||
offset?: InputMaybe<Scalars['Int']>
|
||||
}
|
||||
|
||||
export type QueryTopOverallArgs = {
|
||||
limit: Scalars['Int']
|
||||
offset: Scalars['Int']
|
||||
|
@ -730,7 +708,6 @@ export type Shout = {
|
|||
lang?: Maybe<Scalars['String']>
|
||||
layout?: Maybe<Scalars['String']>
|
||||
mainTopic?: Maybe<Scalars['String']>
|
||||
media?: Maybe<Scalars['String']>
|
||||
publishedAt?: Maybe<Scalars['DateTime']>
|
||||
publishedBy?: Maybe<User>
|
||||
slug: Scalars['String']
|
||||
|
|
|
@ -35,7 +35,8 @@ import reactionDestroy from '../graphql/mutation/reaction-destroy'
|
|||
import reactionUpdate from '../graphql/mutation/reaction-update'
|
||||
import incrementView from '../graphql/mutation/increment-view'
|
||||
import createArticle from '../graphql/mutation/article-create'
|
||||
import myChats from '../graphql/query/my-chats'
|
||||
import CreateChat from '../graphql/mutation/create-chat'
|
||||
// import myChats from '../graphql/query/my-chats'
|
||||
import authorBySlug from '../graphql/query/author-by-slug'
|
||||
import topicBySlug from '../graphql/query/topic-by-slug'
|
||||
|
||||
|
@ -372,22 +373,22 @@ export const apiClient = {
|
|||
},
|
||||
createChat: async ({ title, members }) => {
|
||||
return await privateGraphQLClient.mutation(CreateChat, { title: title, members: members }).toPromise()
|
||||
},
|
||||
}
|
||||
|
||||
getChats: async (payload = {}) => {
|
||||
const resp = await privateGraphQLClient.query(myChats, payload).toPromise()
|
||||
return resp.data.myChats
|
||||
},
|
||||
getChatMessages: async ({
|
||||
chatId,
|
||||
offset = 0,
|
||||
amount = 50
|
||||
}: {
|
||||
chatId: string
|
||||
offset?: number
|
||||
amount?: number
|
||||
}) => {
|
||||
const resp = await privateGraphQLClient.query(loadChat, { chatId, offset, amount }).toPromise()
|
||||
return resp.data.loadChat
|
||||
}
|
||||
// getChats: async (payload = {}) => {
|
||||
// const resp = await privateGraphQLClient.query(myChats, payload).toPromise()
|
||||
// return resp.data.myChats
|
||||
// },
|
||||
// getChatMessages: async ({
|
||||
// chatId,
|
||||
// offset = 0,
|
||||
// amount = 50
|
||||
// }: {
|
||||
// chatId: string
|
||||
// offset?: number
|
||||
// amount?: number
|
||||
// }) => {
|
||||
// const resp = await privateGraphQLClient.query(loadChat, { chatId, offset, amount }).toPromise()
|
||||
// return resp.data.loadChat
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user