diff --git a/app/javascript/gabsocial/actions/chat_conversations.js b/app/javascript/gabsocial/actions/chat_conversations.js index 5ccf3c93..c1ebe430 100644 --- a/app/javascript/gabsocial/actions/chat_conversations.js +++ b/app/javascript/gabsocial/actions/chat_conversations.js @@ -430,22 +430,24 @@ export const hideChatConversation = (chatConversationId) => (dispatch, getState) dispatch(hideChatConversationFetch(chatConversationId)) api(getState).post(`/api/v1/chat_conversation/${chatConversationId}/mark_chat_conversation_hidden`).then((response) => { - dispatch(approveChatConversationRequestSuccess(chatConversationId)) - }).catch((error) => dispatch(approveChatConversationRequestFail(error))) + dispatch(hideChatConversationSuccess(chatConversationId)) + }).catch((error) => dispatch(hideChatConversationFail(error))) } export const hideChatConversationFetch = (chatConversationId) => ({ - type: CHAT_CONVERSATION_HIDE_SUCCESS, + type: CHAT_CONVERSATION_HIDE_FETCH, chatConversationId, }) export const hideChatConversationSuccess = (chatConversationId) => ({ type: CHAT_CONVERSATION_HIDE_SUCCESS, chatConversationId, + showToast: true, }) export const hideChatConversationFail = () => ({ type: CHAT_CONVERSATION_HIDE_FAIL, + showToast: true, }) /** diff --git a/app/javascript/gabsocial/reducers/chat_conversations.js b/app/javascript/gabsocial/reducers/chat_conversations.js index 64102009..81d15eb7 100644 --- a/app/javascript/gabsocial/reducers/chat_conversations.js +++ b/app/javascript/gabsocial/reducers/chat_conversations.js @@ -15,10 +15,13 @@ import { CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS, CHAT_CONVERSATIONS_REQUESTED_FETCH_SUCCESS, CHAT_CONVERSATIONS_REQUESTED_EXPAND_SUCCESS, + CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS, + CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS, CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS, CHAT_CONVERSATION_MARK_READ_SUCCESS, SET_CHAT_CONVERSATION_EXPIRATION_SUCCESS, CHAT_CONVERSATION_APPROVED_SEARCH_FETCH_SUCCESS, + CHAT_CONVERSATION_HIDE_FETCH, } from '../actions/chat_conversations' const initialState = ImmutableMap() @@ -51,13 +54,14 @@ export default function chat_conversations(state = initialState, action) { case CHAT_CONVERSATIONS_APPROVED_EXPAND_SUCCESS: case CHAT_CONVERSATIONS_REQUESTED_FETCH_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: return importChatConversations(state, action.chatConversations) case CHAT_MESSAGES_SEND_SUCCESS: return setLastChatMessage(state, action.chatMessage) - case CHAT_MESSAGES_DELETE_REQUEST: - // : todo : set last conversation message to one prior to this one - return state + case CHAT_CONVERSATION_HIDE_FETCH: + return state.delete(action.chatConversationId) case CHAT_MESSAGES_PURGE_REQUEST: // : todo : return state diff --git a/app/models/chat_conversation_account.rb b/app/models/chat_conversation_account.rb index 452c9b1f..dad54cac 100644 --- a/app/models/chat_conversation_account.rb +++ b/app/models/chat_conversation_account.rb @@ -35,6 +35,10 @@ class ChatConversationAccount < ApplicationRecord belongs_to :chat_conversation belongs_to :last_chat_message, class_name: 'ChatMessage', optional: true + default_scope { recent } + + scope :recent, -> { reorder(updated_at: :desc) } + def participant_accounts if participant_account_ids.empty? [account] diff --git a/app/services/post_chat_message_service.rb b/app/services/post_chat_message_service.rb index 98033773..c68e581d 100644 --- a/app/services/post_chat_message_service.rb +++ b/app/services/post_chat_message_service.rb @@ -67,6 +67,7 @@ class PostChatMessageService < BaseService end else recipient.unread_count = 0 + recipient.is_hidden = false end recipient.save