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 {
|
||||
API_CHAT_FORBIDDEN_USERNAMES,
|
||||
API_CHAT_SUGGESTED_USERNAMES,
|
||||
FIELD_PROPS_CHAT_JOIN_MESSAGES_ENABLED,
|
||||
FIELD_PROPS_DISABLE_CHAT,
|
||||
postConfigUpdateToAPI,
|
||||
RESET_TIMEOUT,
|
||||
@@ -32,7 +33,13 @@ export default function ConfigChat() {
|
||||
const serverStatusData = useContext(ServerStatusContext);
|
||||
const { serverConfig, setFieldInConfigState } = serverStatusData || {};
|
||||
|
||||
const { chatDisabled, forbiddenUsernames, instanceDetails, suggestedUsernames } = serverConfig;
|
||||
const {
|
||||
chatDisabled,
|
||||
chatJoinMessagesEnabled,
|
||||
forbiddenUsernames,
|
||||
instanceDetails,
|
||||
suggestedUsernames,
|
||||
} = serverConfig;
|
||||
const { welcomeMessage } = instanceDetails;
|
||||
|
||||
const handleFieldChange = ({ fieldName, value }: UpdateArgs) => {
|
||||
@@ -46,6 +53,10 @@ export default function ConfigChat() {
|
||||
handleFieldChange({ fieldName: 'chatDisabled', value: !disabled });
|
||||
}
|
||||
|
||||
function handleChatJoinMessagesEnabledChange(enabled: boolean) {
|
||||
handleFieldChange({ fieldName: 'chatJoinMessagesEnabled', value: enabled });
|
||||
}
|
||||
|
||||
function resetForbiddenUsernameState() {
|
||||
setForbiddenUsernameSaveState(null);
|
||||
}
|
||||
@@ -131,6 +142,7 @@ export default function ConfigChat() {
|
||||
useEffect(() => {
|
||||
setFormDataValues({
|
||||
chatDisabled,
|
||||
chatJoinMessagesEnabled,
|
||||
forbiddenUsernames,
|
||||
suggestedUsernames,
|
||||
welcomeMessage,
|
||||
@@ -152,6 +164,12 @@ export default function ConfigChat() {
|
||||
reversed
|
||||
onChange={handleChatDisableChange}
|
||||
/>
|
||||
<ToggleSwitch
|
||||
fieldName="chatJoinMessagesEnabled"
|
||||
{...FIELD_PROPS_CHAT_JOIN_MESSAGES_ENABLED}
|
||||
checked={formDataValues.chatJoinMessagesEnabled}
|
||||
onChange={handleChatJoinMessagesEnabledChange}
|
||||
/>
|
||||
<TextFieldWithSubmit
|
||||
fieldName="welcomeMessage"
|
||||
{...TEXTFIELD_PROPS_SERVER_WELCOME_MESSAGE}
|
||||
|
||||
Reference in New Issue
Block a user