From b7ab62c5adf9e53a1c497fe41e7be5f0c40e702f Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 8 Dec 2023 14:49:50 +0300 Subject: [PATCH] banner image url fix --- src/components/Discours/Banner.tsx | 6 +----- src/components/Feed/ArticleCard/ArticleCard.tsx | 2 +- src/components/Nav/HeaderAuth.tsx | 4 ++-- src/components/Topic/Card.tsx | 12 ++++++++---- src/components/Topic/TopicBadge/TopicBadge.tsx | 7 +++++-- src/components/Views/AllTopics.tsx | 11 ++++++++--- src/components/Views/Feed.tsx | 6 ++++-- src/context/connect.tsx | 10 +++++----- src/graphql/query/core/article-load.ts | 1 + 9 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/components/Discours/Banner.tsx b/src/components/Discours/Banner.tsx index 49085a73..3cb43c32 100644 --- a/src/components/Discours/Banner.tsx +++ b/src/components/Discours/Banner.tsx @@ -23,11 +23,7 @@ export default () => {

- {t('Discours')} + {t('Discours')}
diff --git a/src/components/Feed/ArticleCard/ArticleCard.tsx b/src/components/Feed/ArticleCard/ArticleCard.tsx index c6a1e115..f5f95296 100644 --- a/src/components/Feed/ArticleCard/ArticleCard.tsx +++ b/src/components/Feed/ArticleCard/ArticleCard.tsx @@ -96,7 +96,7 @@ export const ArticleCard = (props: ArticleCardProps) => { const canEdit = () => props.article.authors?.some((a) => a.slug === author()?.slug) || - props.article.created_by.id === author().id + props.article.created_by?.id === author().id const { changeSearchParam } = useRouter() const scrollToComments = (event) => { diff --git a/src/components/Nav/HeaderAuth.tsx b/src/components/Nav/HeaderAuth.tsx index 28a76f83..5bf7c96c 100644 --- a/src/components/Nav/HeaderAuth.tsx +++ b/src/components/Nav/HeaderAuth.tsx @@ -221,8 +221,8 @@ export const HeaderAuth = (props: Props) => {
diff --git a/src/components/Topic/Card.tsx b/src/components/Topic/Card.tsx index 87b6398e..07b96c6e 100644 --- a/src/components/Topic/Card.tsx +++ b/src/components/Topic/Card.tsx @@ -35,7 +35,7 @@ interface TopicProps { } export const TopicCard = (props: TopicProps) => { - const { t } = useLocalize() + const { t, lang } = useLocalize() const { subscriptions, isSessionLoaded, @@ -83,6 +83,10 @@ export const TopicCard = (props: TopicProps) => { ) } + const title = createMemo(() => + capitalize(lang() == 'en' ? props.topic.slug.replace(/-/, ' ') : props.topic.title || ''), + ) + return (
{ !props.subscribeButtonBottom && !props.isNarrow && !props.compact, }} > - +

- {capitalize(props.topic.title || '')} + {title()}

@@ -114,7 +118,7 @@ export const TopicCard = (props: TopicProps) => { diff --git a/src/components/Topic/TopicBadge/TopicBadge.tsx b/src/components/Topic/TopicBadge/TopicBadge.tsx index 549df70a..17b11cea 100644 --- a/src/components/Topic/TopicBadge/TopicBadge.tsx +++ b/src/components/Topic/TopicBadge/TopicBadge.tsx @@ -10,6 +10,7 @@ import { Button } from '../../_shared/Button' import { CheckButton } from '../../_shared/CheckButton' import styles from './TopicBadge.module.scss' +import { capitalize } from '../../../utils/capitalize' type Props = { topic: Topic @@ -18,7 +19,7 @@ type Props = { export const TopicBadge = (props: Props) => { const [isSubscribing, setIsSubscribing] = createSignal(false) - const { t } = useLocalize() + const { t, lang } = useLocalize() const { isAuthenticated, subscriptions, @@ -52,7 +53,9 @@ export const TopicBadge = (props: Props) => { } /> - {props.topic.title} + + {lang() == 'en' ? capitalize(props.topic.slug.replace(/-/, ' ')) : props.topic.title} + { const { t, lang } = useLocalize() const { searchParams, changeSearchParam } = useRouter() const [limit, setLimit] = createSignal(PAGE_SIZE) + const ALPHABET = + lang() === 'ru' ? [...'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ#'] : [...'ABCDEFGHIJKLMNOPQRSTUVWXYZ#'] const { sortedTopics } = useTopicsStore({ topics: props.topics, @@ -52,8 +54,9 @@ export const AllTopicsView = (props: AllTopicsViewProps) => { const byLetter = createMemo<{ [letter: string]: Topic[] }>(() => { return sortedTopics().reduce( (acc, topic) => { - let letter = topic.title[0].toUpperCase() + let letter = lang() == 'en' ? topic.slug[0].toUpperCase() : topic.title[0].toUpperCase() if (/[^ËА-яё]/.test(letter) && lang() === 'ru') letter = '#' + if (/[^A-z]/.test(letter) && lang() === 'en') letter = '#' if (!acc[letter]) acc[letter] = [] acc[letter].push(topic) return acc @@ -143,7 +146,9 @@ export const AllTopicsView = (props: AllTopicsViewProps) => { {(topic) => ( )} diff --git a/src/components/Views/Feed.tsx b/src/components/Views/Feed.tsx index 32a80fe1..c0a6273e 100644 --- a/src/components/Views/Feed.tsx +++ b/src/components/Views/Feed.tsx @@ -48,7 +48,7 @@ type Props = { } export const FeedView = (props: Props) => { - const { t } = useLocalize() + const { t, lang } = useLocalize() const { page, searchParams } = useRouter() const [isLoading, setIsLoading] = createSignal(false) @@ -227,7 +227,9 @@ export const FeedView = (props: Props) => { {(topic) => ( - {topic.title}{' '} + + {lang() == 'en' ? topic.slug.replace(/-/, ' ') : topic.title} + {' '} )} diff --git a/src/context/connect.tsx b/src/context/connect.tsx index 7a0d1f13..0419adc6 100644 --- a/src/context/connect.tsx +++ b/src/context/connect.tsx @@ -59,16 +59,16 @@ export const ConnectProvider = (props: { children: JSX.Element }) => { setConnected(false) }, onerror(err) { - console.error('[context.connect] sse connection closed by error', err) + console.error('[context.connect] sse connection error', err) setConnected(false) throw new Error(err) // NOTE: simple hack to close the connection }, }) } catch (err) { - console.error(err) - setRetried((r) => r + 1) - if (retried() + 1 > 3) { - console.warn('not trying to reconnect anymore, listen() should be called again') + if (retried() < 4) { + setRetried((r) => r + 1) + } else { + console.warn('Not trying to reconnect anymore; listen() should be called again.') } } } diff --git a/src/graphql/query/core/article-load.ts b/src/graphql/query/core/article-load.ts index e415a271..70820fe0 100644 --- a/src/graphql/query/core/article-load.ts +++ b/src/graphql/query/core/article-load.ts @@ -12,6 +12,7 @@ export default gql` slug layout cover + cover_caption body media updated_by {