diff --git a/src/components/App.tsx b/src/components/App.tsx
index 3ce55f92..d896d3bd 100644
--- a/src/components/App.tsx
+++ b/src/components/App.tsx
@@ -41,6 +41,7 @@ import { SearchPage } from '../pages/search.page'
import { TopicPage } from '../pages/topic.page'
import { ROUTES, useRouter } from '../stores/router'
import { hideModal, MODALS, showModal } from '../stores/ui'
+import { AuthorizerProvider } from '../context/authorizer'
// TODO: lazy load
// const SomePage = lazy(() => import('./Pages/SomePage'))
@@ -119,15 +120,17 @@ export const App = (props: Props) => {
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/Feed/ArticleCard/ArticleCard.tsx b/src/components/Feed/ArticleCard/ArticleCard.tsx
index 73a7a317..1988eb0b 100644
--- a/src/components/Feed/ArticleCard/ArticleCard.tsx
+++ b/src/components/Feed/ArticleCard/ArticleCard.tsx
@@ -99,7 +99,7 @@ export const ArticleCard = (props: ArticleCardProps) => {
const canEdit = () =>
props.article.authors?.some((a) => a.slug === author()?.slug) ||
- props.article.created_by?.id === author().id
+ props.article.created_by?.id === author()?.id
const { changeSearchParam } = useRouter()
const scrollToComments = (event) => {
diff --git a/src/context/authorizer.tsx b/src/context/authorizer.tsx
index 13f724ca..9fc1f70d 100644
--- a/src/context/authorizer.tsx
+++ b/src/context/authorizer.tsx
@@ -29,7 +29,7 @@ type AuthorizerContextActions = {
}
const config: ConfigType = {
authorizerURL: 'https://auth.discours.io',
- redirectURL: 'https://discoursio-webapp.vercel.app',
+ redirectURL: 'https://discoursio-webapp.vercel.app/?modal=auth',
clientID: '9c113377-5eea-4c89-98e1-69302462fc08', // FIXME: use env?
}
@@ -51,9 +51,6 @@ const AuthorizerContext = createContext<[AuthorizerState, AuthorizerContextActio
])
type AuthorizerProviderProps = {
- authorizerURL: string
- redirectURL: string
- clientID: string
onStateChangeCallback?: (stateData: AuthorizerState) => void
}
@@ -62,19 +59,14 @@ export const AuthorizerProvider: ParentComponent = (pro
user: null,
token: null,
loading: true,
- config: {
- authorizerURL: props.authorizerURL,
- redirectURL: props.redirectURL,
- clientID: props.clientID,
- } as ConfigType,
+ config,
})
- const [redirect, setRedirect] = createSignal()
const authorizer = createMemo(
() =>
new Authorizer({
- authorizerURL: props.authorizerURL,
- redirectURL: redirect(),
- clientID: props.clientID,
+ authorizerURL: state.config.authorizerURL,
+ redirectURL: state.config.redirectURL,
+ clientID: state.config.clientID,
}),
)
@@ -157,7 +149,7 @@ export const AuthorizerProvider: ParentComponent = (pro
}
onMount(() => {
- setRedirect(window.location.origin)
+ setState('config', { ...config, redirectURL: window.location.origin + '/?modal=auth' })
!state.token && getToken()
})
diff --git a/src/context/session.tsx b/src/context/session.tsx
index 60181e65..5b9ad302 100644
--- a/src/context/session.tsx
+++ b/src/context/session.tsx
@@ -67,17 +67,18 @@ export const SessionProvider = (props: { children: JSX.Element }) => {
const getSession = async (): Promise => {
try {
const token = getToken()
- const authResult = await authorizer().getSession({
- Authorization: token,
- })
- if (authResult && authResult.access_token) {
- console.log(authResult)
- setToken(authResult.access_token)
- loadSubscriptions()
- return authResult
- } else {
- return null
+ if (token) {
+ const authResult = await authorizer().getSession({
+ Authorization: token,
+ })
+ if (authResult && authResult.access_token) {
+ console.log(authResult)
+ setToken(authResult.access_token)
+ loadSubscriptions()
+ return authResult
+ }
}
+ return null
} catch (error) {
console.error('getSession error:', error)
resetToken()
diff --git a/src/graphql/query/core/my-followed.ts b/src/graphql/query/core/my-followed.ts
index bd0618d3..f33808fd 100644
--- a/src/graphql/query/core/my-followed.ts
+++ b/src/graphql/query/core/my-followed.ts
@@ -16,7 +16,7 @@ export default gql`
pic
created_at
}
- communitites {
+ communities {
id
name
slug
diff --git a/src/pages/article.page.tsx b/src/pages/article.page.tsx
index 8ec9681f..752d2fd1 100644
--- a/src/pages/article.page.tsx
+++ b/src/pages/article.page.tsx
@@ -42,7 +42,11 @@ export const ArticlePage = (props: PageProps) => {
script.src = 'https://ackee.discours.io/increment.js'
script.dataset.ackeeServer = 'https://ackee.discours.io'
script.dataset.ackeeDomainId = '1004abeb-89b2-4e85-ad97-74f8d2c8ed2d'
- document.body.appendChild(script)
+ try {
+ document.body.appendChild(script)
+ } catch (err) {
+ console.warn(err)
+ }
})
const [scrollToComments, setScrollToComments] = createSignal(false)