Progress on DMs

Progress on DMs
This commit is contained in:
mgabdev
2020-12-19 01:33:33 -05:00
parent 47cd60f851
commit 7ec426e3d8
38 changed files with 447 additions and 197 deletions

View File

@@ -20,7 +20,7 @@ export const UNBLOCK_CHAT_MESSAGER_REQUEST = 'UNBLOCK_CHAT_MESSAGER_REQUEST'
export const UNBLOCK_CHAT_MESSAGER_SUCCESS = 'UNBLOCK_CHAT_MESSAGER_SUCCESS'
export const UNBLOCK_CHAT_MESSAGER_FAIL = 'UNBLOCK_CHAT_MESSAGER_FAIL'
export const IS_CHAT_MESSENGER_BLOCKED_SUCCESS = 'IS_CHAT_MESSENGER_BLOCKED_SUCCESS'
export const FETCH_CHAT_MESSENGER_BLOCKING_RELATIONSHIPS_SUCCESS = 'FETCH_CHAT_MESSENGER_BLOCKING_RELATIONSHIPS_SUCCESS'
//
@@ -36,13 +36,12 @@ export const UNMUTE_CHAT_CONVERSATION_FAIL = 'UNMUTE_CHAT_CONVERSATION_FAIL'
*
*/
export const blockChatMessenger = (accountId) => (dispatch, getState) => {
console.log("blockChatMessenger:", accountId)
if (!me || !accountId) return
dispatch(blockChatMessengerRequest(accountId))
api(getState).post(`/api/v1/chat_conversation_accounts/${accountId}/block_messenger`).then((response) => {
dispatch(blockChatMessengerSuccess())
api(getState).post(`/api/v1/chat_conversation_accounts/_/block_messenger`, { account_id: accountId }).then((response) => {
dispatch(blockChatMessengerSuccess(response.data))
}).catch((error) => {
dispatch(blockChatMessengerFail(accountId, error))
})
@@ -53,8 +52,9 @@ const blockChatMessengerRequest = (accountId) => ({
accountId,
})
const blockChatMessengerSuccess = () => ({
const blockChatMessengerSuccess = (data) => ({
type: BLOCK_CHAT_MESSAGER_SUCCESS,
data,
showToast: true,
})
@@ -73,8 +73,8 @@ export const unblockChatMessenger = (accountId) => (dispatch, getState) => {
dispatch(unblockChatMessengerRequest(accountId))
api(getState).post(`/api/v1/chat_conversation_accounts/${accountId}/unblock_messenger`).then((response) => {
dispatch(unblockChatMessengerSuccess())
api(getState).post(`/api/v1/chat_conversation_accounts/_/unblock_messenger`, { account_id: accountId }).then((response) => {
dispatch(unblockChatMessengerSuccess(response.data))
}).catch((error) => {
dispatch(unblockChatMessengerFail(accountId, error))
})
@@ -85,8 +85,9 @@ const unblockChatMessengerRequest = (accountId) => ({
accountId,
})
const unblockChatMessengerSuccess = () => ({
const unblockChatMessengerSuccess = (data) => ({
type: UNBLOCK_CHAT_MESSAGER_SUCCESS,
data,
showToast: true,
})
@@ -101,16 +102,16 @@ const unblockChatMessengerFail = (accountId, error) => ({
* @description Check if a chat messenger is blocked by the current user account.
* @param {String} accountId
*/
export const isChatMessengerBlocked = (accountId) => (dispatch, getState) => {
export const fetchMessengerBlockingRelationships = (accountId) => (dispatch, getState) => {
if (!me || !accountId) return
api(getState).post(`/api/v1/chat_conversation_accounts/${accountId}/is_messenger_blocked`).then((response) => {
dispatch(isChatMessengerBlockedSuccess(response.data))
api(getState).post(`/api/v1/chat_conversation_accounts/_/messenger_block_relationships`, { account_id: accountId }).then((response) => {
dispatch(fetchMessengerBlockingRelationshipsSuccess(response.data))
})
}
const isChatMessengerBlockedSuccess = (data) => ({
type: IS_CHAT_MESSENGER_BLOCKED_SUCCESS,
const fetchMessengerBlockingRelationshipsSuccess = (data) => ({
type: FETCH_CHAT_MESSENGER_BLOCKING_RELATIONSHIPS_SUCCESS,
data,
})
@@ -193,7 +194,7 @@ export const muteChatConversation = (chatConversationId) => (dispatch, getState)
api(getState).post(`/api/v1/chat_conversation_accounts/${chatConversationId}/mute_chat_conversation`).then((response) => {
dispatch(muteChatConversationSuccess(response.data))
}).catch((error) => {
dispatch(muteChatMessengerFail(error))
dispatch(muteChatConversationFail(error))
})
}

View File

@@ -389,9 +389,9 @@ export const readChatConversationFail = () => ({
*
*/
export const setChatConversationExpiration = (chatConversationId, expiration) => (dispatch, getState) => {
if (!me|| !chatConversationId || !expiration) return
if (!me|| !chatConversationId) return
dispatch(setChatConversationExpirationFetch(chatConversation))
dispatch(setChatConversationExpirationFetch(chatConversationId))
api(getState).post(`/api/v1/chat_conversation/${chatConversationId}/set_expiration_policy`, {
expiration,
@@ -400,18 +400,18 @@ export const setChatConversationExpiration = (chatConversationId, expiration) =>
}).catch((error) => dispatch(setChatConversationExpirationFail(error)))
}
export const setChatConversationExpirationFetch = (chatConversation) => ({
export const setChatConversationExpirationFetch = (chatConversationId) => ({
type: SET_CHAT_CONVERSATION_EXPIRATION_REQUEST,
chatConversation,
chatConversationId,
})
export const setChatConversationExpirationSuccess = (chatConversation) => ({
type: SET_CHAT_CONVERSATION_EXPIRATION_REQUEST,
type: SET_CHAT_CONVERSATION_EXPIRATION_SUCCESS,
chatConversation,
})
export const setChatConversationExpirationFail = (error) => ({
type: SET_CHAT_CONVERSATION_EXPIRATION_REQUEST,
type: SET_CHAT_CONVERSATION_EXPIRATION_FAIL,
error,
})

View File

@@ -113,12 +113,12 @@ const deleteChatMessageFail = (error) => ({
export const purgeChatMessages = (chatConversationId) => (dispatch, getState) => {
if (!me || !chatConversationId) return
dispatch(deleteChatMessagesRequest(chatConversationId))
dispatch(purgeChatMessagesRequest(chatConversationId))
api(getState).delete(`/api/v1/chat_conversations/messages/${chatConversationId}/destroy_all`).then((response) => {
dispatch(deleteChatMessagesSuccess(response.data))
dispatch(purgeChatMessagesSuccess(chatConversationId))
}).catch((error) => {
dispatch(deleteChatMessagesFail(error))
dispatch(purgeChatMessagesFail(error))
})
}

View File

@@ -21,9 +21,9 @@ import { openModal, closeModal } from './modal'
import {
MODAL_COMPOSE,
EXPIRATION_OPTION_5_MINUTES,
EXPIRATION_OPTION_60_MINUTES,
EXPIRATION_OPTION_1_HOUR,
EXPIRATION_OPTION_6_HOURS,
EXPIRATION_OPTION_24_HOURS,
EXPIRATION_OPTION_1_DAY,
EXPIRATION_OPTION_3_DAYS,
EXPIRATION_OPTION_7_DAYS,
} from '../constants'
@@ -345,23 +345,7 @@ export const submitCompose = (groupId, replyToId = null, router, isStandalone, a
let scheduled_at = getState().getIn(['compose', 'scheduled_at'], null)
if (scheduled_at !== null) scheduled_at = moment.utc(scheduled_at).toDate()
let expires_at = getState().getIn(['compose', 'expires_at'], null)
if (expires_at) {
if (expires_at === EXPIRATION_OPTION_5_MINUTES) {
expires_at = moment.utc().add('5', 'minute').toDate()
} else if (expires_at === EXPIRATION_OPTION_60_MINUTES) {
expires_at = moment.utc().add('60', 'minute').toDate()
} else if (expires_at === EXPIRATION_OPTION_6_HOURS) {
expires_at = moment.utc().add('6', 'hour').toDate()
} else if (expires_at === EXPIRATION_OPTION_24_HOURS) {
expires_at = moment.utc().add('24', 'hour').toDate()
} else if (expires_at === EXPIRATION_OPTION_3_DAYS) {
expires_at = moment.utc().add('3', 'day').toDate()
} else if (expires_at === EXPIRATION_OPTION_7_DAYS) {
expires_at = moment.utc().add('7', 'day').toDate()
}
}
const expires_at = getState().getIn(['compose', 'expires_at'], null)
if (isMobile(window.innerWidth) && router && isStandalone) {
router.history.goBack()