mirror of
https://github.com/owncast/owncast.git
synced 2024-11-25 14:20:54 +03:00
feat: close modal after name change (#3084)
* feat: close modal after name change * refactor: shortened modal name * fix: added a no-op for NameChangeModal storybook
This commit is contained in:
parent
f616f02be3
commit
6fa576a04a
3 changed files with 13 additions and 4 deletions
|
@ -86,6 +86,10 @@ export const UserDropdown: FC<UserDropdownProps> = ({
|
||||||
setShowNameChangeModal(true);
|
setShowNameChangeModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const closeChangeNameModal = () => {
|
||||||
|
setShowNameChangeModal(false);
|
||||||
|
};
|
||||||
|
|
||||||
// Register keyboard shortcut for the space bar to toggle playback
|
// Register keyboard shortcut for the space bar to toggle playback
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
'c',
|
'c',
|
||||||
|
@ -153,9 +157,9 @@ export const UserDropdown: FC<UserDropdownProps> = ({
|
||||||
<Modal
|
<Modal
|
||||||
title="Change Chat Display Name"
|
title="Change Chat Display Name"
|
||||||
open={showNameChangeModal}
|
open={showNameChangeModal}
|
||||||
handleCancel={() => setShowNameChangeModal(false)}
|
handleCancel={closeChangeNameModal}
|
||||||
>
|
>
|
||||||
<NameChangeModal />
|
<NameChangeModal closeModal={closeChangeNameModal} />
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal
|
<Modal
|
||||||
title="Authenticate"
|
title="Authenticate"
|
||||||
|
|
|
@ -27,7 +27,7 @@ const Example = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<NameChangeModal />
|
<NameChangeModal closeModal={() => {}} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,11 @@ const UserColor: FC<UserColorProps> = ({ color }) => {
|
||||||
return <div style={style} />;
|
return <div style={style} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NameChangeModal: FC = () => {
|
type NameChangeModalProps = {
|
||||||
|
closeModal: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NameChangeModal: FC<NameChangeModalProps> = ({ closeModal }) => {
|
||||||
const currentUser = useRecoilValue(currentUserAtom);
|
const currentUser = useRecoilValue(currentUserAtom);
|
||||||
const websocketService = useRecoilValue<WebsocketService>(websocketServiceAtom);
|
const websocketService = useRecoilValue<WebsocketService>(websocketServiceAtom);
|
||||||
const [newName, setNewName] = useState<string>(currentUser?.displayName);
|
const [newName, setNewName] = useState<string>(currentUser?.displayName);
|
||||||
|
@ -44,6 +48,7 @@ export const NameChangeModal: FC = () => {
|
||||||
newName,
|
newName,
|
||||||
};
|
};
|
||||||
websocketService.send(nameChange);
|
websocketService.send(nameChange);
|
||||||
|
closeModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleColorChange = (color: string) => {
|
const handleColorChange = (color: string) => {
|
||||||
|
|
Loading…
Reference in a new issue