General formatting for messaging + reshaping of messaging components and their structure.
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import MessagingActionTypes from './messaging.types'
|
||||
import MessagingActionTypes from "./messaging.types";
|
||||
|
||||
export const toggleChatVisible = () => ({
|
||||
type: MessagingActionTypes.TOGGLE_CHAT_VISIBLE,
|
||||
type: MessagingActionTypes.TOGGLE_CHAT_VISIBLE
|
||||
//payload: user
|
||||
});
|
||||
|
||||
export const toggleConversationVisible = conversationId => ({
|
||||
type: MessagingActionTypes.TOGGLE_CONVERSATION_VISIBLE,
|
||||
payload: conversationId
|
||||
});
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import MessagingActionTypes from "./messaging.types";
|
||||
|
||||
const INITIAL_STATE = {
|
||||
visible: false
|
||||
visible: false,
|
||||
conversations: [
|
||||
{ id: 1, phone: "6049992002", open: false },
|
||||
{ id: 2, phone: "6049992991", open: false }
|
||||
]
|
||||
};
|
||||
|
||||
const messagingReducer = (state = INITIAL_STATE, action) => {
|
||||
@@ -16,6 +20,23 @@ const messagingReducer = (state = INITIAL_STATE, action) => {
|
||||
...state,
|
||||
visible: true
|
||||
};
|
||||
case MessagingActionTypes.OPEN_CONVERSATION:
|
||||
return {
|
||||
...state,
|
||||
conversations: [...state.conversations, action.payload]
|
||||
};
|
||||
case MessagingActionTypes.CLOSE_CONVERSATION:
|
||||
return {
|
||||
...state,
|
||||
conversations: state.conversations.filter(c => c !== action.paylod)
|
||||
};
|
||||
case MessagingActionTypes.TOGGLE_CONVERSATION_VISIBLE:
|
||||
return {
|
||||
...state,
|
||||
conversations: state.conversations.map(c =>
|
||||
c.id === action.payload ? { ...c, open: !c.open } : c
|
||||
)
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -6,3 +6,8 @@ export const selectChatVisible = createSelector(
|
||||
[selectMessaging],
|
||||
messaging => messaging.visible
|
||||
);
|
||||
|
||||
export const selectConversations = createSelector(
|
||||
[selectMessaging],
|
||||
messaging => messaging.conversations
|
||||
);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
const MessagingActionTypes = {
|
||||
TOGGLE_CHAT_VISIBLE: "TOGGLE_CHAT_VISIBLE",
|
||||
SET_CHAT_VISIBLE: "SET_CHAT_VISIBLE"
|
||||
SET_CHAT_VISIBLE: "SET_CHAT_VISIBLE",
|
||||
OPEN_CONVERSATION: "OPEN_CONVERSATION",
|
||||
CLOSE_CONVERSATION: "CLOSE_CONVERSATION",
|
||||
TOGGLE_CONVERSATION_VISIBLE: "TOGGLE_CONVERSATION_VISIBLE",
|
||||
SEND_MESSAGE: "SEND_MESSAGE"
|
||||
};
|
||||
export default MessagingActionTypes;
|
||||
|
||||
@@ -10,7 +10,7 @@ const persistConfig = {
|
||||
key: "root",
|
||||
storage,
|
||||
//whitelist: ["user"]
|
||||
blacklist: ["user", "email"]
|
||||
blacklist: ["user", "email", "messaging"]
|
||||
};
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
|
||||
Reference in New Issue
Block a user