Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Chat name & color modal (#2347)

Philippae61b8d8268e
diff --git a/core/chat/events.go b/core/chat/events.go
index fa4d0b45c6..892d264217 100644
--- a/core/chat/events.go
+++ b/core/chat/events.go
@@ -114,6 +114,10 @@ func (s *Server) userColorChanged(eventData chatClientEvent) {
if err := user.ChangeUserColor(eventData.client.User.ID, receivedEvent.NewColor); err != nil {
log.Errorln("error changing user display color", err)
}
+
+ // Resend client's user info with new color, otherwise the name change dialog would still show the old color
+ eventData.client.User.DisplayColor = receivedEvent.NewColor
+ eventData.client.sendConnectedClientInfo()
}
func (s *Server) userMessageSent(eventData chatClientEvent) {
diff --git a/web/components/modals/NameChangeModal/NameChangeModal.tsx b/web/components/modals/NameChangeModal/NameChangeModal.tsx
index dfb3cc12ff..6571614aaf 100644
--- a/web/components/modals/NameChangeModal/NameChangeModal.tsx
+++ b/web/components/modals/NameChangeModal/NameChangeModal.tsx
@@ -1,6 +1,6 @@
import React, { CSSProperties, FC, useState } from 'react';
import { useRecoilValue } from 'recoil';
-import { Input, Button, Select } from 'antd';
+import { Input, Button, Select, Form } from 'antd';
import { MessageType } from '../../../interfaces/socket-events';
import WebsocketService from '../../../services/websocket-service';
import { websocketServiceAtom, currentUserAtom } from '../../stores/ClientConfigStore';
@@ -32,7 +32,12 @@ export const NameChangeModal: FC = () => {
const { displayName, displayColor } = currentUser;
+ const saveEnabled = () =>
+ newName !== displayName && newName !== '' && websocketService?.isConnected();
+
const handleNameChange = () => {
+ if (!saveEnabled()) return;
+
const nameChange = {
type: MessageType.NAME_CHANGE,
newName,
@@ -40,8 +45,6 @@ export const NameChangeModal: FC = () => {
websocketService.send(nameChange);
};
- const saveEnabled = newName !== displayName && newName !== '' && websocketService?.isConnected();
-
const handleColorChange = (color: string) => {
const colorChange = {
type: MessageType.COLOR_CHANGE,
@@ -53,29 +56,32 @@ export const NameChangeModal: FC = () => {
const maxColor = 8; // 0...n
const colorOptions = [...Array(maxColor)].map((e, i) => i);
+ const saveButton = (
+ <Button type="primary" onClick={handleNameChange} disabled={!saveEnabled()}>
+ Change name
+ </Button>
+ );
+
return (
<div>
- Your chat display name is what people see when you send chat messages. Other information can
- go here to mention auth, and stuff.
- <Input
- id="name-change-field"
- value={newName}
- onChange={e => setNewName(e.target.value)}
- placeholder="Your chat display name"
- maxLength={30}
- showCount
- defaultValue={displayName}
- />
- <Button id="name-change-submit" disabled={!saveEnabled} onClick={handleNameChange}>
- Change name
- </Button>
- <div>
- Your Color
+ Your chat display name is what people see when you send chat messages.
+ <Form onSubmitCapture={handleNameChange} style={{ paddingTop: '8px' }}>
+ <Input.Search
+ enterButton={saveButton}
+ id="name-change-field"
+ value={newName}
+ onChange={e => setNewName(e.target.value)}
+ placeholder="Your chat display name"
+ maxLength={30}
+ showCount
+ defaultValue={displayName}
+ />
+ </Form>
+ <Form.Item label="Your Color" style={{ paddingTop: '8px', zIndex: 1000, marginBottom: 0 }}>
<Select
style={{ width: 120 }}
onChange={handleColorChange}
defaultValue={displayColor.toString()}
- getPopupContainer={triggerNode => triggerNode.parentElement}
>
{colorOptions.map(e => (
<Option key={e.toString()} title={e}>
@@ -83,7 +89,9 @@ export const NameChangeModal: FC = () => {
</Option>
))}
</Select>
- </div>
+ </Form.Item>
+ You can also authenticate an IndieAuth or Fediverse account via the &quot;Authenticate&quot;
+ menu.
</div>
);
};
diff --git a/web/components/ui/Modal/Modal.tsx b/web/components/ui/Modal/Modal.tsx
index 6a5d5e2b77..0aa4f5febf 100644
--- a/web/components/ui/Modal/Modal.tsx
+++ b/web/components/ui/Modal/Modal.tsx
@@ -58,7 +58,7 @@ export const Modal: FC<ModalProps> = ({
afterClose={afterClose}
bodyStyle={modalStyle}
width={width}
- zIndex={9999}
+ zIndex={999}
footer={null}
centered
destroyOnClose
diff --git a/web/styles/ant-overrides.scss b/web/styles/ant-overrides.scss
index 5f024f14a9..d2d792d886 100644
--- a/web/styles/ant-overrides.scss
+++ b/web/styles/ant-overrides.scss
@@ -130,7 +130,7 @@ DROPDOWN
}
.ant-input-affix-wrapper {
- padding: 2px 5px;
+ padding: 4px 5px;
background-color: var(--theme-color-components-form-field-background);
}