getUnverified/getUntrusted: Return conversation array, not collection
This commit is contained in:
parent
3991b06256
commit
da28b4d6cd
3 changed files with 21 additions and 25 deletions
|
@ -291,6 +291,7 @@ export const ForwardMessageModal: FunctionComponent<PropsType> = ({
|
||||||
onEscape={handleBackOrClose}
|
onEscape={handleBackOrClose}
|
||||||
onClose={close}
|
onClose={close}
|
||||||
overlayStyles={overlayStyles}
|
overlayStyles={overlayStyles}
|
||||||
|
useFocusTrap={false}
|
||||||
>
|
>
|
||||||
<animated.div
|
<animated.div
|
||||||
className="module-ForwardMessageModal"
|
className="module-ForwardMessageModal"
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { v4 as generateGuid } from 'uuid';
|
||||||
import type {
|
import type {
|
||||||
ConversationAttributesType,
|
ConversationAttributesType,
|
||||||
ConversationLastProfileType,
|
ConversationLastProfileType,
|
||||||
ConversationModelCollectionType,
|
|
||||||
LastMessageStatus,
|
LastMessageStatus,
|
||||||
MessageAttributesType,
|
MessageAttributesType,
|
||||||
QuotedMessageType,
|
QuotedMessageType,
|
||||||
|
@ -2783,19 +2782,17 @@ export class ConversationModel extends window.Backbone
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnverified(): ConversationModelCollectionType {
|
getUnverified(): Array<ConversationModel> {
|
||||||
if (isDirectConversation(this.attributes)) {
|
if (isDirectConversation(this.attributes)) {
|
||||||
return this.isUnverified()
|
return this.isUnverified() ? [this] : [];
|
||||||
? new window.Whisper.ConversationCollection([this])
|
|
||||||
: new window.Whisper.ConversationCollection();
|
|
||||||
}
|
}
|
||||||
return new window.Whisper.ConversationCollection(
|
return (
|
||||||
this.contactCollection?.filter(contact => {
|
this.contactCollection?.filter(contact => {
|
||||||
if (isMe(contact.attributes)) {
|
if (isMe(contact.attributes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return contact.isUnverified();
|
return contact.isUnverified();
|
||||||
})
|
}) || []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2844,22 +2841,21 @@ export class ConversationModel extends window.Backbone
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getUntrusted(): ConversationModelCollectionType {
|
getUntrusted(): Array<ConversationModel> {
|
||||||
if (isDirectConversation(this.attributes)) {
|
if (isDirectConversation(this.attributes)) {
|
||||||
if (this.isUntrusted()) {
|
if (this.isUntrusted()) {
|
||||||
return new window.Whisper.ConversationCollection([this]);
|
return [this];
|
||||||
}
|
}
|
||||||
return new window.Whisper.ConversationCollection();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new window.Whisper.ConversationCollection(
|
return (
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
this.contactCollection?.filter(contact => {
|
||||||
this.contactCollection!.filter(contact => {
|
|
||||||
if (isMe(contact.attributes)) {
|
if (isMe(contact.attributes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return contact.isUntrusted();
|
return contact.isUntrusted();
|
||||||
})
|
}) || []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import type { ConversationModel } from '../models/conversations';
|
||||||
import type {
|
import type {
|
||||||
GroupV2PendingMemberType,
|
GroupV2PendingMemberType,
|
||||||
MessageAttributesType,
|
MessageAttributesType,
|
||||||
ConversationModelCollectionType,
|
|
||||||
QuotedMessageType,
|
QuotedMessageType,
|
||||||
} from '../model-types.d';
|
} from '../model-types.d';
|
||||||
import type { MediaItemType, MediaItemMessageType } from '../types/MediaItem';
|
import type { MediaItemType, MediaItemMessageType } from '../types/MediaItem';
|
||||||
|
@ -2322,9 +2321,9 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
|
|
||||||
async isCallSafe(): Promise<boolean> {
|
async isCallSafe(): Promise<boolean> {
|
||||||
const contacts = await this.getUntrustedContacts();
|
const contacts = await this.getUntrustedContacts();
|
||||||
if (contacts && contacts.length) {
|
if (contacts.length) {
|
||||||
const callAnyway = await this.showSendAnywayDialog(
|
const callAnyway = await this.showSendAnywayDialog(
|
||||||
contacts.models,
|
contacts,
|
||||||
window.i18n('callAnyway')
|
window.i18n('callAnyway')
|
||||||
);
|
);
|
||||||
if (!callAnyway) {
|
if (!callAnyway) {
|
||||||
|
@ -2366,8 +2365,8 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
try {
|
try {
|
||||||
const contacts = await this.getUntrustedContacts(options);
|
const contacts = await this.getUntrustedContacts(options);
|
||||||
|
|
||||||
if (contacts && contacts.length) {
|
if (contacts.length) {
|
||||||
const sendAnyway = await this.showSendAnywayDialog(contacts.models);
|
const sendAnyway = await this.showSendAnywayDialog(contacts);
|
||||||
if (sendAnyway) {
|
if (sendAnyway) {
|
||||||
this.sendStickerMessage({ ...options, force: true });
|
this.sendStickerMessage({ ...options, force: true });
|
||||||
}
|
}
|
||||||
|
@ -2388,7 +2387,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
|
|
||||||
async getUntrustedContacts(
|
async getUntrustedContacts(
|
||||||
options: { force?: boolean } = {}
|
options: { force?: boolean } = {}
|
||||||
): Promise<null | ConversationModelCollectionType> {
|
): Promise<Array<ConversationModel>> {
|
||||||
const { model }: { model: ConversationModel } = this;
|
const { model }: { model: ConversationModel } = this;
|
||||||
|
|
||||||
// This will go to the trust store for the latest identity key information,
|
// This will go to the trust store for the latest identity key information,
|
||||||
|
@ -2398,7 +2397,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
|
|
||||||
if (options.force) {
|
if (options.force) {
|
||||||
if (unverifiedContacts.length) {
|
if (unverifiedContacts.length) {
|
||||||
await markAllAsVerifiedDefault(unverifiedContacts.models);
|
await markAllAsVerifiedDefault(unverifiedContacts);
|
||||||
// We only want force to break us through one layer of checks
|
// We only want force to break us through one layer of checks
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
options.force = false;
|
options.force = false;
|
||||||
|
@ -2411,13 +2410,13 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
|
|
||||||
if (options.force) {
|
if (options.force) {
|
||||||
if (untrustedContacts.length) {
|
if (untrustedContacts.length) {
|
||||||
await markAllAsApproved(untrustedContacts.models);
|
await markAllAsApproved(untrustedContacts);
|
||||||
}
|
}
|
||||||
} else if (untrustedContacts.length) {
|
} else if (untrustedContacts.length) {
|
||||||
return untrustedContacts;
|
return untrustedContacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async setQuoteMessage(messageId: null | string): Promise<void> {
|
async setQuoteMessage(messageId: null | string): Promise<void> {
|
||||||
|
@ -2560,8 +2559,8 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
this.disableMessageField();
|
this.disableMessageField();
|
||||||
const contacts = await this.getUntrustedContacts(options);
|
const contacts = await this.getUntrustedContacts(options);
|
||||||
|
|
||||||
if (contacts && contacts.length) {
|
if (contacts.length) {
|
||||||
const sendAnyway = await this.showSendAnywayDialog(contacts.models);
|
const sendAnyway = await this.showSendAnywayDialog(contacts);
|
||||||
if (sendAnyway) {
|
if (sendAnyway) {
|
||||||
this.sendMessage(message, mentions, { force: true, timestamp });
|
this.sendMessage(message, mentions, { force: true, timestamp });
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue