refactori
This commit is contained in:
parent
fc2d956349
commit
e11916298e
|
@ -26,7 +26,7 @@ export const markdownOptions: AstroUserConfig['markdown'] = {
|
||||||
remarkPlugins: [remarkCodeTitles],
|
remarkPlugins: [remarkCodeTitles],
|
||||||
rehypePlugins: [
|
rehypePlugins: [
|
||||||
rehypeSlug,
|
rehypeSlug,
|
||||||
[rehypeToc as RehypePlugin<any[]>, { headings: ['h1', 'h2', 'h3'] }],
|
[rehypeToc as RehypePlugin<any>, { headings: ['h1', 'h2', 'h3'] }],
|
||||||
[rehypeAutolinkHeadings, { behavior: 'prepend' }],
|
[rehypeAutolinkHeadings, { behavior: 'prepend' }],
|
||||||
[addClasses, { 'h1,h2,h3': 'title' }]
|
[addClasses, { 'h1,h2,h3': 'title' }]
|
||||||
],
|
],
|
||||||
|
|
|
@ -63,8 +63,8 @@ export const FeedSidebar = (props: FeedSidebarProps) => {
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<For each={session()?.info?.authors}>
|
<For each={session()?.news?.authors}>
|
||||||
{(authorSlug) => (
|
{(authorSlug: string) => (
|
||||||
<li>
|
<li>
|
||||||
<a href={`/author/${authorSlug}`} classList={{ unread: checkAuthorIsSeen(authorSlug) }}>
|
<a href={`/author/${authorSlug}`} classList={{ unread: checkAuthorIsSeen(authorSlug) }}>
|
||||||
<small>@{authorSlug}</small>
|
<small>@{authorSlug}</small>
|
||||||
|
@ -74,8 +74,8 @@ export const FeedSidebar = (props: FeedSidebarProps) => {
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
|
|
||||||
<For each={session()?.info?.topics}>
|
<For each={session()?.news?.topics}>
|
||||||
{(topicSlug) => (
|
{(topicSlug: string) => (
|
||||||
<li>
|
<li>
|
||||||
<a href={`/author/${topicSlug}`} classList={{ unread: checkTopicIsSeen(topicSlug) }}>
|
<a href={`/author/${topicSlug}`} classList={{ unread: checkTopicIsSeen(topicSlug) }}>
|
||||||
{topicEntities()[topicSlug]?.title}
|
{topicEntities()[topicSlug]?.title}
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default () => {
|
||||||
<a href="/inbox">
|
<a href="/inbox">
|
||||||
{/*FIXME: replace with route*/}
|
{/*FIXME: replace with route*/}
|
||||||
<div classList={{ entered: getPage().path === '/inbox' }}>
|
<div classList={{ entered: getPage().path === '/inbox' }}>
|
||||||
<Icon name="inbox-white" counter={session().info?.unread || 0} />
|
<Icon name="inbox-white" counter={session()?.news?.unread || 0} />
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -24,11 +24,11 @@ export const TopicCard = (props: TopicProps) => {
|
||||||
const { session } = useAuthStore()
|
const { session } = useAuthStore()
|
||||||
|
|
||||||
const subscribed = createMemo(() => {
|
const subscribed = createMemo(() => {
|
||||||
if (!session()?.user?.slug || !session()?.info?.topics) {
|
if (!session()?.user?.slug || !session()?.news?.topics) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.topic.slug in session().info.topics
|
return session()?.news.topics.includes(props.topic.slug)
|
||||||
})
|
})
|
||||||
|
|
||||||
// FIXME use store actions
|
// FIXME use store actions
|
||||||
|
|
|
@ -14,7 +14,7 @@ type Props = {
|
||||||
export const FullTopic = (props: Props) => {
|
export const FullTopic = (props: Props) => {
|
||||||
const { session } = useAuthStore()
|
const { session } = useAuthStore()
|
||||||
|
|
||||||
const subscribed = createMemo(() => session()?.info?.topics?.includes(props.topic?.slug))
|
const subscribed = createMemo(() => session()?.news?.topics?.includes(props.topic?.slug))
|
||||||
return (
|
return (
|
||||||
<div class="topic-full container">
|
<div class="topic-full container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -26,7 +26,7 @@ export const AllAuthorsView = (props: Props) => {
|
||||||
|
|
||||||
const { session } = useAuthStore()
|
const { session } = useAuthStore()
|
||||||
|
|
||||||
const subscribed = (s) => Boolean(session()?.info?.authors && session()?.info?.authors?.includes(s || ''))
|
const subscribed = (s) => Boolean(session()?.news?.authors && session()?.news?.authors?.includes(s || ''))
|
||||||
|
|
||||||
const { getSearchParams } = useRouter<AllAuthorsPageSearchParams>()
|
const { getSearchParams } = useRouter<AllAuthorsPageSearchParams>()
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ export const AllTopicsView = (props: AllTopicsViewProps) => {
|
||||||
setSortAllTopicsBy(getSearchParams().by || 'shouts')
|
setSortAllTopicsBy(getSearchParams().by || 'shouts')
|
||||||
})
|
})
|
||||||
|
|
||||||
const subscribed = (s) => Boolean(session()?.info?.topics && session()?.info?.topics?.includes(s || ''))
|
const subscribed = (s) => Boolean(session()?.news?.topics && session()?.news?.topics?.includes(s || ''))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="all-topics-page">
|
<div class="all-topics-page">
|
||||||
|
|
|
@ -13,7 +13,8 @@ export default gql`
|
||||||
userpic
|
userpic
|
||||||
links
|
links
|
||||||
}
|
}
|
||||||
info {
|
news {
|
||||||
|
unread
|
||||||
inbox
|
inbox
|
||||||
topics
|
topics
|
||||||
authors
|
authors
|
||||||
|
|
|
@ -16,7 +16,7 @@ export type Scalars = {
|
||||||
|
|
||||||
export type AuthResult = {
|
export type AuthResult = {
|
||||||
error?: Maybe<Scalars['String']>
|
error?: Maybe<Scalars['String']>
|
||||||
info?: Maybe<SessionInfo>
|
news?: Maybe<UserFollowings>
|
||||||
token?: Maybe<Scalars['String']>
|
token?: Maybe<Scalars['String']>
|
||||||
user?: Maybe<User>
|
user?: Maybe<User>
|
||||||
}
|
}
|
||||||
|
@ -638,14 +638,6 @@ export type Role = {
|
||||||
permissions: Array<Permission>
|
permissions: Array<Permission>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SessionInfo = {
|
|
||||||
authors?: Maybe<Array<Maybe<Scalars['String']>>>
|
|
||||||
communities?: Maybe<Array<Maybe<Scalars['String']>>>
|
|
||||||
reactions?: Maybe<Array<Maybe<Scalars['Int']>>>
|
|
||||||
topics?: Maybe<Array<Maybe<Scalars['String']>>>
|
|
||||||
unread?: Maybe<Scalars['Int']>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Shout = {
|
export type Shout = {
|
||||||
authors?: Maybe<Array<Maybe<Author>>>
|
authors?: Maybe<Array<Maybe<Author>>>
|
||||||
body: Scalars['String']
|
body: Scalars['String']
|
||||||
|
@ -773,6 +765,14 @@ export type User = {
|
||||||
wasOnlineAt?: Maybe<Scalars['DateTime']>
|
wasOnlineAt?: Maybe<Scalars['DateTime']>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type UserFollowings = {
|
||||||
|
authors?: Maybe<Array<Maybe<Scalars['String']>>>
|
||||||
|
communities?: Maybe<Array<Maybe<Scalars['String']>>>
|
||||||
|
reactions?: Maybe<Array<Maybe<Scalars['Int']>>>
|
||||||
|
topics?: Maybe<Array<Maybe<Scalars['String']>>>
|
||||||
|
unread?: Maybe<Scalars['Int']>
|
||||||
|
}
|
||||||
|
|
||||||
export type UserNotification = {
|
export type UserNotification = {
|
||||||
id: Scalars['Int']
|
id: Scalars['Int']
|
||||||
kind: Scalars['String']
|
kind: Scalars['String']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user