Chats: fix flickering during update
This commit is contained in:
parent
9af664bda8
commit
8b621d30fc
2 changed files with 5 additions and 4 deletions
|
@ -55,7 +55,7 @@ export function connectTimelineStream(timelineId, path, pollingRefresh = null, a
|
||||||
dispatch(fetchFilters());
|
dispatch(fetchFilters());
|
||||||
break;
|
break;
|
||||||
case 'pleroma:chat_update':
|
case 'pleroma:chat_update':
|
||||||
dispatch({ type: STREAMING_CHAT_UPDATE, chat: JSON.parse(data.payload) });
|
dispatch({ type: STREAMING_CHAT_UPDATE, chat: JSON.parse(data.payload), me: getState().get('me') });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -38,15 +38,16 @@ export default function chatMessageLists(state = initialState, action) {
|
||||||
case CHATS_FETCH_SUCCESS:
|
case CHATS_FETCH_SUCCESS:
|
||||||
return importLastMessages(state, action.chats).sort();
|
return importLastMessages(state, action.chats).sort();
|
||||||
case STREAMING_CHAT_UPDATE:
|
case STREAMING_CHAT_UPDATE:
|
||||||
if (action.chat.last_message)
|
if (action.chat.last_message &&
|
||||||
|
action.chat.last_message.account_id !== action.me)
|
||||||
return importMessages(state, [action.chat.last_message]).sort();
|
return importMessages(state, [action.chat.last_message]).sort();
|
||||||
else
|
else
|
||||||
return state.sort();
|
return state;
|
||||||
case CHAT_MESSAGES_FETCH_SUCCESS:
|
case CHAT_MESSAGES_FETCH_SUCCESS:
|
||||||
return updateList(state, action.chatId, action.chatMessages.map(chat => chat.id).reverse()).sort();
|
return updateList(state, action.chatId, action.chatMessages.map(chat => chat.id).reverse()).sort();
|
||||||
case CHAT_MESSAGE_SEND_SUCCESS:
|
case CHAT_MESSAGE_SEND_SUCCESS:
|
||||||
return updateList(state, action.chatId, [action.chatMessage.id]).sort();
|
return updateList(state, action.chatId, [action.chatMessage.id]).sort();
|
||||||
default:
|
default:
|
||||||
return state.sort();
|
return state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue