feat: hide scores if 'show scores' is disabled in profile

This commit is contained in:
Xylight committed 2024-09-05 17:43:44 -07:00
1 parent 683523d32c
commit f562c54efa
3 files changed
+32 -28

No files matched your search

@@ -126,6 +126,8 @@
bind:score={post.counts.score} bind:score={post.counts.score}
bind:upvotes={post.counts.upvotes} bind:upvotes={post.counts.upvotes}
bind:downvotes={post.counts.downvotes} bind:downvotes={post.counts.downvotes}
showCounts={$profile?.user?.local_user_view?.local_user?.show_scores ??
true}
/> />
<Button <Button
+30 -24
View File
@@ -35,6 +35,8 @@
export let upvotes: number = 0 export let upvotes: number = 0
export let downvotes: number = 0 export let downvotes: number = 0
export let showCounts: boolean = true
let loading = false let loading = false
let oldScore = score let oldScore = score
@@ -77,18 +79,20 @@
aria-label={$t('post.actions.vote.upvote')} aria-label={$t('post.actions.vote.upvote')}
> >
<Icon src={ChevronUp} size="20" micro /> <Icon src={ChevronUp} size="20" micro />
<span class="grid text-sm"> {#if showCounts}
{#key upvotes} <span class="grid text-sm">
<span {#key upvotes}
style="grid-column: 1; grid-row: 1;" <span
in:fly={{ duration: 400, y: -10, easing: backOut }} style="grid-column: 1; grid-row: 1;"
out:fly={{ duration: 400, y: 10, easing: backOut }} in:fly={{ duration: 400, y: -10, easing: backOut }}
aria-label={$t('aria.vote.upvotes', { default: upvotes })} out:fly={{ duration: 400, y: 10, easing: backOut }}
> aria-label={$t('aria.vote.upvotes', { default: upvotes })}
<FormattedNumber number={upvotes} /> >
</span> <FormattedNumber number={upvotes} />
{/key} </span>
</span> {/key}
</span>
{/if}
</button> </button>
{#if $site?.site_view.local_site.enable_downvotes ?? true} {#if $site?.site_view.local_site.enable_downvotes ?? true}
<button <button
@@ -101,18 +105,20 @@
aria-label={$t('post.actions.vote.downvote')} aria-label={$t('post.actions.vote.downvote')}
> >
<Icon src={ChevronDown} size="20" micro /> <Icon src={ChevronDown} size="20" micro />
<span class="grid text-sm"> {#if showCounts}
{#key downvotes} <span class="grid text-sm">
<span {#key downvotes}
style="grid-column: 1; grid-row: 1;" <span
in:fly={{ duration: 400, y: -10, easing: backOut }} style="grid-column: 1; grid-row: 1;"
out:fly={{ duration: 400, y: 10, easing: backOut }} in:fly={{ duration: 400, y: -10, easing: backOut }}
aria-label={$t('aria.vote.downvotes', { default: downvotes })} out:fly={{ duration: 400, y: 10, easing: backOut }}
> aria-label={$t('aria.vote.downvotes', { default: downvotes })}
<FormattedNumber number={downvotes} /> >
</span> <FormattedNumber number={downvotes} />
{/key} </span>
</span> {/key}
</span>
{/if}
</button> </button>
{/if} {/if}
</div> </div>
-4
View File
@@ -1,9 +1,5 @@
import { profile } from '$lib/auth.js'
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte' import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js'
import type { ListingType, SortType } from 'lemmy-js-client'
import { get } from 'svelte/store'
export async function load(req: any) { export async function load(req: any) {
const community = await getClient(undefined, req.fetch).getCommunity({ const community = await getClient(undefined, req.fetch).getCommunity({