-
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.
feat: Browse Page 채널 목록 구현(Infinite Scroll 구현, 채널 Join 기능 구현) (#185)
* fix: 채널 목록 조회 API 오류 해결 - x-total-count header를 사용할 수 있도록 수정 - 오타 수정 * feat: 채널 개수와 join 여부 연동 - channel-saga, api에 channelCount 추가 * feat: getNextChannels API 추가 - offsetTitle을 기준으로 다음 채널목록을 가져오는 API 추가 * feat: Channel Store에 loadNextChannels 추가 - 다음 채널 목록을 가져오는 loadNextChannels type, action, reducer, saga 구현 * feat: 채널 목록 infinite scroll 구현 * feat: 채팅방 JOIN 기능 구현 - joinChannel API 추가 - Channel Store에 joinChannel types, action, reducer, saga 구현 - 채팅방 목록에서 Join 버튼 클릭 시 채팅방 들어가기 동작 구현 - join chatroom socket 리팩토링
- Loading branch information
1 parent
837fe8b
commit c76909f
Showing
17 changed files
with
153 additions
and
38 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