run fix checks

This commit is contained in:
ilya-bkv 2024-03-15 17:57:03 +03:00
parent edf4400627
commit d202845aab
6 changed files with 67 additions and 67 deletions

View File

@ -10,13 +10,13 @@ import { Author, FollowingEntity } from '../../../graphql/schema/core.gen'
import { router, useRouter } from '../../../stores/router'
import { translit } from '../../../utils/ru2en'
import { isCyrillic } from '../../../utils/translate'
import { BadgeSubscribeButton } from '../../_shared/BadgeSubscribeButton'
import { Button } from '../../_shared/Button'
import { CheckButton } from '../../_shared/CheckButton'
import { ConditionalWrapper } from '../../_shared/ConditionalWrapper'
import { Icon } from '../../_shared/Icon'
import { Userpic } from '../Userpic'
import styles from './AuthorBadge.module.scss'
import { BadgeSubscribeButton } from "../../_shared/BadgeSubscribeButton";
type Props = {
author: Author
@ -36,8 +36,8 @@ export const AuthorBadge = (props: Props) => {
const [isSubscribed, setIsSubscribed] = createSignal<boolean>()
createEffect(() => {
if(!subscriptions || !props.author) return
const subscribed = subscriptions.authors?.some((authorEntity) => authorEntity.id === props.author?.id);
if (!subscriptions || !props.author) return
const subscribed = subscriptions.authors?.some((authorEntity) => authorEntity.id === props.author?.id)
setIsSubscribed(subscribed)
})
@ -73,7 +73,9 @@ export const AuthorBadge = (props: Props) => {
const handleFollowClick = () => {
requireAuthentication(() => {
isSubscribed() ? unfollow(FollowingEntity.Author, props.author.slug) : follow(FollowingEntity.Author, props.author.slug)
isSubscribed()
? unfollow(FollowingEntity.Author, props.author.slug)
: follow(FollowingEntity.Author, props.author.slug)
}, 'subscribe')
}
@ -130,7 +132,9 @@ export const AuthorBadge = (props: Props) => {
<BadgeSubscribeButton
action={() => handleFollowClick()}
isSubscribed={isSubscribed()}
actionMessageType={subscribeInAction()?.slug === props.author.slug ? subscribeInAction().type : undefined}
actionMessageType={
subscribeInAction()?.slug === props.author.slug ? subscribeInAction().type : undefined
}
/>
<Show when={props.showMessageButton}>
<Button

View File

@ -43,8 +43,8 @@ export const AuthorCard = (props: Props) => {
})
createEffect(() => {
if(!subscriptions || !props.author) return
const subscribed = subscriptions.authors?.some((authorEntity) => authorEntity.id === props.author?.id);
if (!subscriptions || !props.author) return
const subscribed = subscriptions.authors?.some((authorEntity) => authorEntity.id === props.author?.id)
setIsSubscribed(subscribed)
})
@ -86,7 +86,9 @@ export const AuthorCard = (props: Props) => {
const handleFollowClick = () => {
requireAuthentication(() => {
isSubscribed() ? unfollow(FollowingEntity.Author, props.author.slug) : follow(FollowingEntity.Author, props.author.slug)
isSubscribed()
? unfollow(FollowingEntity.Author, props.author.slug)
: follow(FollowingEntity.Author, props.author.slug)
}, 'subscribe')
}
@ -123,9 +125,7 @@ export const AuthorCard = (props: Props) => {
<Show when={props.author.bio}>
<div class={styles.authorAbout} innerHTML={props.author.bio} />
</Show>
<Show
when={(props.followers?.length > 0) || (props.following?.length > 0)}
>
<Show when={props.followers?.length > 0 || props.following?.length > 0}>
<div class={styles.subscribersContainer}>
<Show when={props.followers && props.followers.length > 0}>
<a href="?m=followers" class={styles.subscribers}>
@ -251,9 +251,7 @@ export const AuthorCard = (props: Props) => {
<div class="row">
<div class="col-24">
<For each={props.followers}>
{(follower: Author) => (
<AuthorBadge author={follower}/>
)}
{(follower: Author) => <AuthorBadge author={follower} />}
</For>
</div>
</div>
@ -296,13 +294,9 @@ export const AuthorCard = (props: Props) => {
<For each={authorSubs()}>
{(subscription) =>
isAuthor(subscription) ? (
<AuthorBadge
author={subscription}
/>
<AuthorBadge author={subscription} />
) : (
<TopicBadge
topic={subscription}
/>
<TopicBadge topic={subscription} />
)
}
</For>

View File

@ -8,10 +8,10 @@ import { useSession } from '../../../context/session'
import { FollowingEntity, Topic } from '../../../graphql/schema/core.gen'
import { capitalize } from '../../../utils/capitalize'
import { getImageUrl } from '../../../utils/getImageUrl'
import { BadgeSubscribeButton } from '../../_shared/BadgeSubscribeButton'
import { Button } from '../../_shared/Button'
import { CheckButton } from '../../_shared/CheckButton'
import styles from './TopicBadge.module.scss'
import { BadgeSubscribeButton } from "../../_shared/BadgeSubscribeButton";
type Props = {
topic: Topic
@ -28,14 +28,16 @@ export const TopicBadge = (props: Props) => {
const { follow, unfollow, subscriptions, subscribeInAction } = useFollowing()
createEffect(() => {
if(!subscriptions || !props.topic) return
const subscribed = subscriptions.authors?.some((authorEntity) => authorEntity.id === props.topic?.id);
if (!subscriptions || !props.topic) return
const subscribed = subscriptions.authors?.some((authorEntity) => authorEntity.id === props.topic?.id)
setIsSubscribed(subscribed)
})
const handleFollowClick = () => {
requireAuthentication(() => {
isSubscribed() ? follow(FollowingEntity.Topic, props.topic.slug) : unfollow(FollowingEntity.Topic, props.topic.slug)
isSubscribed()
? follow(FollowingEntity.Topic, props.topic.slug)
: unfollow(FollowingEntity.Topic, props.topic.slug)
}, 'subscribe')
}
@ -80,7 +82,9 @@ export const TopicBadge = (props: Props) => {
<BadgeSubscribeButton
isSubscribed={isSubscribed()}
action={handleFollowClick}
actionMessageType={subscribeInAction()?.slug === props.topic.slug ? subscribeInAction().type : undefined}
actionMessageType={
subscribeInAction()?.slug === props.topic.slug ? subscribeInAction().type : undefined
}
/>
</div>
</div>

View File

@ -3,7 +3,7 @@ import type { Author, Reaction, Shout, Topic } from '../../../graphql/schema/cor
import { getPagePath } from '@nanostores/router'
import { Meta, Title } from '@solidjs/meta'
import { clsx } from 'clsx'
import { For, Match, Show, Switch, createEffect, createMemo, createSignal, onMount, on } from "solid-js";
import { For, Match, Show, Switch, createEffect, createMemo, createSignal, on, onMount } from 'solid-js'
import { useFollowing } from '../../../context/following'
import { useLocalize } from '../../../context/localize'

View File

@ -1,45 +1,45 @@
import { clsx } from "clsx";
import styles from "./BadgeDubscribeButton.module.scss";
import { CheckButton } from "../CheckButton";
import { createMemo, Show } from "solid-js";
import { Button } from "../Button";
import { Icon } from "../Icon";
import stylesButton from "../Button/Button.module.scss";
import { useLocalize } from "../../../context/localize";
import { useFollowing } from "../../../context/following";
import { clsx } from 'clsx'
import { Show, createMemo } from 'solid-js'
import { useFollowing } from '../../../context/following'
import { useLocalize } from '../../../context/localize'
import { Button } from '../Button'
import stylesButton from '../Button/Button.module.scss'
import { CheckButton } from '../CheckButton'
import { Icon } from '../Icon'
import styles from './BadgeDubscribeButton.module.scss'
type Props = {
class?: string;
isSubscribed: boolean;
minimizeSubscribeButton?: boolean;
action: () => void;
iconButtons?: boolean;
actionMessageType?: "subscribe" | "unsubscribe";
};
class?: string
isSubscribed: boolean
minimizeSubscribeButton?: boolean
action: () => void
iconButtons?: boolean
actionMessageType?: 'subscribe' | 'unsubscribe'
}
export const BadgeSubscribeButton = (props: Props) => {
const { t } = useLocalize();
const { t } = useLocalize()
const inActionText = createMemo(() => {
return props.actionMessageType === "subscribe" ? t("Subscribing...") : t("Unsubscribing...");
});
return props.actionMessageType === 'subscribe' ? t('Subscribing...') : t('Unsubscribing...')
})
return (
<div class={props.class}>
<Show
when={!props.minimizeSubscribeButton}
fallback={<CheckButton text={t("Follow")} checked={props.isSubscribed} onClick={props.action} />}
fallback={<CheckButton text={t('Follow')} checked={props.isSubscribed} onClick={props.action} />}
>
<Show
when={props.isSubscribed}
fallback={
<Button
variant={props.iconButtons ? "secondary" : "bordered"}
variant={props.iconButtons ? 'secondary' : 'bordered'}
size="S"
value={
<Show
when={props.iconButtons}
fallback={props.actionMessageType ? inActionText() : t("Subscribe")}
fallback={props.actionMessageType ? inActionText() : t('Subscribe')}
>
<Icon name="author-subscribe" class={stylesButton.icon} />
</Show>
@ -54,7 +54,7 @@ export const BadgeSubscribeButton = (props: Props) => {
}
>
<Button
variant={props.iconButtons ? "secondary" : "bordered"}
variant={props.iconButtons ? 'secondary' : 'bordered'}
size="S"
value={
<Show
@ -64,8 +64,8 @@ export const BadgeSubscribeButton = (props: Props) => {
inActionText()
) : (
<>
<span class={styles.actionButtonLabel}>{t("Following")}</span>
<span class={styles.actionButtonLabelHovered}>{t("Unfollow")}</span>
<span class={styles.actionButtonLabel}>{t('Following')}</span>
<span class={styles.actionButtonLabelHovered}>{t('Unfollow')}</span>
</>
)
}
@ -83,5 +83,5 @@ export const BadgeSubscribeButton = (props: Props) => {
</Show>
</Show>
</div>
);
};
)
}

View File

@ -1,8 +1,8 @@
import { Accessor, JSX, createContext, createEffect, createSignal, useContext, createMemo } from "solid-js";
import { Accessor, JSX, createContext, createEffect, createMemo, createSignal, useContext } from 'solid-js'
import { createStore } from 'solid-js/store'
import { apiClient } from '../graphql/client/core'
import { Author, AuthorFollows, Community, FollowingEntity, Topic } from "../graphql/schema/core.gen";
import { Author, AuthorFollows, Community, FollowingEntity, Topic } from '../graphql/schema/core.gen'
import { useSession } from './session'
@ -60,24 +60,23 @@ export const FollowingProvider = (props: { children: JSX.Element }) => {
}
createEffect(() => {
console.info('[context.following] subs:', subscriptions);
console.info('[context.following] subs:', subscriptions)
})
const follow = async (what: FollowingEntity, slug: string) => {
if (!author()) return;
setSubscribeInAction({ slug, type: 'subscribe' });
if (!author()) return
setSubscribeInAction({ slug, type: 'subscribe' })
try {
const subscriptionData = await apiClient.follow({ what, slug });
const subscriptionData = await apiClient.follow({ what, slug })
setSubscriptions((prevSubscriptions) => {
if (!prevSubscriptions[what]) prevSubscriptions[what] = [];
prevSubscriptions[what].push(subscriptionData);
return prevSubscriptions;
});
if (!prevSubscriptions[what]) prevSubscriptions[what] = []
prevSubscriptions[what].push(subscriptionData)
return prevSubscriptions
})
} catch (error) {
console.error(error);
console.error(error)
} finally {
setSubscribeInAction(); // Сбрасываем состояние действия подписки.
setSubscribeInAction() // Сбрасываем состояние действия подписки.
}
}
@ -93,7 +92,6 @@ export const FollowingProvider = (props: { children: JSX.Element }) => {
}
}
createEffect(() => {
if (author()) {
console.debug('[context.following] author update detect')