Add option to hide viewer count. Closes #1939

This commit is contained in:
Gabe Kangas
2022-06-26 00:46:55 -07:00
parent 97db93e0d7
commit b08393295f
11 changed files with 209 additions and 125 deletions

View File

@@ -15,6 +15,7 @@ import {
API_YP_SWITCH,
FIELD_PROPS_YP,
FIELD_PROPS_NSFW,
FIELD_PROPS_HIDE_VIEWER_COUNT,
} from '../../utils/config-constants';
import { UpdateArgs } from '../../types/config-section';
@@ -61,6 +62,10 @@ export default function EditInstanceDetails() {
});
};
function handleHideViewerCountChange(enabled: boolean) {
handleFieldChange({ fieldName: 'hideViewerCount', value: enabled });
}
const hasInstanceUrl = instanceUrl !== '';
return (
@@ -100,6 +105,14 @@ export default function EditInstanceDetails() {
{/* Logo section */}
<EditLogo />
<ToggleSwitch
fieldName="hideViewerCount"
useSubmit
{...FIELD_PROPS_HIDE_VIEWER_COUNT}
checked={formDataValues.hideViewerCount}
onChange={handleHideViewerCountChange}
/>
<br />
<p className="description">
Increase your audience by appearing in the{' '}

View File

@@ -40,12 +40,12 @@ export default function Statusbar(props: Props) {
if (online && lastConnectTime) {
const duration = makeDurationString(new Date(lastConnectTime));
onlineMessage = online ? `Live for ${duration}` : 'Offline';
rightSideMessage = (
rightSideMessage = viewerCount > 0 && (
<span>
<EyeOutlined /> {viewerCount}
</span>
);
} else {
} else if (!online) {
onlineMessage = 'Offline';
if (lastDisconnectTime) {
rightSideMessage = `Last live ${formatDistanceToNow(new Date(lastDisconnectTime))} ago.`;