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