Chats is working!
This commit is contained in:
parent
c1413bbf5d
commit
9602925a31
|
@ -9,6 +9,7 @@ import { locale } from '../../stores/ui'
|
|||
import { follow, unfollow } from '../../stores/zine/common'
|
||||
import { clsx } from 'clsx'
|
||||
import { useSession } from '../../context/session'
|
||||
import { FollowingEntity } from '../../graphql/types.gen'
|
||||
|
||||
interface AuthorCardProps {
|
||||
caption?: string
|
||||
|
@ -84,7 +85,8 @@ export const AuthorCard = (props: AuthorCardProps) => {
|
|||
when={subscribed()}
|
||||
fallback={
|
||||
<button
|
||||
onClick={() => follow}
|
||||
// TODO: change button view reactivity
|
||||
onclick={() => follow({ what: FollowingEntity.Author, slug: props.author.slug })}
|
||||
class={clsx('button', styles.button)}
|
||||
classList={{
|
||||
[styles.buttonSubscribe]: !props.isAuthorsList,
|
||||
|
@ -101,7 +103,7 @@ export const AuthorCard = (props: AuthorCardProps) => {
|
|||
}
|
||||
>
|
||||
<button
|
||||
onClick={() => unfollow}
|
||||
onclick={() => follow({ what: FollowingEntity.Author, slug: props.author.slug })}
|
||||
classList={{
|
||||
[styles.buttonSubscribe]: !props.isAuthorsList,
|
||||
'button--subscribe': !props.isAuthorsList,
|
||||
|
|
|
@ -37,7 +37,7 @@ export const InboxView = () => {
|
|||
const [sortByPerToPer, setSortByPerToPer] = createSignal<boolean>(false)
|
||||
const [currentDialog, setCurrentDialog] = createSignal<Chat>()
|
||||
const { session } = useSession()
|
||||
const currentUserId = createMemo(() => session()?.user?.id)
|
||||
const currentUserId = createMemo(() => session()?.user.id)
|
||||
|
||||
// Поиск по диалогам
|
||||
const getQuery = (query) => {
|
||||
|
|
|
@ -23,6 +23,7 @@ const getSession = async (): Promise<AuthResult> => {
|
|||
if (!authResult) {
|
||||
return null
|
||||
}
|
||||
console.log('!!! authResult:', authResult)
|
||||
setToken(authResult.token)
|
||||
return authResult
|
||||
} catch (error) {
|
||||
|
|
|
@ -7,6 +7,7 @@ export default gql`
|
|||
token
|
||||
user {
|
||||
_id: slug
|
||||
id
|
||||
name
|
||||
slug
|
||||
bio
|
||||
|
|
|
@ -78,7 +78,6 @@ export type ChatMember = {
|
|||
id: Scalars['Int']
|
||||
lastSeen?: Maybe<Scalars['DateTime']>
|
||||
name: Scalars['String']
|
||||
online?: Maybe<Scalars['Boolean']>
|
||||
slug: Scalars['String']
|
||||
userpic?: Maybe<Scalars['String']>
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ export type LoadShoutsOptions = {
|
|||
}
|
||||
|
||||
export type Message = {
|
||||
author: Scalars['Int']
|
||||
author: Scalars['String']
|
||||
body: Scalars['String']
|
||||
chatId: Scalars['String']
|
||||
createdAt: Scalars['Int']
|
||||
|
|
|
@ -2,6 +2,7 @@ import type { FollowingEntity } from '../../graphql/types.gen'
|
|||
import { apiClient } from '../../utils/apiClient'
|
||||
|
||||
export const follow = async ({ what, slug }: { what: FollowingEntity; slug: string }) => {
|
||||
console.log('!!! follow:')
|
||||
await apiClient.follow({ what, slug })
|
||||
// refresh session
|
||||
// TODO: _store update code
|
||||
|
|
|
@ -16,7 +16,7 @@ main {
|
|||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
|
||||
.row {
|
||||
flex: 1;
|
||||
|
|
|
@ -167,11 +167,12 @@ export const apiClient = {
|
|||
// subscribe
|
||||
|
||||
follow: async ({ what, slug }: { what: FollowingEntity; slug: string }) => {
|
||||
const response = await privateGraphQLClient.query(followMutation, { what, slug }).toPromise()
|
||||
const response = await privateGraphQLClient.mutation(followMutation, { what, slug }).toPromise()
|
||||
console.debug('!!! [follow]:', response)
|
||||
return response.data.follow
|
||||
},
|
||||
unfollow: async ({ what, slug }: { what: FollowingEntity; slug: string }) => {
|
||||
const response = await privateGraphQLClient.query(unfollowMutation, { what, slug }).toPromise()
|
||||
const response = await privateGraphQLClient.mutation(unfollowMutation, { what, slug }).toPromise()
|
||||
return response.data.unfollow
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user