-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from boostcamp-2020/develop
Release Browse Page
- Loading branch information
Showing
25 changed files
with
305 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { JOIN_CHATROOM, joinChatroomState } from '@socket/types/chatroom-types'; | ||
import socket from '../socketIO'; | ||
|
||
export const joinChatroom = (chatroomId: joinChatroomState) => { | ||
socket.emit(JOIN_CHATROOM, { chatroomId }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const JOIN_CHATROOM = 'join chatroom'; | ||
|
||
export interface joinChatroomState { | ||
chatroomId: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { INIT_CHANNELS_ASYNC } from '../types/channel-types'; | ||
import { INIT_CHANNELS_ASYNC, LOAD_NEXT_CHANNELS_ASYNC, JOIN_CHANNEL_ASYNC } from '../types/channel-types'; | ||
|
||
export const initChannels = () => ({ type: INIT_CHANNELS_ASYNC }); | ||
export const loadNextChannels = (payload: any) => ({ type: LOAD_NEXT_CHANNELS_ASYNC, payload }); | ||
export const joinChannel = (payload: any) => ({ type: JOIN_CHANNEL_ASYNC, payload }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,52 @@ | ||
import { call, put, takeEvery } from 'redux-saga/effects'; | ||
import API from '@utils/api'; | ||
import { INIT_CHANNELS, INIT_CHANNELS_ASYNC } from '../types/channel-types'; | ||
import { joinChatroom } from '@socket/emits/chatroom'; | ||
import { | ||
INIT_CHANNELS, | ||
INIT_CHANNELS_ASYNC, | ||
JOIN_CHANNEL, | ||
JOIN_CHANNEL_ASYNC, | ||
LOAD_NEXT_CHANNELS, | ||
LOAD_NEXT_CHANNELS_ASYNC | ||
} from '../types/channel-types'; | ||
import { ADD_CHANNEL } from '../types/chatroom-types'; | ||
|
||
function* initChannelsSaga() { | ||
try { | ||
const channelCount = 0; | ||
const channels = yield call(API.getChannels); | ||
const { channels, channelCount } = yield call(API.getChannels); | ||
yield put({ type: INIT_CHANNELS, payload: { channelCount, channels } }); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
|
||
function* loadNextChannels(action: any) { | ||
try { | ||
const { title } = action.payload; | ||
const nextChannels = yield call(API.getNextChannels, title); | ||
yield put({ type: LOAD_NEXT_CHANNELS, payload: { channels: nextChannels } }); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
|
||
function* joinChannel(action: any) { | ||
try { | ||
const { chatroomId } = action.payload; | ||
yield call(API.joinChannel, chatroomId); | ||
yield put({ type: JOIN_CHANNEL, payload: { chatroomId } }); | ||
const chatroom = yield call(API.getChatroom, chatroomId); | ||
const { chatType, isPrivate, title } = chatroom; | ||
const payload = { chatroomId, chatType, isPrivate, title }; | ||
joinChatroom(chatroomId); | ||
yield put({ type: ADD_CHANNEL, payload }); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
|
||
export function* channelSaga() { | ||
yield takeEvery(INIT_CHANNELS_ASYNC, initChannelsSaga); | ||
yield takeEvery(LOAD_NEXT_CHANNELS_ASYNC, loadNextChannels); | ||
yield takeEvery(JOIN_CHANNEL_ASYNC, joinChannel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.