1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-18 01:50:50 +00:00

feat: allow viewer count to be hidden

This commit is contained in:
Ash Keel 2023-10-28 21:49:40 +02:00
parent 7941e0699d
commit 525399049a
No known key found for this signature in database
GPG key ID: 53A9E9A6035DD109
4 changed files with 19 additions and 6 deletions

View file

@ -259,7 +259,7 @@
"dashboard": { "dashboard": {
"twitch-status": "Twitch stream status", "twitch-status": "Twitch stream status",
"live": "Live!", "live": "Live!",
"x-viewers": "{{count}} viewers", "x-viewers": "{{num}} viewers",
"not-live": "Offline / Not streaming", "not-live": "Offline / Not streaming",
"twitch-events": { "twitch-events": {
"header": "Recent events", "header": "Recent events",

View file

@ -143,7 +143,7 @@
"live": "In onda!", "live": "In onda!",
"not-live": "Offline / Non in streaming", "not-live": "Offline / Non in streaming",
"twitch-status": "Stato stream Twitch", "twitch-status": "Stato stream Twitch",
"x-viewers": "{{count}} spettatori", "x-viewers": "{{num}} spettatori",
"twitch-events": { "twitch-events": {
"anonymous": "Uno spettatore anonimo", "anonymous": "Uno spettatore anonimo",
"header": "Eventi recenti", "header": "Eventi recenti",

View file

@ -151,6 +151,7 @@ export interface UISettings {
onboardingDone: boolean; onboardingDone: boolean;
language: string; language: string;
theme: string; theme: string;
hideViewers: boolean;
} }
export enum ConnectionStatus { export enum ConnectionStatus {

View file

@ -5,11 +5,13 @@ import {
EventSubNotificationType, EventSubNotificationType,
unwrapEvent, unwrapEvent,
} from '~/lib/eventSub'; } from '~/lib/eventSub';
import { useLiveKey } from '~/lib/react'; import { useLiveKey, useModule } from '~/lib/react';
import { useAppSelector } from '~/store'; import { useAppDispatch, useAppSelector } from '~/store';
import { modules } from '~/store/api/reducer';
import { PageContainer, SectionHeader, styled, TextBlock } from '../theme'; import { PageContainer, SectionHeader, styled, TextBlock } from '../theme';
import BrowserLink from '../components/BrowserLink'; import BrowserLink from '../components/BrowserLink';
import Scrollbar from '../components/utils/Scrollbar'; import Scrollbar from '../components/utils/Scrollbar';
import RevealLink from '../components/utils/RevealLink';
interface StreamInfo { interface StreamInfo {
id: string; id: string;
@ -370,6 +372,9 @@ function TwitchEventLog({ events }: { events: EventSubNotification[] }) {
function TwitchStreamStatus({ info }: { info: StreamInfo }) { function TwitchStreamStatus({ info }: { info: StreamInfo }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [uiConfig, setUiConfig] = useModule(modules.uiConfig);
const dispatch = useAppDispatch();
console.log(uiConfig);
return ( return (
<StreamBlock> <StreamBlock>
<LiveIndicator <LiveIndicator
@ -387,8 +392,15 @@ function TwitchStreamStatus({ info }: { info: StreamInfo }) {
<StreamInfo> <StreamInfo>
{info.game_name} -{' '} {info.game_name} -{' '}
{t('pages.dashboard.x-viewers', { {t('pages.dashboard.x-viewers', {
count: info.viewer_count, num: uiConfig.hideViewers ? '...' : `${info.viewer_count}`,
})} })}{' '}
<RevealLink
value={!uiConfig.hideViewers}
setter={(newVal) => {
console.log(newVal);
void dispatch(setUiConfig({ ...uiConfig, hideViewers: !newVal }));
}}
/>
</StreamInfo> </StreamInfo>
</StreamBlock> </StreamBlock>
); );