mirror of
https://github.com/owncast/owncast.git
synced 2025-11-02 20:23:29 +08:00
Add support to disable chat join messages. Closes https://github.com/owncast/owncast/issues/1582 (#452)
This commit is contained in:
@ -15,6 +15,7 @@ import { UpdateArgs } from '../types/config-section';
|
|||||||
import {
|
import {
|
||||||
API_CHAT_FORBIDDEN_USERNAMES,
|
API_CHAT_FORBIDDEN_USERNAMES,
|
||||||
API_CHAT_SUGGESTED_USERNAMES,
|
API_CHAT_SUGGESTED_USERNAMES,
|
||||||
|
FIELD_PROPS_CHAT_JOIN_MESSAGES_ENABLED,
|
||||||
FIELD_PROPS_DISABLE_CHAT,
|
FIELD_PROPS_DISABLE_CHAT,
|
||||||
postConfigUpdateToAPI,
|
postConfigUpdateToAPI,
|
||||||
RESET_TIMEOUT,
|
RESET_TIMEOUT,
|
||||||
@ -32,7 +33,13 @@ export default function ConfigChat() {
|
|||||||
const serverStatusData = useContext(ServerStatusContext);
|
const serverStatusData = useContext(ServerStatusContext);
|
||||||
const { serverConfig, setFieldInConfigState } = serverStatusData || {};
|
const { serverConfig, setFieldInConfigState } = serverStatusData || {};
|
||||||
|
|
||||||
const { chatDisabled, forbiddenUsernames, instanceDetails, suggestedUsernames } = serverConfig;
|
const {
|
||||||
|
chatDisabled,
|
||||||
|
chatJoinMessagesEnabled,
|
||||||
|
forbiddenUsernames,
|
||||||
|
instanceDetails,
|
||||||
|
suggestedUsernames,
|
||||||
|
} = serverConfig;
|
||||||
const { welcomeMessage } = instanceDetails;
|
const { welcomeMessage } = instanceDetails;
|
||||||
|
|
||||||
const handleFieldChange = ({ fieldName, value }: UpdateArgs) => {
|
const handleFieldChange = ({ fieldName, value }: UpdateArgs) => {
|
||||||
@ -46,6 +53,10 @@ export default function ConfigChat() {
|
|||||||
handleFieldChange({ fieldName: 'chatDisabled', value: !disabled });
|
handleFieldChange({ fieldName: 'chatDisabled', value: !disabled });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleChatJoinMessagesEnabledChange(enabled: boolean) {
|
||||||
|
handleFieldChange({ fieldName: 'chatJoinMessagesEnabled', value: enabled });
|
||||||
|
}
|
||||||
|
|
||||||
function resetForbiddenUsernameState() {
|
function resetForbiddenUsernameState() {
|
||||||
setForbiddenUsernameSaveState(null);
|
setForbiddenUsernameSaveState(null);
|
||||||
}
|
}
|
||||||
@ -131,6 +142,7 @@ export default function ConfigChat() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFormDataValues({
|
setFormDataValues({
|
||||||
chatDisabled,
|
chatDisabled,
|
||||||
|
chatJoinMessagesEnabled,
|
||||||
forbiddenUsernames,
|
forbiddenUsernames,
|
||||||
suggestedUsernames,
|
suggestedUsernames,
|
||||||
welcomeMessage,
|
welcomeMessage,
|
||||||
@ -152,6 +164,12 @@ export default function ConfigChat() {
|
|||||||
reversed
|
reversed
|
||||||
onChange={handleChatDisableChange}
|
onChange={handleChatDisableChange}
|
||||||
/>
|
/>
|
||||||
|
<ToggleSwitch
|
||||||
|
fieldName="chatJoinMessagesEnabled"
|
||||||
|
{...FIELD_PROPS_CHAT_JOIN_MESSAGES_ENABLED}
|
||||||
|
checked={formDataValues.chatJoinMessagesEnabled}
|
||||||
|
onChange={handleChatJoinMessagesEnabledChange}
|
||||||
|
/>
|
||||||
<TextFieldWithSubmit
|
<TextFieldWithSubmit
|
||||||
fieldName="welcomeMessage"
|
fieldName="welcomeMessage"
|
||||||
{...TEXTFIELD_PROPS_SERVER_WELCOME_MESSAGE}
|
{...TEXTFIELD_PROPS_SERVER_WELCOME_MESSAGE}
|
||||||
|
|||||||
@ -113,5 +113,6 @@ export interface ConfigDetails {
|
|||||||
forbiddenUsernames: string[];
|
forbiddenUsernames: string[];
|
||||||
suggestedUsernames: string[];
|
suggestedUsernames: string[];
|
||||||
chatDisabled: boolean;
|
chatDisabled: boolean;
|
||||||
|
chatJoinMessagesEnabled: boolean;
|
||||||
federation: Federation;
|
federation: Federation;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ export const API_VIDEO_VARIANTS = '/video/streamoutputvariants';
|
|||||||
export const API_WEB_PORT = '/webserverport';
|
export const API_WEB_PORT = '/webserverport';
|
||||||
export const API_YP_SWITCH = '/directoryenabled';
|
export const API_YP_SWITCH = '/directoryenabled';
|
||||||
export const API_CHAT_DISABLE = '/chat/disable';
|
export const API_CHAT_DISABLE = '/chat/disable';
|
||||||
|
export const API_CHAT_JOIN_MESSAGES_ENABLED = '/chat/joinmessagesenabled';
|
||||||
export const API_CHAT_FORBIDDEN_USERNAMES = '/chat/forbiddenusernames';
|
export const API_CHAT_FORBIDDEN_USERNAMES = '/chat/forbiddenusernames';
|
||||||
export const API_CHAT_SUGGESTED_USERNAMES = '/chat/suggestedusernames';
|
export const API_CHAT_SUGGESTED_USERNAMES = '/chat/suggestedusernames';
|
||||||
export const API_EXTERNAL_ACTIONS = '/externalactions';
|
export const API_EXTERNAL_ACTIONS = '/externalactions';
|
||||||
@ -192,6 +193,14 @@ export const FIELD_PROPS_DISABLE_CHAT = {
|
|||||||
useSubmit: true,
|
useSubmit: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const FIELD_PROPS_CHAT_JOIN_MESSAGES_ENABLED = {
|
||||||
|
apiPath: API_CHAT_JOIN_MESSAGES_ENABLED,
|
||||||
|
configPath: '',
|
||||||
|
label: 'Join Messages',
|
||||||
|
tip: 'Show when a viewer joins the chat.',
|
||||||
|
useSubmit: true,
|
||||||
|
};
|
||||||
|
|
||||||
export const TEXTFIELD_PROPS_CHAT_FORBIDDEN_USERNAMES = {
|
export const TEXTFIELD_PROPS_CHAT_FORBIDDEN_USERNAMES = {
|
||||||
apiPath: API_CHAT_FORBIDDEN_USERNAMES,
|
apiPath: API_CHAT_FORBIDDEN_USERNAMES,
|
||||||
placeholder: 'username',
|
placeholder: 'username',
|
||||||
|
|||||||
@ -59,6 +59,7 @@ export const initialServerConfigState: ConfigDetails = {
|
|||||||
forbiddenUsernames: [],
|
forbiddenUsernames: [],
|
||||||
suggestedUsernames: [],
|
suggestedUsernames: [],
|
||||||
chatDisabled: false,
|
chatDisabled: false,
|
||||||
|
chatJoinMessagesEnabled: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialServerStatusState = {
|
const initialServerStatusState = {
|
||||||
|
|||||||
Reference in New Issue
Block a user