Skip to content

Commit

Permalink
[fix] 방송 중에 ID 및 닉네임을 바꿀 수 없도록 수정 (#218)
Browse files Browse the repository at this point in the history
fix : 방송 중에 ID 및 닉네임을 바꿀 수 없도록 수정
  • Loading branch information
Novrule authored Dec 14, 2023
1 parent cc07602 commit a0aaf82
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion client/src/components/Modal/SettingModal/SettingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { filterState } from '@/states/filter'
import { userState } from '@/states/user'

interface SettingModalProps {
authority: 'viewer' | 'streamer'
onConfirm: (changeUser: boolean) => void
}

const SettingModal = ({ onConfirm }: SettingModalProps) => {
const SettingModal = ({ authority, onConfirm }: SettingModalProps) => {
const [currentTheme, setTheme] = useRecoilState(themeState)
const [filter, setFilter] = useRecoilState(filterState)
const [user, setUser] = useRecoilState(userState)
Expand Down Expand Up @@ -42,6 +43,11 @@ const SettingModal = ({ onConfirm }: SettingModalProps) => {
setId(user.id)
alert('올바른 ID를 입력해주세요.')

return
} else if (authority === 'streamer') {
setId(user.id)
alert('방숭 중에는 ID를 변경할 수 없습니다.')

return
} else if (id.trim() === user.id) {
setId(user.id)
Expand Down Expand Up @@ -92,6 +98,11 @@ const SettingModal = ({ onConfirm }: SettingModalProps) => {
setNickname(user.nickname)
alert('올바른 닉네임을 입력해주세요.')

return
} else if (authority === 'streamer') {
setNickname(user.nickname)
alert('방숭 중에는 닉네임을 변경할 수 없습니다.')

return
} else if (nickname.trim() === user.nickname) {
setNickname(user.nickname)
Expand Down
4 changes: 3 additions & 1 deletion client/src/pages/BroadcastPage/BroadcastPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ const BroadcastPage = () => {

const onEnter = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (event.nativeEvent.isComposing || settingModal === true || loginModal === true || viewerModal === true || confirmModal === true) {
setChatting('')

return
} else if (event.key === 'Enter' && event.shiftKey === false) {
event.preventDefault()
Expand Down Expand Up @@ -272,7 +274,7 @@ const BroadcastPage = () => {
<styles.Nickname>{streamer.nickname}</styles.Nickname>
<styles.Viewer>시청자 {streamer.viewer.toLocaleString()}</styles.Viewer>
</styles.Info>
{settingModal && <SettingModal onConfirm={onSetting} />}
{settingModal && <SettingModal authority={getAuthority()} onConfirm={onSetting} />}
{loginModal && <LoginModal onCancle={onLogin} currentTheme={theme} />}
{viewerModal && (
<ViewerModal
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/MainPage/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const MainPage = () => {
<EmptyList currentTheme={theme} />
)}
</styles.List>
{settingModal && <SettingModal onConfirm={onSetting} />}
{settingModal && <SettingModal authority={'viewer'} onConfirm={onSetting} />}
{loginModal && <LoginModal onCancle={onLogin} currentTheme={theme} />}
{confirmModal && <ConfirmModal text="방송 목록을 가져오는데 실패했습니다." onConfirm={onConfirm} currentTheme={theme} />}
</styles.Container>
Expand Down
3 changes: 2 additions & 1 deletion server/api-server/src/streams/streams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ReadStreamDto } from './dto/read-stream.dto';
import { PageDto } from 'src/common/dto/page.dto';
import { ChatGateway } from 'src/chat/chat.gateway';
import { ThumbnailsService } from 'src/thumbnails/thumbnails.service';
import { VideoInfoDto } from './dto/video-info.dto';

@Injectable()
export class StreamsService {
Expand Down Expand Up @@ -72,7 +73,7 @@ export class StreamsService {
const videoInfos = await this.videoInfoProvider.getVideoInfo();
const { streamKey, ...videoInfo } = videoInfos.find(
(info) => info.streamKey === user.stream.streamKey,
);
) ?? { streamKey: "" } as VideoInfoDto;

return {
userId,
Expand Down

0 comments on commit a0aaf82

Please sign in to comment.