Merge remote-tracking branch 'origin/prepare-inbox' into prepare-inbox
This commit is contained in:
commit
b46603c553
|
@ -1,5 +1,5 @@
|
|||
overwrite: true
|
||||
schema: 'https://testapi.discours.io'
|
||||
schema: 'http://localhost:8080'
|
||||
generates:
|
||||
src/graphql/introspec.gen.ts:
|
||||
plugins:
|
||||
|
|
|
@ -8,7 +8,7 @@ type SessionContextType = {
|
|||
session: InitializedResource<AuthResult>
|
||||
isAuthenticated: Accessor<boolean>
|
||||
actions: {
|
||||
refreshSession: () => AuthResult | Promise<AuthResult>
|
||||
getSession: () => AuthResult | Promise<AuthResult>
|
||||
signIn: ({ email, password }: { email: string; password: string }) => Promise<void>
|
||||
signOut: () => Promise<void>
|
||||
confirmEmail: (token: string) => Promise<void>
|
||||
|
@ -17,7 +17,7 @@ type SessionContextType = {
|
|||
|
||||
const SessionContext = createContext<SessionContextType>()
|
||||
|
||||
const refreshSession = async (): Promise<AuthResult> => {
|
||||
const getSession = async (): Promise<AuthResult> => {
|
||||
try {
|
||||
const authResult = await apiClient.getSession()
|
||||
if (!authResult) {
|
||||
|
@ -37,7 +37,7 @@ export function useSession() {
|
|||
}
|
||||
|
||||
export const SessionProvider = (props: { children: JSX.Element }) => {
|
||||
const [session, { refetch: refetchRefreshSession, mutate }] = createResource<AuthResult>(refreshSession, {
|
||||
const [session, { refetch: refetchSession, mutate }] = createResource<AuthResult>(getSession, {
|
||||
ssrLoadFrom: 'initial',
|
||||
initialValue: null
|
||||
})
|
||||
|
@ -65,7 +65,7 @@ export const SessionProvider = (props: { children: JSX.Element }) => {
|
|||
}
|
||||
|
||||
const actions = {
|
||||
refreshSession: refetchRefreshSession,
|
||||
getSession: refetchSession,
|
||||
signIn,
|
||||
signOut,
|
||||
confirmEmail
|
||||
|
@ -74,7 +74,7 @@ export const SessionProvider = (props: { children: JSX.Element }) => {
|
|||
const value: SessionContextType = { session, isAuthenticated, actions }
|
||||
|
||||
onMount(() => {
|
||||
refetchRefreshSession()
|
||||
refetchSession()
|
||||
})
|
||||
|
||||
return <SessionContext.Provider value={value}>{props.children}</SessionContext.Provider>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
mutation RefreshSessionMutation {
|
||||
refreshSession {
|
||||
mutation GetSessionMutation {
|
||||
getSession {
|
||||
error
|
||||
token
|
||||
user {
|
||||
|
|
|
@ -32,6 +32,7 @@ const options: ClientOptions = {
|
|||
// меняем через setToken, например при получении значения с сервера
|
||||
// скорее всего придумаем что-нибудь получше со временем
|
||||
const token = localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)
|
||||
if (token === null) alert('token is null')
|
||||
const headers = { Authorization: token }
|
||||
return { headers }
|
||||
},
|
||||
|
|
|
@ -176,11 +176,11 @@ export type Mutation = {
|
|||
deleteShout: Result
|
||||
destroyTopic: Result
|
||||
follow: Result
|
||||
getSession: AuthResult
|
||||
inviteAuthor: Result
|
||||
inviteChat: Result
|
||||
markAsRead: Result
|
||||
rateUser: Result
|
||||
refreshSession: AuthResult
|
||||
registerUser: AuthResult
|
||||
removeAuthor: Result
|
||||
sendLink: Result
|
||||
|
@ -661,10 +661,7 @@ export type TopicInput = {
|
|||
|
||||
export type TopicStat = {
|
||||
authors: Scalars['Int']
|
||||
commented?: Maybe<Scalars['Int']>
|
||||
followers: Scalars['Int']
|
||||
rating?: Maybe<Scalars['Int']>
|
||||
reacted: Scalars['Int']
|
||||
shouts: Scalars['Int']
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { createPresignedPost } from '@aws-sdk/s3-presigned-post'
|
|||
|
||||
export default async function handler(req, res) {
|
||||
const s3Client = new S3Client({
|
||||
region: process.env.S3_REGION,
|
||||
region: process.env.S3_REGION || 'eu-west-1',
|
||||
credentials: {
|
||||
accessKeyId: process.env.S3_ACCESS_KEY,
|
||||
secretAccessKey: process.env.S3_SECRET_KEY
|
||||
|
@ -13,7 +13,7 @@ export default async function handler(req, res) {
|
|||
})
|
||||
|
||||
const post = await createPresignedPost(s3Client, {
|
||||
Bucket: process.env.S3_BUCKET_NAME,
|
||||
Bucket: process.env.S3_BUCKET_NAME || 'discours-io',
|
||||
Key: req.query.file,
|
||||
Fields: {
|
||||
acl: 'public-read',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createStorageSignal } from '@solid-primitives/storage'
|
||||
|
||||
// local stored seen marks by shout's slug
|
||||
// TODO: use indexedDB here
|
||||
export const [seen, setSeen] = createStorageSignal<{ [slug: string]: Date }>('seen', {})
|
||||
export const addSeen = (slug) => setSeen({ ...seen(), [slug]: Date.now() })
|
||||
|
||||
|
|
|
@ -185,11 +185,11 @@ export const apiClient = {
|
|||
throw new ApiError('unknown', response.error.message)
|
||||
}
|
||||
|
||||
if (response.data?.refreshSession?.error) {
|
||||
throw new ApiError('unknown', response.data.refreshSession.error)
|
||||
if (response.data?.getSession?.error) {
|
||||
throw new ApiError('unknown', response.data.getSession.error)
|
||||
}
|
||||
|
||||
return response.data.refreshSession
|
||||
return response.data.getSession
|
||||
},
|
||||
getAllTopics: async () => {
|
||||
const response = await publicGraphQLClient.query(topicsAll, {}).toPromise()
|
||||
|
|
Loading…
Reference in New Issue
Block a user