nostylelint-stage
This commit is contained in:
commit
238a17a9de
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"*.{js,ts,cjs,mjs,d.mts,jsx,tsx,json,jsonc,scss,css}": [
|
"*.{js,ts,cjs,mjs,d.mts,jsx,tsx,json,jsonc,scss,css}": [
|
||||||
"npx @biomejs/biome check . --log-kind=compact --verbose --apply-unsafe && stylelint **/*.{scss,css}"
|
"npx @biomejs/biome check . --log-kind=compact --verbose --apply-unsafe"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,6 @@ export const AuthorBadge = (props: Props) => {
|
||||||
() => {
|
() => {
|
||||||
setIsFollowed(props.isFollowed.value)
|
setIsFollowed(props.isFollowed.value)
|
||||||
},
|
},
|
||||||
{ defer: true },
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -32,37 +32,30 @@ type Props = {
|
||||||
export const AuthorCard = (props: Props) => {
|
export const AuthorCard = (props: Props) => {
|
||||||
const { t, lang } = useLocalize()
|
const { t, lang } = useLocalize()
|
||||||
const { author, isSessionLoaded, requireAuthentication } = useSession()
|
const { author, isSessionLoaded, requireAuthentication } = useSession()
|
||||||
const { setFollowing } = useFollowing()
|
|
||||||
const [authorSubs, setAuthorSubs] = createSignal<Array<Author | Topic | Community>>([])
|
const [authorSubs, setAuthorSubs] = createSignal<Array<Author | Topic | Community>>([])
|
||||||
const [subscriptionFilter, setSubscriptionFilter] = createSignal<SubscriptionFilter>('all')
|
const [subscriptionFilter, setSubscriptionFilter] = createSignal<SubscriptionFilter>('all')
|
||||||
const [isFollowed, setIsFollowed] = createSignal<boolean>()
|
const [isFollowed, setIsFollowed] = createSignal<boolean>()
|
||||||
const isProfileOwner = createMemo(() => author()?.slug === props.author.slug)
|
const isProfileOwner = createMemo(() => author()?.slug === props.author.slug)
|
||||||
const isSubscribed = () => props.followers?.some((entity) => entity.id === author()?.id)
|
const { setFollowing, isOwnerSubscribed } = useFollowing()
|
||||||
|
|
||||||
createEffect(
|
onMount(() => {
|
||||||
on(
|
setAuthorSubs(props.following)
|
||||||
() => props.followers,
|
})
|
||||||
() => {
|
|
||||||
setIsFollowed(isSubscribed())
|
createEffect(() => {
|
||||||
},
|
setIsFollowed(isOwnerSubscribed(props.author?.id))
|
||||||
{ defer: true },
|
})
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
const name = createMemo(() => {
|
const name = createMemo(() => {
|
||||||
if (lang() !== 'ru' && isCyrillic(props.author.name)) {
|
if (lang() !== 'ru' && isCyrillic(props.author.name)) {
|
||||||
if (props.author.name === 'Дискурс') {
|
if (props.author.name === 'Дискурс') {
|
||||||
return 'Discours'
|
return 'Discours'
|
||||||
}
|
}
|
||||||
|
|
||||||
return translit(props.author.name)
|
return translit(props.author.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.author.name
|
return props.author.name
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(() => setAuthorSubs(props.following))
|
|
||||||
|
|
||||||
// TODO: reimplement AuthorCard
|
// TODO: reimplement AuthorCard
|
||||||
const { changeSearchParams } = useRouter()
|
const { changeSearchParams } = useRouter()
|
||||||
const initChat = () => {
|
const initChat = () => {
|
||||||
|
@ -98,7 +91,7 @@ export const AuthorCard = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const followButtonText = createMemo(() => {
|
const followButtonText = createMemo(() => {
|
||||||
if (isFollowed()) {
|
if (isOwnerSubscribed(props.author?.id)) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span class={stylesButton.buttonSubscribeLabel}>{t('Following')}</span>
|
<span class={stylesButton.buttonSubscribeLabel}>{t('Following')}</span>
|
||||||
|
@ -106,7 +99,6 @@ export const AuthorCard = (props: Props) => {
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return t('Follow')
|
return t('Follow')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -204,12 +196,11 @@ export const AuthorCard = (props: Props) => {
|
||||||
</For>
|
</For>
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show
|
<Show
|
||||||
when={isProfileOwner()}
|
when={isProfileOwner()}
|
||||||
fallback={
|
fallback={
|
||||||
<div class={styles.authorActions}>
|
<div class={styles.authorActions}>
|
||||||
<Show when={isFollowed()}>
|
<Show when={authorSubs().length}>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleFollowClick}
|
onClick={handleFollowClick}
|
||||||
value={followButtonText()}
|
value={followButtonText()}
|
||||||
|
@ -258,7 +249,15 @@ export const AuthorCard = (props: Props) => {
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-24">
|
<div class="col-24">
|
||||||
<For each={props.followers}>
|
<For each={props.followers}>
|
||||||
{(follower: Author) => <AuthorBadge author={follower} />}
|
{(follower: Author) => (
|
||||||
|
<AuthorBadge
|
||||||
|
author={follower}
|
||||||
|
isFollowed={{
|
||||||
|
loaded: Boolean(authorSubs()),
|
||||||
|
value: isOwnerSubscribed(follower.id),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</For>
|
</For>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -301,7 +300,13 @@ export const AuthorCard = (props: Props) => {
|
||||||
<For each={authorSubs()}>
|
<For each={authorSubs()}>
|
||||||
{(subscription) =>
|
{(subscription) =>
|
||||||
isAuthor(subscription) ? (
|
isAuthor(subscription) ? (
|
||||||
<AuthorBadge author={subscription} />
|
<AuthorBadge
|
||||||
|
isFollowed={{
|
||||||
|
loaded: Boolean(authorSubs()),
|
||||||
|
value: isOwnerSubscribed(subscription.id),
|
||||||
|
}}
|
||||||
|
author={subscription}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TopicBadge topic={subscription} />
|
<TopicBadge topic={subscription} />
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import type { Author, Shout, Topic } from '../../graphql/schema/core.gen'
|
import type { Author, Shout, Topic } from '../../graphql/schema/core.gen'
|
||||||
|
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { For, Show, createEffect, createSignal } from 'solid-js'
|
import { For, Show } from 'solid-js'
|
||||||
|
|
||||||
import { useFollowing } from '../../context/following'
|
import { useFollowing } from '../../context/following'
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
|
@ -30,12 +30,7 @@ type Props = {
|
||||||
|
|
||||||
export const Beside = (props: Props) => {
|
export const Beside = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const { subscriptions } = useFollowing()
|
const { isOwnerSubscribed } = useFollowing()
|
||||||
const [subscriptionsAuthorsId, setSubscriptionsAuthorsId] = createSignal<number[] | undefined>()
|
|
||||||
|
|
||||||
createEffect(() => {
|
|
||||||
setSubscriptionsAuthorsId(subscriptions?.authors?.map((item) => item.id) || [])
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Show when={!!props.beside?.slug && props.values?.length > 0}>
|
<Show when={!!props.beside?.slug && props.values?.length > 0}>
|
||||||
|
@ -94,8 +89,7 @@ export const Beside = (props: Props) => {
|
||||||
<AuthorBadge
|
<AuthorBadge
|
||||||
author={value as Author}
|
author={value as Author}
|
||||||
isFollowed={{
|
isFollowed={{
|
||||||
loaded: Boolean(subscriptionsAuthorsId()),
|
value: isOwnerSubscribed(value.id),
|
||||||
value: subscriptionsAuthorsId().includes(value.id),
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Meta } from '@solidjs/meta'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { For, Show, createEffect, createMemo, createSignal } from 'solid-js'
|
import { For, Show, createEffect, createMemo, createSignal } from 'solid-js'
|
||||||
|
|
||||||
|
import { useFollowing } from '../../context/following'
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
import { useRouter } from '../../stores/router'
|
import { useRouter } from '../../stores/router'
|
||||||
import { loadAuthors, setAuthorsSort, useAuthorsStore } from '../../stores/zine/authors'
|
import { loadAuthors, setAuthorsSort, useAuthorsStore } from '../../stores/zine/authors'
|
||||||
|
@ -83,6 +84,8 @@ export const AllAuthorsView = (props: Props) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { isOwnerSubscribed } = useFollowing()
|
||||||
|
|
||||||
const sortedKeys = createMemo<string[]>(() => {
|
const sortedKeys = createMemo<string[]>(() => {
|
||||||
const keys = Object.keys(byLetter())
|
const keys = Object.keys(byLetter())
|
||||||
keys.sort()
|
keys.sort()
|
||||||
|
@ -201,7 +204,13 @@ export const AllAuthorsView = (props: Props) => {
|
||||||
{(author) => (
|
{(author) => (
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-20 col-xl-18">
|
<div class="col-lg-20 col-xl-18">
|
||||||
<AuthorBadge author={author as Author} />
|
<AuthorBadge
|
||||||
|
author={author as Author}
|
||||||
|
isFollowed={{
|
||||||
|
loaded: Boolean(filteredAuthors()),
|
||||||
|
value: isOwnerSubscribed(author.id),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -20,6 +20,7 @@ interface FollowingContextType {
|
||||||
loadSubscriptions: () => void
|
loadSubscriptions: () => void
|
||||||
follow: (what: FollowingEntity, slug: string) => Promise<void>
|
follow: (what: FollowingEntity, slug: string) => Promise<void>
|
||||||
unfollow: (what: FollowingEntity, slug: string) => Promise<void>
|
unfollow: (what: FollowingEntity, slug: string) => Promise<void>
|
||||||
|
isOwnerSubscribed: (userId: number) => boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const FollowingContext = createContext<FollowingContextType>()
|
const FollowingContext = createContext<FollowingContextType>()
|
||||||
|
@ -108,10 +109,16 @@ export const FollowingProvider = (props: { children: JSX.Element }) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isOwnerSubscribed = (userId: number) => {
|
||||||
|
if (!author()) return
|
||||||
|
return !!subscriptions?.authors?.some((authorEntity) => authorEntity.id === userId)
|
||||||
|
}
|
||||||
|
|
||||||
const value: FollowingContextType = {
|
const value: FollowingContextType = {
|
||||||
loading,
|
loading,
|
||||||
subscriptions,
|
subscriptions,
|
||||||
setSubscriptions,
|
setSubscriptions,
|
||||||
|
isOwnerSubscribed,
|
||||||
setFollowing,
|
setFollowing,
|
||||||
loadSubscriptions: fetchData,
|
loadSubscriptions: fetchData,
|
||||||
follow,
|
follow,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user