Additional PR changes

pull/2222/head
warrickct 3 years ago
parent efa482b002
commit abc188e889

@ -7,7 +7,6 @@ import {
declineConversation, declineConversation,
} from '../../interactions/conversationInteractions'; } from '../../interactions/conversationInteractions';
import { forceSyncConfigurationNowIfNeeded } from '../../session/utils/syncUtils'; import { forceSyncConfigurationNowIfNeeded } from '../../session/utils/syncUtils';
import { ReduxConversationType } from '../../state/ducks/conversations';
import { updateConfirmModal } from '../../state/ducks/modalDialog'; import { updateConfirmModal } from '../../state/ducks/modalDialog';
import { getSelectedConversation } from '../../state/selectors/conversations'; import { getSelectedConversation } from '../../state/selectors/conversations';
import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton'; import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton';

@ -1493,7 +1493,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
} }
} }
public async addSingleMessage(messageAttributes: MessageAttributesOptionals) { private async addSingleMessage(messageAttributes: MessageAttributesOptionals) {
const model = new MessageModel(messageAttributes); const model = new MessageModel(messageAttributes);
// no need to trigger a UI update now, we trigger a messagesAdded just below // no need to trigger a UI update now, we trigger a messagesAdded just below

@ -146,13 +146,8 @@ const handleContactReceived = async (
if (contactReceived.didApproveMe) { if (contactReceived.didApproveMe) {
// TODO: add message search in convo for pre-existing msgRequestResponse msg only happens once per convo // TODO: add message search in convo for pre-existing msgRequestResponse msg only happens once per convo
// if source of the sync matches conversationId await contactConvo.addSingleOutgoingMessage({
await contactConvo.addSingleMessage({ sent_at: _.toNumber(envelope.timestamp),
conversationId: contactConvo.get('id'),
source: envelope.source,
type: 'outgoing', // mark it as outgoing just so it appears below our sent attachment
sent_at: _.toNumber(envelope.timestamp), // TODO: maybe add timestamp to messageRequestResponse? confirm it doesn't exist first
received_at: Date.now(),
messageRequestResponse: { messageRequestResponse: {
isApproved: 1, isApproved: 1,
}, },

@ -389,12 +389,9 @@ export async function innerHandleSwarmContentMessage(
if (!convo.didApproveMe() && convo.isPrivate() && convo.isApproved()) { if (!convo.didApproveMe() && convo.isPrivate() && convo.isApproved()) {
await convo.setDidApproveMe(true); await convo.setDidApproveMe(true);
// Conversation was not approved before so a sync is needed // Conversation was not approved before so a sync is needed
await convo.addSingleMessage({ await convo.addSingleIncomingMessage({
conversationId: convo.get('id'), sent_at: _.toNumber(envelope.timestamp),
source: envelope.source, source: envelope.source,
type: 'outgoing', // mark it as outgoing just so it appears below our sent attachment
sent_at: _.toNumber(envelope.timestamp), // TODO: maybe add timestamp to messageRequestResponse? confirm it doesn't exist first
received_at: Date.now(),
messageRequestResponse: { messageRequestResponse: {
isApproved: 1, isApproved: 1,
}, },
@ -609,12 +606,9 @@ async function handleMessageRequestResponse(
await conversationToApprove.setDidApproveMe(isApproved); await conversationToApprove.setDidApproveMe(isApproved);
if (isApproved === true) { if (isApproved === true) {
// Conversation was not approved before so a sync is needed // Conversation was not approved before so a sync is needed
await conversationToApprove.addSingleMessage({ await conversationToApprove.addSingleIncomingMessage({
conversationId: conversationToApprove.get('id'),
source: envelope.source,
type: 'outgoing', // mark it as outgoing just so it appears below our sent attachment
sent_at: _.toNumber(envelope.timestamp), // TODO: maybe add timestamp to messageRequestResponse? confirm it doesn't exist first sent_at: _.toNumber(envelope.timestamp), // TODO: maybe add timestamp to messageRequestResponse? confirm it doesn't exist first
received_at: Date.now(), source: envelope.source,
messageRequestResponse: { messageRequestResponse: {
isApproved: 1, isApproved: 1,
}, },

Loading…
Cancel
Save