Skip to content

Commit 93bab5d

Browse files
authored
Merge pull request #21 from oslabs-beta/liz-chatbug
[Bug Fix] Clean Chat History When Leaving Collaboration Room
2 parents 4926d6b + fe3f54f commit 93bab5d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/src/components/left/RoomsContainer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ import {
4141
setUserJoined,
4242
setUserList,
4343
setMessages,
44-
setPassword
44+
setPassword,
45+
setEmptyMessages
4546
} from '../../redux/reducers/slice/roomSlice';
4647
import { codePreviewCooperative } from '../../redux/reducers/slice/codePreviewSlice';
4748
import { cooperativeStyle } from '../../redux/reducers/slice/styleSlice';
@@ -342,6 +343,7 @@ const RoomsContainer = () => {
342343
dispatch(setUserJoined(false)); //false: join room UI appear
343344
dispatch(resetState(''));
344345
dispatch(setPassword(''));
346+
dispatch(setEmptyMessages([]));
345347
};
346348

347349
const checkInputField = (...inputs) => {

app/src/redux/reducers/slice/roomSlice.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const roomSlice = createSlice({
2828
setMessages: (state, action) => {
2929
state.messages = [...state.messages, action.payload];
3030
},
31+
setEmptyMessages: (state, action) => {
32+
state.messages = [];
33+
},
3134
setPassword: (state, action) => {
3235
state.password = action.payload;
3336
}
@@ -40,6 +43,7 @@ export const {
4043
setUserList,
4144
setUserJoined,
4245
setMessages,
46+
setEmptyMessages,
4347
setPassword
4448
} = roomSlice.actions;
4549

0 commit comments

Comments
 (0)