diff --git a/.lintstagedrc b/.lintstagedrc index 292224b9..0641af7e 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,5 +1,5 @@ { "*.{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" ] } diff --git a/src/components/Author/AuthorBadge/AuthorBadge.tsx b/src/components/Author/AuthorBadge/AuthorBadge.tsx index 3b0a384d..84f3ba54 100644 --- a/src/components/Author/AuthorBadge/AuthorBadge.tsx +++ b/src/components/Author/AuthorBadge/AuthorBadge.tsx @@ -76,7 +76,6 @@ export const AuthorBadge = (props: Props) => { () => { setIsFollowed(props.isFollowed.value) }, - { defer: true }, ), ) diff --git a/src/components/Author/AuthorCard/AuthorCard.tsx b/src/components/Author/AuthorCard/AuthorCard.tsx index 241f2185..5ffea38d 100644 --- a/src/components/Author/AuthorCard/AuthorCard.tsx +++ b/src/components/Author/AuthorCard/AuthorCard.tsx @@ -32,37 +32,30 @@ type Props = { export const AuthorCard = (props: Props) => { const { t, lang } = useLocalize() const { author, isSessionLoaded, requireAuthentication } = useSession() - const { setFollowing } = useFollowing() const [authorSubs, setAuthorSubs] = createSignal>([]) const [subscriptionFilter, setSubscriptionFilter] = createSignal('all') const [isFollowed, setIsFollowed] = createSignal() const isProfileOwner = createMemo(() => author()?.slug === props.author.slug) - const isSubscribed = () => props.followers?.some((entity) => entity.id === author()?.id) + const { setFollowing, isOwnerSubscribed } = useFollowing() - createEffect( - on( - () => props.followers, - () => { - setIsFollowed(isSubscribed()) - }, - { defer: true }, - ), - ) + onMount(() => { + setAuthorSubs(props.following) + }) + + createEffect(() => { + setIsFollowed(isOwnerSubscribed(props.author?.id)) + }) const name = createMemo(() => { if (lang() !== 'ru' && isCyrillic(props.author.name)) { if (props.author.name === 'Дискурс') { return 'Discours' } - return translit(props.author.name) } - return props.author.name }) - onMount(() => setAuthorSubs(props.following)) - // TODO: reimplement AuthorCard const { changeSearchParams } = useRouter() const initChat = () => { @@ -98,7 +91,7 @@ export const AuthorCard = (props: Props) => { } const followButtonText = createMemo(() => { - if (isFollowed()) { + if (isOwnerSubscribed(props.author?.id)) { return ( <> {t('Following')} @@ -106,7 +99,6 @@ export const AuthorCard = (props: Props) => { ) } - return t('Follow') }) @@ -204,12 +196,11 @@ export const AuthorCard = (props: Props) => { - - +