diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx
index 5e94c4a8..a8854832 100644
--- a/src/components/Article/Comment/Comment.tsx
+++ b/src/components/Article/Comment/Comment.tsx
@@ -48,7 +48,7 @@ export const Comment = (props: Props) => {
const canEdit = createMemo(
() =>
Boolean(author()?.id) &&
- (props.comment?.created_by?.slug === author().slug || session()?.user?.roles.includes('editor')),
+ (props.comment?.created_by?.slug === author()?.slug || session()?.user?.roles.includes('editor')),
)
const body = createMemo(() => (editedBody() ? editedBody().trim() : props.comment.body.trim() || ''))
diff --git a/src/components/Author/AuthorCard/AuthorCard.tsx b/src/components/Author/AuthorCard/AuthorCard.tsx
index 5df81631..9804b6e3 100644
--- a/src/components/Author/AuthorCard/AuthorCard.tsx
+++ b/src/components/Author/AuthorCard/AuthorCard.tsx
@@ -17,8 +17,8 @@ import { SharePopup, getShareUrl } from '../../Article/SharePopup'
import { Modal } from '../../Nav/Modal'
import { TopicBadge } from '../../Topic/TopicBadge'
import { Button } from '../../_shared/Button'
+import { FollowingCounters } from '../../_shared/FollowingCounters'
import { ShowOnlyOnClient } from '../../_shared/ShowOnlyOnClient'
-import { Subscribers } from '../../_shared/Subscribers'
import { AuthorBadge } from '../AuthorBadge'
import { Userpic } from '../Userpic'
@@ -195,7 +195,7 @@ export const AuthorCard = (props: Props) => {
0 || props.flatFollows?.length > 0}>
-
{
{t('Subscription')}
{t('Join our maillist')}
-
+
diff --git a/src/components/Nav/Header/Header.tsx b/src/components/Nav/Header/Header.tsx
index 680dd886..f161364d 100644
--- a/src/components/Nav/Header/Header.tsx
+++ b/src/components/Nav/Header/Header.tsx
@@ -11,7 +11,7 @@ import { useModalStore } from '../../../stores/ui'
import { getDescription } from '../../../utils/meta'
import { SharePopup, getShareUrl } from '../../Article/SharePopup'
import { Icon } from '../../_shared/Icon'
-import { Subscribe } from '../../_shared/Subscribe'
+import { Newsletter } from '../../_shared/Newsletter'
import { AuthModal } from '../AuthModal'
import { ConfirmModal } from '../ConfirmModal'
import { HeaderAuth } from '../HeaderAuth'
@@ -301,7 +301,7 @@ export const Header = (props: Props) => {
{t('Newsletter')}
-
+
{t('Language')}
- {
- -
+
-
{
{author().stat.shouts}
- -
+
-
{
{author().stat.comments}
- -
+
-
checkBioHeight()}
href={getPagePath(router, 'authorAbout', {
@@ -284,38 +270,31 @@ export const AuthorView = (props: Props) => {
0}>
-
-
-
+
-
-
-
-
-
-
-
-
- 3}>
-
-
-
-
-
-
-
-
- {(page) => (
- <>
-
-
-
-
-
-
- >
- )}
-
+ 1}>
+
+
+
+
+
+
+
+ 3}>
+
+ {(page) => (
+ <>
+
+
+
+
+
+
+ >
+ )}
+
+
+
diff --git a/src/components/_shared/Subscribers/Subscribers.module.scss b/src/components/_shared/FollowingCounters/FollowingCounters.module.scss
similarity index 100%
rename from src/components/_shared/Subscribers/Subscribers.module.scss
rename to src/components/_shared/FollowingCounters/FollowingCounters.module.scss
diff --git a/src/components/_shared/Subscribers/Subscribers.tsx b/src/components/_shared/FollowingCounters/FollowingCounters.tsx
similarity index 94%
rename from src/components/_shared/Subscribers/Subscribers.tsx
rename to src/components/_shared/FollowingCounters/FollowingCounters.tsx
index d3814a20..fc2228da 100644
--- a/src/components/_shared/Subscribers/Subscribers.tsx
+++ b/src/components/_shared/FollowingCounters/FollowingCounters.tsx
@@ -5,7 +5,7 @@ import { useLocalize } from '../../../context/localize'
import { Author, Topic } from '../../../graphql/schema/core.gen'
import { Userpic } from '../../Author/Userpic'
-import styles from './Subscribers.module.scss'
+import styles from './FollowingCounters.module.scss'
type Props = {
followers?: Author[]
@@ -14,7 +14,7 @@ type Props = {
followingAmount?: number
}
-export const Subscribers = (props: Props) => {
+export const FollowingCounters = (props: Props) => {
const { t } = useLocalize()
return (
diff --git a/src/components/_shared/FollowingCounters/index.ts b/src/components/_shared/FollowingCounters/index.ts
new file mode 100644
index 00000000..33e34c6b
--- /dev/null
+++ b/src/components/_shared/FollowingCounters/index.ts
@@ -0,0 +1 @@
+export { FollowingCounters } from './FollowingCounters'
diff --git a/src/components/_shared/Subscribe/Subscribe.module.scss b/src/components/_shared/Newsletter/Newsletter.module.scss
similarity index 100%
rename from src/components/_shared/Subscribe/Subscribe.module.scss
rename to src/components/_shared/Newsletter/Newsletter.module.scss
diff --git a/src/components/_shared/Subscribe/Subscribe.tsx b/src/components/_shared/Newsletter/Newsletter.tsx
similarity index 97%
rename from src/components/_shared/Subscribe/Subscribe.tsx
rename to src/components/_shared/Newsletter/Newsletter.tsx
index 63c2341e..d1fa00fc 100644
--- a/src/components/_shared/Subscribe/Subscribe.tsx
+++ b/src/components/_shared/Newsletter/Newsletter.tsx
@@ -6,12 +6,12 @@ import { validateEmail } from '../../../utils/validateEmail'
import { Button } from '../Button'
import { Icon } from '../Icon'
-import styles from './Subscribe.module.scss'
+import styles from './Newsletter.module.scss'
type Props = {
variant?: 'mobileSubscription'
}
-export const Subscribe = (props: Props) => {
+export const Newsletter = (props: Props) => {
const { t } = useLocalize()
const [title, setTitle] = createSignal('')
diff --git a/src/components/_shared/Newsletter/index.ts b/src/components/_shared/Newsletter/index.ts
new file mode 100644
index 00000000..e8f0e231
--- /dev/null
+++ b/src/components/_shared/Newsletter/index.ts
@@ -0,0 +1 @@
+export { Newsletter } from './Newsletter'
diff --git a/src/components/_shared/Subscribe/index.ts b/src/components/_shared/Subscribe/index.ts
deleted file mode 100644
index 77ee7e60..00000000
--- a/src/components/_shared/Subscribe/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { Subscribe } from './Subscribe'
diff --git a/src/components/_shared/Subscribers/index.ts b/src/components/_shared/Subscribers/index.ts
deleted file mode 100644
index cfa0eef9..00000000
--- a/src/components/_shared/Subscribers/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { Subscribers } from './Subscribers'
diff --git a/src/context/session.tsx b/src/context/session.tsx
index 92502b83..7e35e6c3 100644
--- a/src/context/session.tsx
+++ b/src/context/session.tsx
@@ -32,7 +32,7 @@ import { inboxClient } from '../graphql/client/chat'
import { apiClient } from '../graphql/client/core'
import { useRouter } from '../stores/router'
import { showModal } from '../stores/ui'
-import { addAuthors } from '../stores/zine/authors'
+import { addAuthors, loadAuthor } from '../stores/zine/authors'
import { authApiUrl } from '../utils/config'
import { useLocalize } from './localize'
@@ -203,7 +203,6 @@ export const SessionProvider = (props: {
ssrLoadFrom: 'initial',
initialValue: null,
})
- const author = createMemo(() => session()?.user?.app_data?.profile)
const checkSessionIsExpired = () => {
const expires_at_data = localStorage.getItem('expires_at')
@@ -225,38 +224,46 @@ export const SessionProvider = (props: {
onCleanup(() => clearTimeout(minuteLater))
+ const [author, setAuthor] = createSignal()
// when session is loaded
createEffect(
on(
- session,
- (s: AuthToken) => {
+ () => session(),
+ async (s: AuthToken) => {
if (s) {
const token = s?.access_token
- if (token) {
- if (!inboxClient.private) {
- apiClient.connect(token)
- inboxClient.connect(token)
- }
-
- try {
- const profile = session()?.user?.app_data?.profile
- if (profile?.id) addAuthors([profile])
- } catch (e) {
- console.error(e)
- }
+ const profile = s?.user?.app_data?.profile
+ if (token && !inboxClient.private) {
+ apiClient.connect(token)
+ inboxClient.connect(token)
+ }
+ if (profile?.id) {
+ addAuthors([profile])
+ setAuthor(profile)
setIsSessionLoaded(true)
} else {
- reset()
+ console.warn('app_data is empty')
+ if (s?.user) {
+ try {
+ const a = await loadAuthor({ slug: s?.user?.nickname })
+ addAuthors([a])
+ setAuthor(a)
+ s.user.app_data.profile = a
+ } catch (error) {
+ console.error('Error loading author:', error)
+ }
+ } else {
+ console.warn(s)
+ setSession(null)
+ setAuthor(null)
+ setIsSessionLoaded(true)
+ }
}
}
},
{ defer: true },
),
)
- const reset = () => {
- setIsSessionLoaded(true)
- setSession(null)
- }
// initial effect
onMount(() => {
@@ -311,7 +318,8 @@ export const SessionProvider = (props: {
const signOut = async () => {
const authResult: ApiResponse = await authorizer().logout()
console.debug(authResult)
- reset()
+ setSession(null)
+ setIsSessionLoaded(true)
showSnackbar({ body: t("You've successfully logged out") })
console.debug(session())
}
diff --git a/src/graphql/query/core/author-followers.ts b/src/graphql/query/core/author-followers.ts
index 1c8373b8..df6e5e59 100644
--- a/src/graphql/query/core/author-followers.ts
+++ b/src/graphql/query/core/author-followers.ts
@@ -1,7 +1,7 @@
import { gql } from '@urql/core'
export default gql`
- query UserSubscribersQuery($slug: String, $user: String, $author_id: Int) {
+ query UserFollowingCountersQuery($slug: String, $user: String, $author_id: Int) {
get_author_followers(slug: $slug, user: $user, author_id: $author_id) {
id
slug
diff --git a/src/pages/about/manifest.page.tsx b/src/pages/about/manifest.page.tsx
index 7599bdce..0c205e64 100644
--- a/src/pages/about/manifest.page.tsx
+++ b/src/pages/about/manifest.page.tsx
@@ -4,7 +4,7 @@ import { Feedback } from '../../components/Discours/Feedback'
import { Modal } from '../../components/Nav/Modal'
import Opener from '../../components/Nav/Modal/Opener'
import { StaticPage } from '../../components/Views/StaticPage'
-import { Subscribe } from '../../components/_shared/Subscribe'
+import { Newsletter } from '../../components/_shared/Newsletter'
import { useLocalize } from '../../context/localize'
import { getImageUrl } from '../../utils/getImageUrl'
@@ -24,7 +24,7 @@ export const ManifestPage = () => {
-
+