|
|
|
@ -211,6 +211,12 @@ export type MessageDeletedActionType = {
|
|
|
|
|
messageId: string;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
export type ConversationResetActionType = {
|
|
|
|
|
type: 'CONVERSATION_RESET';
|
|
|
|
|
payload: {
|
|
|
|
|
conversationKey: string;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
export type SelectedConversationChangedActionType = {
|
|
|
|
|
type: 'SELECTED_CONVERSATION_CHANGED';
|
|
|
|
|
payload: {
|
|
|
|
@ -231,6 +237,7 @@ export type ConversationActionType =
|
|
|
|
|
| ConversationAddedActionType
|
|
|
|
|
| ConversationChangedActionType
|
|
|
|
|
| ConversationRemovedActionType
|
|
|
|
|
| ConversationResetActionType
|
|
|
|
|
| RemoveAllConversationsActionType
|
|
|
|
|
| MessageExpiredActionType
|
|
|
|
|
| MessageAddedActionType
|
|
|
|
@ -250,6 +257,7 @@ export const actions = {
|
|
|
|
|
messageExpired,
|
|
|
|
|
messageAdded,
|
|
|
|
|
messageDeleted,
|
|
|
|
|
conversationReset,
|
|
|
|
|
messageChanged,
|
|
|
|
|
fetchMessagesForConversation,
|
|
|
|
|
openConversationExternal,
|
|
|
|
@ -349,6 +357,19 @@ function messageDeleted({
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function conversationReset({
|
|
|
|
|
conversationKey,
|
|
|
|
|
}: {
|
|
|
|
|
conversationKey: string;
|
|
|
|
|
}): ConversationResetActionType {
|
|
|
|
|
return {
|
|
|
|
|
type: 'CONVERSATION_RESET',
|
|
|
|
|
payload: {
|
|
|
|
|
conversationKey,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openConversationExternal(
|
|
|
|
|
id: string,
|
|
|
|
|
messageId?: string
|
|
|
|
@ -553,5 +574,17 @@ export function reducer(
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (action.type === 'CONVERSATION_RESET') {
|
|
|
|
|
const { conversationKey } = action.payload;
|
|
|
|
|
if (conversationKey === state.selectedConversation) {
|
|
|
|
|
// just empty the list of messages
|
|
|
|
|
return {
|
|
|
|
|
...state,
|
|
|
|
|
messages: [],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|