all-authors-topics-stat-fixes

This commit is contained in:
tonyrewin 2022-11-25 08:54:19 +03:00
parent 451602beb5
commit aea582cf5e
6 changed files with 33 additions and 25 deletions

View File

@ -52,11 +52,15 @@ export const FullArticle = (props: ArticleProps) => {
)
onMount(() => {
const script = document.createElement('script')
script.async = true
script.src = 'https://ackee.discours.io/increment.js'
script.setAttribute('data-ackee-server', 'https://ackee.discours.io')
script.setAttribute('data-ackee-domain-id', '1004abeb-89b2-4e85-ad97-74f8d2c8ed2d')
document.body.appendChild(script)
const windowHash = window.location.hash
if (windowHash?.length > 0) {
const comments = document.querySelector(windowHash)
if (comments) {
window.scrollTo({
top: comments.getBoundingClientRect().top,

View File

@ -29,14 +29,19 @@ export const AllAuthorsView = (props: Props) => {
const { searchParams, changeSearchParam } = useRouter<AllAuthorsPageSearchParams>()
const { sortedAuthors } = useAuthorsStore({
authors: props.authors,
sortBy: searchParams().by || 'shouts'
sortBy: searchParams().by || 'name'
})
const { session } = useSession()
onMount(() => changeSearchParam('by', 'shouts'))
onMount(() => {
if (!searchParams().by) {
setAuthorsSort('name')
changeSearchParam('by', 'name')
}
})
createEffect(() => {
setAuthorsSort(searchParams().by || 'shouts')
setAuthorsSort(searchParams().by || 'name')
setLimit(PAGE_SIZE)
})
@ -211,7 +216,7 @@ export const AllAuthorsView = (props: Props) => {
</div>
</Show>
<Show when={sortedAuthors().length > limit()}>
<Show when={searchParams().by !== 'name' && sortedAuthors().length > limit()}>
<div class="row">
<div class={clsx(styles.loadMoreContainer, 'col-12 col-md-10')}>
<button class={clsx('button', styles.loadMoreButton)} onClick={showMore}>

View File

@ -35,7 +35,12 @@ export const AllTopicsView = (props: AllTopicsViewProps) => {
const { session } = useSession()
onMount(() => changeSearchParam('by', 'shouts'))
onMount(() => {
if (!searchParams().by) {
setTopicsSort('shouts')
changeSearchParam('by', 'shouts')
}
})
createEffect(() => {
setTopicsSort(searchParams().by || 'shouts')
setLimit(PAGE_SIZE)

View File

@ -13,18 +13,19 @@ interface StatMetricsProps {
const pseudonames = {
// topics: 'topics' # amount of topics for community💥
followed: 'followers',
followers: 'followers',
reacted: 'involvings',
reactions: 'involvings',
commented: 'discoussions',
comments: 'discussions',
shouts: 'posts',
authors: 'authors'
followed: 'follower',
followers: 'follower',
rating: 'like',
viewed: 'view',
views: 'view',
reacted: 'involving',
reactions: 'involving',
commented: 'discussion',
comments: 'discussion',
shouts: 'post',
authors: 'author'
}
const nos = (s) => s.slice(-1)
export const StatMetrics = (props: StatMetricsProps) => {
return (
<div class={styles.statMetrics}>
@ -33,7 +34,7 @@ export const StatMetrics = (props: StatMetricsProps) => {
<span class={styles.statMetricsItem} classList={{ compact: props.compact }}>
{props.stat[entity] +
' ' +
t((pseudonames[entity] || entity).slice(-1)) +
t(pseudonames[entity] || entity.slice(-1)) +
plural(props.stat[entity] || 0, locale() === 'ru' ? ['ов', '', 'а'] : ['s', '', 's'])}
</span>
)}

View File

@ -8,8 +8,6 @@ export default gql`
name
bio
userpic
links
lastSeen
stat {
shouts
followers

View File

@ -16,11 +16,6 @@ setLocale(lang)
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/png" href="/favicon.png" />
<title>{t('Discours')}</title>
<script async
src="https://ackee.discours.io/increment.js"
data-ackee-server="https://ackee.discours.io"
data-ackee-domain-id="1004abeb-89b2-4e85-ad97-74f8d2c8ed2d"
></script>
</head>
<body>
<slot />