Progress on chat
This commit is contained in:
parent
7a62adea3e
commit
4e1e29571b
@ -430,22 +430,24 @@ export const hideChatConversation = (chatConversationId) => (dispatch, getState)
|
|||||||
dispatch(hideChatConversationFetch(chatConversationId))
|
dispatch(hideChatConversationFetch(chatConversationId))
|
||||||
|
|
||||||
api(getState).post(`/api/v1/chat_conversation/${chatConversationId}/mark_chat_conversation_hidden`).then((response) => {
|
api(getState).post(`/api/v1/chat_conversation/${chatConversationId}/mark_chat_conversation_hidden`).then((response) => {
|
||||||
dispatch(approveChatConversationRequestSuccess(chatConversationId))
|
dispatch(hideChatConversationSuccess(chatConversationId))
|
||||||
}).catch((error) => dispatch(approveChatConversationRequestFail(error)))
|
}).catch((error) => dispatch(hideChatConversationFail(error)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const hideChatConversationFetch = (chatConversationId) => ({
|
export const hideChatConversationFetch = (chatConversationId) => ({
|
||||||
type: CHAT_CONVERSATION_HIDE_SUCCESS,
|
type: CHAT_CONVERSATION_HIDE_FETCH,
|
||||||
chatConversationId,
|
chatConversationId,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const hideChatConversationSuccess = (chatConversationId) => ({
|
export const hideChatConversationSuccess = (chatConversationId) => ({
|
||||||
type: CHAT_CONVERSATION_HIDE_SUCCESS,
|
type: CHAT_CONVERSATION_HIDE_SUCCESS,
|
||||||
chatConversationId,
|
chatConversationId,
|
||||||
|
showToast: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const hideChatConversationFail = () => ({
|
export const hideChatConversationFail = () => ({
|
||||||
type: CHAT_CONVERSATION_HIDE_FAIL,
|
type: CHAT_CONVERSATION_HIDE_FAIL,
|
||||||
|
showToast: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,10 +15,13 @@ import {
|
|||||||
CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS,
|
CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS,
|
||||||
CHAT_CONVERSATIONS_REQUESTED_FETCH_SUCCESS,
|
CHAT_CONVERSATIONS_REQUESTED_FETCH_SUCCESS,
|
||||||
CHAT_CONVERSATIONS_REQUESTED_EXPAND_SUCCESS,
|
CHAT_CONVERSATIONS_REQUESTED_EXPAND_SUCCESS,
|
||||||
|
CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS,
|
||||||
|
CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS,
|
||||||
CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS,
|
CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS,
|
||||||
CHAT_CONVERSATION_MARK_READ_SUCCESS,
|
CHAT_CONVERSATION_MARK_READ_SUCCESS,
|
||||||
SET_CHAT_CONVERSATION_EXPIRATION_SUCCESS,
|
SET_CHAT_CONVERSATION_EXPIRATION_SUCCESS,
|
||||||
CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS,
|
CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS,
|
||||||
|
CHAT_CONVERSATION_HIDE_FETCH,
|
||||||
} from '../actions/chat_conversations'
|
} from '../actions/chat_conversations'
|
||||||
|
|
||||||
const initialState = ImmutableMap()
|
const initialState = ImmutableMap()
|
||||||
@ -51,13 +54,14 @@ export default function chat_conversations(state = initialState, action) {
|
|||||||
case CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS:
|
case CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS:
|
||||||
case CHAT_CONVERSATIONS_REQUESTED_FETCH_SUCCESS:
|
case CHAT_CONVERSATIONS_REQUESTED_FETCH_SUCCESS:
|
||||||
case CHAT_CONVERSATIONS_REQUESTED_EXPAND_SUCCESS:
|
case CHAT_CONVERSATIONS_REQUESTED_EXPAND_SUCCESS:
|
||||||
|
case CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS:
|
||||||
|
case CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS:
|
||||||
case CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS:
|
case CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS:
|
||||||
return importChatConversations(state, action.chatConversations)
|
return importChatConversations(state, action.chatConversations)
|
||||||
case CHAT_MESSAGES_SEND_SUCCESS:
|
case CHAT_MESSAGES_SEND_SUCCESS:
|
||||||
return setLastChatMessage(state, action.chatMessage)
|
return setLastChatMessage(state, action.chatMessage)
|
||||||
case CHAT_MESSAGES_DELETE_REQUEST:
|
case CHAT_CONVERSATION_HIDE_FETCH:
|
||||||
// : todo : set last conversation message to one prior to this one
|
return state.delete(action.chatConversationId)
|
||||||
return state
|
|
||||||
case CHAT_MESSAGES_PURGE_REQUEST:
|
case CHAT_MESSAGES_PURGE_REQUEST:
|
||||||
// : todo :
|
// : todo :
|
||||||
return state
|
return state
|
||||||
|
@ -35,6 +35,10 @@ class ChatConversationAccount < ApplicationRecord
|
|||||||
belongs_to :chat_conversation
|
belongs_to :chat_conversation
|
||||||
belongs_to :last_chat_message, class_name: 'ChatMessage', optional: true
|
belongs_to :last_chat_message, class_name: 'ChatMessage', optional: true
|
||||||
|
|
||||||
|
default_scope { recent }
|
||||||
|
|
||||||
|
scope :recent, -> { reorder(updated_at: :desc) }
|
||||||
|
|
||||||
def participant_accounts
|
def participant_accounts
|
||||||
if participant_account_ids.empty?
|
if participant_account_ids.empty?
|
||||||
[account]
|
[account]
|
||||||
|
@ -67,6 +67,7 @@ class PostChatMessageService < BaseService
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
recipient.unread_count = 0
|
recipient.unread_count = 0
|
||||||
|
recipient.is_hidden = false
|
||||||
end
|
end
|
||||||
|
|
||||||
recipient.save
|
recipient.save
|
||||||
|
Loading…
x
Reference in New Issue
Block a user