Skip to content

Commit

Permalink
refactor(BREAKING_CHANGE): update store and related type to update ne…
Browse files Browse the repository at this point in the history
…w converstaion addition

Relates enBloc-org#236
  • Loading branch information
nichgalzin committed Jun 5, 2024
1 parent 61f54f1 commit eda7bb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion context/contextTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
AllConversationsType,
ConversationCardType,
} from '@/types/messagingTypes';

export interface IConversationState {
allConversations: AllConversationsType;
currentConversation: ConversationCardType | undefined;
Expand All @@ -9,4 +14,5 @@ export type ConversationActionType =
| { type: 'SET_ALL_CONVERSATIONS'; payload: AllConversationsType }
| { type: 'SET_CURRENT_CONVERSATION'; payload: ConversationCardType }
| { type: 'SET_SHOW_CONVERSATIONS_LIST'; payload: boolean }
| { type: 'SET_CURRENT_USER_ID'; payload: string };
| { type: 'SET_CURRENT_USER_ID'; payload: string }
| { type: 'ADD_NEW_CONVERSATION'; payload: ConversationCardType };
5 changes: 5 additions & 0 deletions context/conversationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export default function conversationReducer(
return { ...state, showConversationsList: action.payload };
case 'SET_CURRENT_USER_ID':
return { ...state, currentUserId: action.payload };
case 'ADD_NEW_CONVERSATION':
return {
...state,
allConversations: [action.payload, ...state.allConversations],
};
default:
return state;
}
Expand Down

0 comments on commit eda7bb1

Please sign in to comment.