Fix management of selectedMessage in redux
This commit is contained in:
parent
6ad091bfe3
commit
6b231346d9
6 changed files with 15 additions and 15 deletions
|
@ -359,7 +359,6 @@ const actions = () => ({
|
|||
),
|
||||
setIsNearBottom: action('setIsNearBottom'),
|
||||
learnMoreAboutDeliveryIssue: action('learnMoreAboutDeliveryIssue'),
|
||||
loadAndScroll: action('loadAndScroll'),
|
||||
loadOlderMessages: action('loadOlderMessages'),
|
||||
loadNewerMessages: action('loadNewerMessages'),
|
||||
loadNewestMessages: action('loadNewestMessages'),
|
||||
|
|
|
@ -161,7 +161,6 @@ export type PropsActionsType = {
|
|||
) => void;
|
||||
|
||||
learnMoreAboutDeliveryIssue: () => unknown;
|
||||
loadAndScroll: (messageId: string) => unknown;
|
||||
loadOlderMessages: (messageId: string) => unknown;
|
||||
loadNewerMessages: (messageId: string) => unknown;
|
||||
loadNewestMessages: (messageId: string, setFocus?: boolean) => unknown;
|
||||
|
@ -220,7 +219,6 @@ const getActions = createSelector(
|
|||
'reviewGroupMemberNameCollision',
|
||||
'reviewMessageRequestNameCollision',
|
||||
'learnMoreAboutDeliveryIssue',
|
||||
'loadAndScroll',
|
||||
'loadOlderMessages',
|
||||
'loadNewerMessages',
|
||||
'loadNewestMessages',
|
||||
|
|
|
@ -1370,10 +1370,6 @@ export class ConversationModel extends window.Backbone
|
|||
this.debouncedUpdateLastMessage!();
|
||||
}
|
||||
|
||||
addIncomingMessage(message: MessageModel): void {
|
||||
this.addSingleMessage(message);
|
||||
}
|
||||
|
||||
// New messages might arrive while we're in the middle of a bulk fetch from the
|
||||
// database. We'll wait until that is done before moving forward.
|
||||
async addSingleMessage(
|
||||
|
|
|
@ -1726,6 +1726,14 @@ function messagesReset({
|
|||
scrollToMessageId,
|
||||
unboundedFetch,
|
||||
}: MessageResetOptionsType): MessagesResetActionType {
|
||||
for (const message of messages) {
|
||||
strictAssert(
|
||||
message.conversationId === conversationId,
|
||||
`messagesReset(${conversationId}): invalid message conversationId ` +
|
||||
`${message.conversationId}`
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'MESSAGES_RESET',
|
||||
payload: {
|
||||
|
@ -2625,8 +2633,12 @@ export function reducer(
|
|||
|
||||
return {
|
||||
...state,
|
||||
selectedMessage: scrollToMessageId,
|
||||
selectedMessageCounter: state.selectedMessageCounter + 1,
|
||||
...(state.selectedConversationId === conversationId
|
||||
? {
|
||||
selectedMessage: scrollToMessageId,
|
||||
selectedMessageCounter: state.selectedMessageCounter + 1,
|
||||
}
|
||||
: {}),
|
||||
messagesLookup: {
|
||||
...messagesLookup,
|
||||
...lookup,
|
||||
|
@ -3035,12 +3047,9 @@ export function reducer(
|
|||
const nextState = {
|
||||
...omit(state, 'contactSpoofingReview'),
|
||||
selectedConversationId: id,
|
||||
selectedMessage: messageId,
|
||||
};
|
||||
|
||||
if (messageId) {
|
||||
nextState.selectedMessage = messageId;
|
||||
}
|
||||
|
||||
if (switchToAssociatedView && id) {
|
||||
const conversation = getOwn(state.conversationLookup, id);
|
||||
if (!conversation) {
|
||||
|
|
|
@ -71,7 +71,6 @@ export type TimelinePropsType = ExternalProps &
|
|||
| 'downloadNewVersion'
|
||||
| 'kickOffAttachmentDownload'
|
||||
| 'learnMoreAboutDeliveryIssue'
|
||||
| 'loadAndScroll'
|
||||
| 'loadNewerMessages'
|
||||
| 'loadNewestMessages'
|
||||
| 'loadOlderMessages'
|
||||
|
|
|
@ -509,7 +509,6 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||
learnMoreAboutDeliveryIssue,
|
||||
loadNewerMessages: this.model.loadNewerMessages.bind(this.model),
|
||||
loadNewestMessages: this.model.loadNewestMessages.bind(this.model),
|
||||
loadAndScroll: this.model.loadAndScroll.bind(this.model),
|
||||
loadOlderMessages: this.model.loadOlderMessages.bind(this.model),
|
||||
markMessageRead,
|
||||
onBlock: createMessageRequestResponseHandler(
|
||||
|
|
Loading…
Reference in a new issue