Fix stuck safety number modal overlay
This commit is contained in:
parent
3aa488c3d5
commit
f5eb17e0d1
2 changed files with 49 additions and 27 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// Copyright 2021-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as log from '../logging/log';
|
||||
|
@ -7,19 +7,19 @@ import type { MessageAttributesType } from '../model-types.d';
|
|||
import * as Errors from '../types/errors';
|
||||
|
||||
export async function getMessagesById(
|
||||
messageIds: ReadonlyArray<string>
|
||||
messageIds: Iterable<string>
|
||||
): Promise<Array<MessageModel>> {
|
||||
const messagesFromMemory: Array<MessageModel> = [];
|
||||
const messageIdsToLookUpInDatabase: Array<string> = [];
|
||||
|
||||
messageIds.forEach(messageId => {
|
||||
for (const messageId of messageIds) {
|
||||
const message = window.MessageController.getById(messageId);
|
||||
if (message) {
|
||||
messagesFromMemory.push(message);
|
||||
} else {
|
||||
messageIdsToLookUpInDatabase.push(messageId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let rawMessagesFromDatabase: Array<MessageAttributesType>;
|
||||
try {
|
||||
|
|
|
@ -369,12 +369,17 @@ export const getConversationCallMode = (
|
|||
return CallMode.None;
|
||||
};
|
||||
|
||||
const retryMessages = async (messageIds: Iterable<string>): Promise<void> => {
|
||||
const messages = await getMessagesById(messageIds);
|
||||
await Promise.all(messages.map(message => message.retrySend()));
|
||||
};
|
||||
|
||||
// Actions
|
||||
|
||||
const CLEAR_MESSAGES_PENDING_CONVERSATION_VERIFICATION =
|
||||
'conversations/CLEAR_MESSAGES_PENDING_CONVERSATION_VERIFICATION';
|
||||
export const COLORS_CHANGED = 'conversations/COLORS_CHANGED';
|
||||
export const COLOR_SELECTED = 'conversations/COLOR_SELECTED';
|
||||
const CANCEL_MESSAGES_PENDING_CONVERSATION_VERIFICATION =
|
||||
'conversations/CANCEL_MESSAGES_PENDING_CONVERSATION_VERIFICATION';
|
||||
const COMPOSE_TOGGLE_EDITING_AVATAR =
|
||||
'conversations/compose/COMPOSE_TOGGLE_EDITING_AVATAR';
|
||||
const COMPOSE_ADD_AVATAR = 'conversations/compose/ADD_AVATAR';
|
||||
|
@ -386,9 +391,6 @@ const MESSAGE_STOPPED_BY_MISSING_VERIFICATION =
|
|||
const REPLACE_AVATARS = 'conversations/REPLACE_AVATARS';
|
||||
const UPDATE_USERNAME_SAVE_STATE = 'conversations/UPDATE_USERNAME_SAVE_STATE';
|
||||
|
||||
type CancelMessagesPendingConversationVerificationActionType = {
|
||||
type: typeof CANCEL_MESSAGES_PENDING_CONVERSATION_VERIFICATION;
|
||||
};
|
||||
type CantAddContactToGroupActionType = {
|
||||
type: 'CANT_ADD_CONTACT_TO_GROUP';
|
||||
payload: {
|
||||
|
@ -399,6 +401,9 @@ type ClearGroupCreationErrorActionType = { type: 'CLEAR_GROUP_CREATION_ERROR' };
|
|||
type ClearInvitedUuidsForNewlyCreatedGroupActionType = {
|
||||
type: 'CLEAR_INVITED_UUIDS_FOR_NEWLY_CREATED_GROUP';
|
||||
};
|
||||
type ClearMessagesPendingConversationVerificationActionType = {
|
||||
type: typeof CLEAR_MESSAGES_PENDING_CONVERSATION_VERIFICATION;
|
||||
};
|
||||
type CloseCantAddContactToGroupModalActionType = {
|
||||
type: 'CLOSE_CANT_ADD_CONTACT_TO_GROUP_MODAL';
|
||||
};
|
||||
|
@ -730,11 +735,11 @@ type ReplaceAvatarsActionType = {
|
|||
};
|
||||
};
|
||||
export type ConversationActionType =
|
||||
| CancelMessagesPendingConversationVerificationActionType
|
||||
| CantAddContactToGroupActionType
|
||||
| ClearChangedMessagesActionType
|
||||
| ClearGroupCreationErrorActionType
|
||||
| ClearInvitedUuidsForNewlyCreatedGroupActionType
|
||||
| ClearMessagesPendingConversationVerificationActionType
|
||||
| ClearSelectedMessageActionType
|
||||
| ClearUnreadMetricsActionType
|
||||
| CloseCantAddContactToGroupModalActionType
|
||||
|
@ -1243,19 +1248,39 @@ function verifyConversationsStoppingMessageSend(): ThunkAction<
|
|||
void,
|
||||
RootStateType,
|
||||
unknown,
|
||||
never
|
||||
ClearMessagesPendingConversationVerificationActionType
|
||||
> {
|
||||
return async (_dispatch, getState) => {
|
||||
const conversationIds = Object.keys(
|
||||
getState().conversations.outboundMessagesPendingConversationVerification
|
||||
return async (dispatch, getState) => {
|
||||
const { outboundMessagesPendingConversationVerification } =
|
||||
getState().conversations;
|
||||
|
||||
const allMessageIds = new Set<string>();
|
||||
const promises: Array<Promise<unknown>> = [];
|
||||
|
||||
Object.entries(outboundMessagesPendingConversationVerification).forEach(
|
||||
([conversationId, messageIds]) => {
|
||||
for (const messageId of messageIds) {
|
||||
allMessageIds.add(messageId);
|
||||
}
|
||||
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
if (!conversation) {
|
||||
return;
|
||||
}
|
||||
if (conversation.isUnverified()) {
|
||||
promises.push(conversation.setVerifiedDefault());
|
||||
}
|
||||
promises.push(conversation.setApproved());
|
||||
}
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
conversationIds.map(async conversationId => {
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
await conversation?.setVerifiedDefault();
|
||||
})
|
||||
);
|
||||
promises.push(retryMessages(allMessageIds));
|
||||
|
||||
dispatch({
|
||||
type: CLEAR_MESSAGES_PENDING_CONVERSATION_VERIFICATION,
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1317,7 +1342,7 @@ function cancelMessagesPendingConversationVerification(): ThunkAction<
|
|||
void,
|
||||
RootStateType,
|
||||
unknown,
|
||||
CancelMessagesPendingConversationVerificationActionType
|
||||
ClearMessagesPendingConversationVerificationActionType
|
||||
> {
|
||||
return async (dispatch, getState) => {
|
||||
const messageIdsPending = getMessageIdsPendingBecauseOfVerification(
|
||||
|
@ -1329,7 +1354,7 @@ function cancelMessagesPendingConversationVerification(): ThunkAction<
|
|||
});
|
||||
|
||||
dispatch({
|
||||
type: CANCEL_MESSAGES_PENDING_CONVERSATION_VERIFICATION,
|
||||
type: CLEAR_MESSAGES_PENDING_CONVERSATION_VERIFICATION,
|
||||
});
|
||||
|
||||
await window.Signal.Data.saveMessages(
|
||||
|
@ -1384,10 +1409,7 @@ function conversationChanged(
|
|||
id
|
||||
) ?? [];
|
||||
if (messageIdsPending.length) {
|
||||
const messagesPending = await getMessagesById(messageIdsPending);
|
||||
messagesPending.forEach(message => {
|
||||
message.retrySend();
|
||||
});
|
||||
retryMessages(messageIdsPending);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2237,7 +2259,7 @@ export function reducer(
|
|||
state: Readonly<ConversationsStateType> = getEmptyState(),
|
||||
action: Readonly<ConversationActionType>
|
||||
): ConversationsStateType {
|
||||
if (action.type === CANCEL_MESSAGES_PENDING_CONVERSATION_VERIFICATION) {
|
||||
if (action.type === CLEAR_MESSAGES_PENDING_CONVERSATION_VERIFICATION) {
|
||||
return {
|
||||
...state,
|
||||
outboundMessagesPendingConversationVerification: {},
|
||||
|
|
Loading…
Add table
Reference in a new issue