forked from enBloc-org/kindly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: context type file and basic reducer funtion setup
Relates enBloc-org#236
- Loading branch information
1 parent
d661e90
commit b63c900
Showing
3 changed files
with
33 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export interface IConversationState { | ||
allConversations: AllConversationsType; | ||
currentConversation: ConversationCardType | undefined; | ||
showConversationsList: boolean; | ||
currentUserId: string; | ||
} | ||
|
||
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 }; |
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,19 @@ | ||
import { ConversationActionType, IConversationState } from './contextTypes'; | ||
|
||
export default function conversationReducer( | ||
state: IConversationState, | ||
action: ConversationActionType | ||
): IConversationState { | ||
switch (action.type) { | ||
case 'SET_ALL_CONVERSATIONS': | ||
return { ...state, allConversations: action.payload }; | ||
case 'SET_CURRENT_CONVERSATION': | ||
return { ...state, currentConversation: action.payload }; | ||
case 'SET_SHOW_CONVERSATIONS_LIST': | ||
return { ...state, showConversationsList: action.payload }; | ||
case 'SET_CURRENT_USER_ID': | ||
return { ...state, currentUserId: action.payload }; | ||
default: | ||
return state; | ||
} | ||
} |