about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/actions/conversations.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-09-21 20:01:16 +0200
committerThibaut Girka <thib@sitedethib.com>2019-09-30 17:01:16 +0200
commit13bc2cd4afb3928a5a4380b4c3b035298f595bf7 (patch)
tree5a5a68a113db7c86cb61355a544334a3af26cc11 /app/javascript/flavours/glitch/actions/conversations.js
parent4d6ef02203bb5c198c9a6574601c8664271ad44d (diff)
[Glitch] Change conversations UI
Port bc5678d0151dd96e0ec5f3d4084ac6356c1d02f5 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/actions/conversations.js')
-rw-r--r--app/javascript/flavours/glitch/actions/conversations.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/actions/conversations.js b/app/javascript/flavours/glitch/actions/conversations.js
index 856f8f10f..e5c85c65d 100644
--- a/app/javascript/flavours/glitch/actions/conversations.js
+++ b/app/javascript/flavours/glitch/actions/conversations.js
@@ -15,6 +15,10 @@ export const CONVERSATIONS_UPDATE        = 'CONVERSATIONS_UPDATE';
 
 export const CONVERSATIONS_READ = 'CONVERSATIONS_READ';
 
+export const CONVERSATIONS_DELETE_REQUEST = 'CONVERSATIONS_DELETE_REQUEST';
+export const CONVERSATIONS_DELETE_SUCCESS = 'CONVERSATIONS_DELETE_SUCCESS';
+export const CONVERSATIONS_DELETE_FAIL    = 'CONVERSATIONS_DELETE_FAIL';
+
 export const mountConversations = () => ({
   type: CONVERSATIONS_MOUNT,
 });
@@ -82,3 +86,27 @@ export const updateConversations = conversation => dispatch => {
     conversation,
   });
 };
+
+export const deleteConversation = conversationId => (dispatch, getState) => {
+  dispatch(deleteConversationRequest(conversationId));
+
+  api(getState).delete(`/api/v1/conversations/${conversationId}`)
+    .then(() => dispatch(deleteConversationSuccess(conversationId)))
+    .catch(error => dispatch(deleteConversationFail(conversationId, error)));
+};
+
+export const deleteConversationRequest = id => ({
+  type: CONVERSATIONS_DELETE_REQUEST,
+  id,
+});
+
+export const deleteConversationSuccess = id => ({
+  type: CONVERSATIONS_DELETE_SUCCESS,
+  id,
+});
+
+export const deleteConversationFail = (id, error) => ({
+  type: CONVERSATIONS_DELETE_FAIL,
+  id,
+  error,
+});