Skip to content

Commit

Permalink
Merge pull request #305 from boostcampwm-2021/dev
Browse files Browse the repository at this point in the history
Release 1.0.4
  • Loading branch information
zaehuun authored Dec 4, 2021
2 parents 89fb82f + 9102d8f commit b591e21
Show file tree
Hide file tree
Showing 30 changed files with 129 additions and 84 deletions.
2 changes: 2 additions & 0 deletions client/src/components/room/RoomCard/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const RoomCardWrapper = styled.div`
flex-direction: column;
background-color: ${({ theme }) => theme.colors.white};
padding: ${({ theme }) => theme.paddings.base};
min-width: 15rem;
width: 100%;
height: ${ROOM_CARD.height}rem;
border-radius: ${({ theme }) => theme.borderRadius.base};
Expand Down Expand Up @@ -77,6 +78,7 @@ export const RoomCardBottom = styled.div`
`;

export const RoomFieldType = styled.div<{ bgColor: DevFieldType }>`
min-width: 5.1rem;
width: 6rem;
height: 2rem;
${({ theme, bgColor }) => css`
Expand Down
20 changes: 14 additions & 6 deletions client/src/components/video/Screenshare/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import { ICameraVideoTrack, IMicrophoneAudioTrack } from 'agora-rtc-react';
import { useClient, useScreenVideoTrack } from '@components/video/config';

Expand All @@ -19,27 +19,35 @@ const ScreenShare = ({
}: ScreenShareDivProps): JSX.Element => {
const client = useClient();
const { ready, tracks, error } = useScreenVideoTrack();
const firstRenderRef = useRef(true);

useEffect(() => {
const pulishScreenShare = async () => {
setStart(false);
await client.unpublish(preTracks[1]);
await client.publish(tracks);
setStart(true);
if (!Array.isArray(tracks)) {
tracks.on('track-ended', async () => {
setScreenShare(false);
await client.unpublish(tracks);
tracks.close();
if (trackState.video) {
await client.publish(preTracks[1]);
}
setScreenShare(false);
});
}
};
if (ready) pulishScreenShare();
if (ready && tracks) pulishScreenShare();
if (error) setScreenShare(false);

return () => {
client.unpublish(tracks);
if (firstRenderRef.current) {
firstRenderRef.current = false;
return;
}
if (!error && !Array.isArray(tracks)) {
client.unpublish(tracks);
tracks.close();
}
};
}, [setStart, setScreenShare, screenShare, client, preTracks, trackState, tracks, ready, error]);

Expand Down
7 changes: 4 additions & 3 deletions client/src/components/video/VideoCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
AgoraVideoPlayer,
} from 'agora-rtc-react';
import { VideoWrap, VolumeVisualizer } from './style';
import { SPEAK } from '@utils/constant';
import { SCREEN_SHARE_HEIGHT, SPEAK } from '@utils/constant';
import { useToast } from '@hooks/useToast';
import { TOAST_MESSAGE } from '@utils/constant';

Expand Down Expand Up @@ -69,8 +69,9 @@ const VideoCard = ({ videoTrack, audioTrack }: VideoCardProps): JSX.Element => {
<VideoWrap
onClick={onClickInfo}
onDoubleClick={() => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
videoTrack?.getMediaStreamTrack().readyState === 'live' && openFullscreen();
if (videoTrack?.getCurrentFrameData()?.height === SCREEN_SHARE_HEIGHT) {
openFullscreen();
}
}}
ref={videoRef}>
{videoTrack && (
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/video/VideoController/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const VideoController = ({ tracks, setStart, uuid, ownerId }: VideoControllerPro
}
};

const handleScreenShare = () => setScreenShare(!screenShare);
const handleScreenShare = useCallback(() => {
setScreenShare((prev) => !prev);
}, []);

const leaveChannel = useCallback(async () => {
if (ownerId === user.id) {
Expand Down
25 changes: 18 additions & 7 deletions client/src/components/video/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
createMicrophoneAndCameraTracks,
createMicrophoneAudioTrack,
createScreenVideoTrack,
ILocalAudioTrack,
ILocalVideoTrack,
AgoraRTCError,
} from 'agora-rtc-react';
import { SCREEN_SHARE_HEIGHT } from '@utils/constant';

const config: ClientConfig = {
mode: 'rtc',
Expand All @@ -14,12 +18,19 @@ const config: ClientConfig = {
const useClient = createClient(config);
const useMicrophoneAndCameraTracks = createMicrophoneAndCameraTracks();
const useMicrophoneTrack = createMicrophoneAudioTrack();
const useScreenVideoTrack = createScreenVideoTrack(
{
encoderConfig: '1080p_1',
optimizationMode: 'detail',
},
'disable',
);
const useScreenVideoTrack = (): {
ready: boolean;
tracks: ILocalVideoTrack | [ILocalVideoTrack, ILocalAudioTrack];
error: AgoraRTCError | null;
} => {
const screenShare = createScreenVideoTrack(
{
encoderConfig: `${SCREEN_SHARE_HEIGHT}p_1`,
optimizationMode: 'detail',
},
'disable',
);
return screenShare();
};

export { useClient, useMicrophoneAndCameraTracks, useMicrophoneTrack, useScreenVideoTrack };
2 changes: 0 additions & 2 deletions client/src/pages/Campfire/Campfire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import BGMContextProvider from '@contexts/bgmContext';
import { useUser } from '@contexts/userContext';
import { RoomType } from '@utils/constant';
import { RoomInfoType } from '@src/types';
import { postLeaveRoom } from '@src/apis';

interface LocationProps {
pathname: string;
Expand All @@ -35,7 +34,6 @@ const Campfire = ({ location }: RoomProps): JSX.Element => {

useEffect(() => {
if (!userInfo.login) {
postLeaveRoom(uuid);
history.goBack();
return;
}
Expand Down
12 changes: 6 additions & 6 deletions client/src/pages/Tadak/Tadak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import VideoList from '@components/video/VideoList';
import Loader from '@components/common/Loader';
import { useUser } from '@contexts/userContext';
import { RoomInfoType } from '@src/types';
import { postLeaveRoom } from '@src/apis';

interface LocationProps {
pathname: string;
Expand All @@ -23,15 +22,15 @@ interface TadakProps {
const Tadak = ({ location }: TadakProps): JSX.Element => {
const { agoraAppId, agoraToken, uuid, owner, maxHeadcount } = location?.state;
const [users, setUsers] = useState<IAgoraRTCRemoteUser[]>([]);
const [start, setStart] = useState<boolean>(false);
const [start, setStart] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const client = useClient();
const { ready, tracks } = useMicrophoneAndCameraTracks();
const userInfo = useUser();
const history = useHistory();

useEffect(() => {
if (!userInfo.login) {
postLeaveRoom(uuid);
history.goBack();
return;
}
Expand Down Expand Up @@ -74,6 +73,7 @@ const Tadak = ({ location }: TadakProps): JSX.Element => {
await tracks[1].setEnabled(false);
await tracks[0].setEnabled(false);
}
setIsLoading(false);
setStart(true);
};

Expand All @@ -85,14 +85,14 @@ const Tadak = ({ location }: TadakProps): JSX.Element => {

return (
<TadakWrapper>
{!start ? (
{isLoading ? (
<Loader isWholeScreen={true} />
) : (
<>
<RoomSideBar uuid={uuid} hostNickname={owner?.nickname} maxHeadcount={maxHeadcount} />
<TadakContainer>
{tracks && <VideoList users={users} tracks={tracks} />}
{tracks && <VideoController tracks={tracks} setStart={setStart} uuid={uuid} ownerId={owner?.id} />}
{start && tracks && <VideoList users={users} tracks={tracks} />}
{ready && tracks && <VideoController tracks={tracks} setStart={setStart} uuid={uuid} ownerId={owner?.id} />}
</TadakContainer>
</>
)}
Expand Down
4 changes: 3 additions & 1 deletion client/src/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const INPUT = {

export const TOAST_TIME = 2000;

export const SCREEN_SHARE_HEIGHT = 1080;

export const MODAL_NAME = {
login: '로그인',
join: '회원가입',
Expand Down Expand Up @@ -86,7 +88,7 @@ export const TOAST_MESSAGE = {
introduceHost:
'호스트는 참가자를 강퇴할 수 있습니다.  강퇴 당한 사용자는 다시 이 방에 들어올 수 없으니 신중하게 사용해주세요!',
narcissism: '누구나 자기 자신을 좋아합니다...!',
infoDoubleClick: '더블 클릭 하면 어떤 일이 일어날까요...?',
infoDoubleClick: '화면공유된 블록을 더블 클릭 하면 어떤 일이 일어날까요...?',
introFireAnimation: '자세히 보시면 불꽃이 일렁입니다...!',
introMoon: '자세히 보시면 달이 반짝입니다...!',
introSky: '자세히 보시면 별이 반짝이고 별똥별이 떨어집니다...!',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BuilderCommon } from './builder';
import { DevField } from '../domain/field/dev-field.entity';
import { BuilderCommon } from '../builder';
import { DevField } from '../../domain/field/dev-field.entity';

export class DevFieldBuilder extends BuilderCommon<DevField> {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LocalDate } from 'js-joda';
import { BuilderCommon } from './builder';
import { User } from '../domain/user/user.entity';
import { History } from '../domain/history/history.entity';
import { BuilderCommon } from '../builder';
import { User } from '../../domain/user/user.entity';
import { History } from '../../domain/history/history.entity';

export class HistoryBuilder extends BuilderCommon<History> {
constructor() {
Expand Down
6 changes: 3 additions & 3 deletions server/api/src/builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export { RoomBuilder } from './room/room.builder';
export { UserBuilder } from './user/user.builder';
export { HistoryBuilder } from './history.builder';
export { VisitBuilder } from './visit.builder';
export { DevFieldBuilder } from './dev-field.builder';
export { HistoryBuilder } from './history/history.builder';
export { VisitBuilder } from './visit/visit.builder';
export { DevFieldBuilder } from './dev-field/dev-field.builder';
export { LoginRequestDtoBuilder } from './auth/login-request.dto.builder';
export { UserResponseDtoBuilder } from './user/user-response.dto.builder';
export { UserUpdateDtoBuilder } from './user/user-update.dto.builder';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LocalDate } from 'js-joda';
import { BuilderCommon } from './builder';
import { Visit } from '../domain/history/visit.entity';
import { BuilderCommon } from '../builder';
import { Visit } from '../../domain/history/visit.entity';
export class VisitBuilder extends BuilderCommon<Visit> {
constructor() {
super(Visit);
Expand Down
2 changes: 1 addition & 1 deletion server/api/src/domain/auth/service/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { HistoryBuilder, LoginRequestDtoBuilder, UserBuilder, UserResponseDtoBui
import { BadRequestException, HttpStatus, UnauthorizedException } from '@nestjs/common';
import { UserException } from '../../../exception';
import { LoginRequestDto } from '../dto/login-request.dto';
import { Bcrypt } from '../../../utils/bcrypt.util';
import { Bcrypt } from '../../../utils';
import { User } from '../../user/user.entity';
import { LocalDate } from 'js-joda';
import { DevField } from '../../field/dev-field.entity';
Expand Down
2 changes: 1 addition & 1 deletion server/api/src/domain/auth/service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { JwtService } from '@nestjs/jwt';
import { LocalDate } from 'js-joda';
import { Bcrypt } from '../../../utils/bcrypt.util';
import { Bcrypt } from '../../../utils';
import { UserBuilder, UserResponseDtoBuilder } from '../../../builder';
import { DevFieldException, UserException } from '../../../exception';
import { User } from '../../user/user.entity';
Expand Down
2 changes: 1 addition & 1 deletion server/api/src/domain/base-time.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CreateDateColumn, Generated, PrimaryColumn, UpdateDateColumn } from 'typeorm';
import { BigintValueTransformer } from '../transformer/bigint-value.transformer';
import { BigintValueTransformer } from '../transformer';

export abstract class BaseTimeEntity {
@Generated('increment')
Expand Down
2 changes: 1 addition & 1 deletion server/api/src/domain/history/history.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { LocalDate } from 'js-joda';
import { LocalDateTransformer } from '../../transformer/local-date.transformer.';
import { LocalDateTransformer } from '../../transformer';
import { User } from '../user/user.entity';

@Entity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export class VisitRepository extends Repository<Visit> {

async addVisitCount(count: number) {
const visit: Visit = new VisitBuilder().setDate(LocalDate.now().minusDays(1)).setTotalVisit(count).build();
this.save(visit);
await this.save(visit);
}
}
5 changes: 1 addition & 4 deletions server/api/src/domain/history/service/history.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export class HistoryService {
const user: User = await this.userRepository.findUserByUserEmail(email);
if (!user) throw UserException.userNotFound();
const year = LocalDate.now().year();
const result: HistoryResponseDto = new HistoryResponseDto(
await this.historyRepository.getMonthHistoryByUser(user, year),
);
return result;
return new HistoryResponseDto(await this.historyRepository.getMonthHistoryByUser(user, year));
}

async getLastVisitCount() {
Expand Down
2 changes: 1 addition & 1 deletion server/api/src/domain/history/visit.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { LocalDate } from 'js-joda';
import { LocalDateTransformer } from '../../transformer/local-date.transformer.';
import { LocalDateTransformer } from '../../transformer';

@Entity()
export class Visit {
Expand Down
1 change: 0 additions & 1 deletion server/api/src/domain/user/controller/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Req,
Delete,
Get,
Param,
Patch,
Post,
UploadedFile,
Expand Down
2 changes: 1 addition & 1 deletion server/api/src/domain/user/user.entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { LocalDate } from 'js-joda';
import { LocalDateTransformer } from '../../transformer/local-date.transformer.';
import { LocalDateTransformer } from '../../transformer';
import { DevField } from '../field/dev-field.entity';
import { History } from '../history/history.entity';

Expand Down
3 changes: 3 additions & 0 deletions server/api/src/transformer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { BigintValueTransformer } from './bigint-value.transformer';
export { LocalDateTransformer } from './local-date.transformer.';
export { LocalDateTimeTransformer } from './local-date-time.transformer';
2 changes: 1 addition & 1 deletion server/api/src/transformer/local-date-time.transformer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ValueTransformer } from 'typeorm';
import { LocalDateTime } from 'js-joda';
import { DateTimeUtil } from '../utils/date-time.util';
import { DateTimeUtil } from '../utils';

export class LocalDateTimeTransformer implements ValueTransformer {
to(entityValue: LocalDateTime): Date | null {
Expand Down
2 changes: 1 addition & 1 deletion server/api/src/transformer/local-date.transformer..ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ValueTransformer } from 'typeorm';
import { LocalDate } from 'js-joda';
import { DateTimeUtil } from '../utils/date-time.util';
import { DateTimeUtil } from '../utils';

export class LocalDateTransformer implements ValueTransformer {
to(entityValue: LocalDate): Date | null {
Expand Down
2 changes: 2 additions & 0 deletions server/api/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Bcrypt } from './bcrypt.util';
export { DateTimeUtil } from './date-time.util';
2 changes: 1 addition & 1 deletion server/api/test/mock.object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DevFieldBuilder } from '../src/builder/dev-field.builder';
import { DevFieldBuilder } from '../src/builder/dev-field/dev-field.builder';
import { RoomBuilder, UserBuilder } from '../src/builder';
import { datatype, internet, lorem } from 'faker';
import { RoomType } from '../src/domain/room/room.entity';
Expand Down
2 changes: 1 addition & 1 deletion server/socket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "nest start",
"start:dev": "set NODE_ENV=dev&&nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "set NODE_ENV=prod&&nest start",
"start:prod": "set NODE_ENV=production&&nest start",
"start:3000": "cross-env NODE_PORT=3000 nest start",
"start:3001": "cross-env NODE_PORT=3001 nest start",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
Expand Down
2 changes: 1 addition & 1 deletion server/socket/src/gateway/room.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { Server, Socket } from 'socket.io';
import { Logger } from '@nestjs/common';
import { IMessage, IRoomRequest } from './room.interface';
import { LocalDateTime, ZoneId } from '@js-joda/core';
import { LocalDateTime} from '@js-joda/core';
import { RoomEvent } from './room.event';
import { RoomService } from './room.service';

Expand Down
Loading

0 comments on commit b591e21

Please sign in to comment.