From 89a55f7d15f067c3815bafd71fe2bff6e07def8d Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 6 Jun 2024 11:36:07 +0300 Subject: [PATCH] topic-fix --- public/locales/en/translation.json | 8 ++--- public/locales/ru/translation.json | 8 ++--- .../Author/AuthorBadge/AuthorBadge.tsx | 2 +- .../Topic/TopicBadge/TopicBadge.tsx | 8 ++--- src/components/Views/Topic.tsx | 32 ++++++++----------- 5 files changed, 26 insertions(+), 32 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index f2efa988..e3431ece 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -46,7 +46,7 @@ "Author": "Author", "authors": "authors", "Authors": "Authors", - "authorsWithCount": "{count} {count, plural, one {author} other {authors}}", + "some authors": "{count} {count, plural, one {author} other {authors}}", "Autotypograph": "Autotypograph", "Back": "Back", "Back to editor": "Back to editor", @@ -98,7 +98,7 @@ "Commentator": "Commentator", "Commenting": "Commenting", "Comments": "Comments", - "CommentsWithCount": "{count, plural, =0 {{count} comments} one {{count} comment} few {{count} comments} other {{count} comments}}", + "some comments": "{count, plural, =0 {{count} comments} one {{count} comment} few {{count} comments} other {{count} comments}}", "Common feed": "All", "Communities": "Communities", "community": "community", @@ -404,7 +404,7 @@ "Share": "Share", "Share publication": "Share publication", "shout": "post", - "shoutsWithCount": "{count} {count, plural, one {post} other {posts}}", + "some shouts": "{count} {count, plural, one {post} other {posts}}", "Show": "Show", "Show lyrics": "Show lyrics", "Show more": "Show more", @@ -553,4 +553,4 @@ "You've reached a non-existed page": "You've reached a non-existed page", "Your email": "Your email", "Your name will appear on your profile page and as your signature in publications, comments and responses.": "Your name will appear on your profile page and as your signature in publications, comments and responses" -} +} \ No newline at end of file diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index 33278b15..292830d3 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -50,7 +50,7 @@ "Author": "Автор", "authors": "авторы", "Authors": "Авторы", - "authorsWithCount": "{count} {count, plural, one {автор} few {автора} other {авторов}}", + "some authors": "{count} {count, plural, one {автор} few {автора} other {авторов}}", "Autotypograph": "Автотипограф", "Back": "Назад", "Back to editor": "Вернуться в редактор", @@ -103,7 +103,7 @@ "Commentator": "Комментатор", "Commenting": "Комментирование", "Comments": "Комментарии", - "CommentsWithCount": "{count, plural, =0 {{count} комментариев} one {{count} комментарий} few {{count} комментария} other {{count} комментариев}}", + "some comments": "{count, plural, =0 {{count} комментариев} one {{count} комментарий} few {{count} комментария} other {{count} комментариев}}", "Common feed": "Общая лента", "Communities": "Сообщества", "community": "сообщество", @@ -426,7 +426,7 @@ "Short opening": "Расскажите вашу историю...", "shout": "пост", "shout not found": "публикация не найдена", - "shoutsWithCount": "{count} {count, plural, one {публикация} few {публикации} other {публикаций}}", + "some shouts": "{count} {count, plural, one {публикация} few {публикации} other {публикаций}}", "Show": "Показать", "Show lyrics": "Текст песни", "Show more": "Читать дальше", @@ -579,4 +579,4 @@ "You've successfully logged out": "Вы успешно вышли из аккаунта", "Your email": "Ваш email", "Your name will appear on your profile page and as your signature in publications, comments and responses.": "Ваше имя появится на странице вашего профиля и как ваша подпись в публикациях, комментариях и откликах" -} +} \ No newline at end of file diff --git a/src/components/Author/AuthorBadge/AuthorBadge.tsx b/src/components/Author/AuthorBadge/AuthorBadge.tsx index 281c058f..8f0191e5 100644 --- a/src/components/Author/AuthorBadge/AuthorBadge.tsx +++ b/src/components/Author/AuthorBadge/AuthorBadge.tsx @@ -121,7 +121,7 @@ export const AuthorBadge = (props: Props) => {
{t('PublicationsWithCount', { count: props.author.stat?.shouts ?? 0 })}
0}> -
{t('CommentsWithCount', { count: props.author.stat?.comments ?? 0 })}
+
{t('some comments', { count: props.author.stat?.comments ?? 0 })}
0}>
{t('some followers', { count: props.author.stat?.followers ?? 0 })}
diff --git a/src/components/Topic/TopicBadge/TopicBadge.tsx b/src/components/Topic/TopicBadge/TopicBadge.tsx index fe708817..a07dca47 100644 --- a/src/components/Topic/TopicBadge/TopicBadge.tsx +++ b/src/components/Topic/TopicBadge/TopicBadge.tsx @@ -99,16 +99,14 @@ export const TopicBadge = (props: Props) => {
- {t('shoutsWithCount', { count: props.topic?.stat?.shouts })} - - {t('authorsWithCount', { count: props.topic?.stat?.authors })} - + {t('some shouts', { count: props.topic?.stat?.shouts })} + {t('some authors', { count: props.topic?.stat?.authors })} {t('some followers', { count: props.topic?.stat?.followers })} - {t('CommentsWithCount', { count: props.topic?.stat?.comments ?? 0 })} + {t('some comments', { count: props.topic?.stat?.comments ?? 0 })}
diff --git a/src/components/Views/Topic.tsx b/src/components/Views/Topic.tsx index 7389b3a5..785560f1 100644 --- a/src/components/Views/Topic.tsx +++ b/src/components/Views/Topic.tsx @@ -50,13 +50,21 @@ export const TopicView = (props: Props) => { const [reactedTopMonthArticles, setReactedTopMonthArticles] = createSignal([]) const [topic, setTopic] = createSignal() + createEffect( + on( + [topic, topicEntities], + ([t, ttt]) => { + if (props.topicSlug && !t && ttt) { + setTopic(ttt[props.topicSlug]) + loadTopicFollowers() + loadTopicAuthors() + loadRandom() + } + }, + { defer: true }, + ), + ) - createEffect(() => { - const topics = topicEntities() - if (props.topicSlug && !topic() && topics) { - setTopic(topics[props.topicSlug]) - } - }) const [followers, setFollowers] = createSignal(props.followers || []) const loadTopicFollowers = async () => { const result = await apiClient.getTopicFollowers({ slug: props.topicSlug }) @@ -99,18 +107,6 @@ export const TopicView = (props: Props) => { loadReactedTopMonthArticles(topic()?.slug) } - createEffect( - on( - () => topic()?.id, - (_) => { - loadTopicFollowers() - loadTopicAuthors() - loadRandom() - }, - { defer: true }, - ), - ) - const title = createMemo( () => `#${capitalize(