Soft assert for hydrating story context
This commit is contained in:
parent
a924591a8c
commit
ddde85cdd8
3 changed files with 24 additions and 5 deletions
|
@ -21,7 +21,7 @@ import {
|
||||||
import type { SentEventData } from '../textsecure/messageReceiverEvents';
|
import type { SentEventData } from '../textsecure/messageReceiverEvents';
|
||||||
import { isNotNil } from '../util/isNotNil';
|
import { isNotNil } from '../util/isNotNil';
|
||||||
import { isNormalNumber } from '../util/isNormalNumber';
|
import { isNormalNumber } from '../util/isNormalNumber';
|
||||||
import { strictAssert } from '../util/assert';
|
import { softAssert, strictAssert } from '../util/assert';
|
||||||
import { missingCaseError } from '../util/missingCaseError';
|
import { missingCaseError } from '../util/missingCaseError';
|
||||||
import { dropNull } from '../util/dropNull';
|
import { dropNull } from '../util/dropNull';
|
||||||
import type { ConversationModel } from './conversations';
|
import type { ConversationModel } from './conversations';
|
||||||
|
@ -324,16 +324,16 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
const conversation = this.getConversation();
|
const conversation = this.getConversation();
|
||||||
strictAssert(
|
softAssert(
|
||||||
conversation && isDirectConversation(conversation.attributes),
|
conversation && isDirectConversation(conversation.attributes),
|
||||||
'Hydrating story context on a non-private conversation'
|
'hydrateStoryContext: Not a type=direct conversation'
|
||||||
);
|
);
|
||||||
this.set({
|
this.set({
|
||||||
storyReplyContext: {
|
storyReplyContext: {
|
||||||
attachment: undefined,
|
attachment: undefined,
|
||||||
// This is ok to do because story replies only show in 1:1 conversations
|
// This is ok to do because story replies only show in 1:1 conversations
|
||||||
// so the story that was quoted should be from the same conversation.
|
// so the story that was quoted should be from the same conversation.
|
||||||
authorUuid: conversation.get('uuid'),
|
authorUuid: conversation?.get('uuid'),
|
||||||
// No messageId, referenced story not found!
|
// No messageId, referenced story not found!
|
||||||
messageId: '',
|
messageId: '',
|
||||||
},
|
},
|
||||||
|
|
|
@ -2869,7 +2869,11 @@ async function getConversationRangeCenteredOnMessage({
|
||||||
sentAt,
|
sentAt,
|
||||||
storyId,
|
storyId,
|
||||||
}),
|
}),
|
||||||
metrics: getMessageMetricsForConversationSync(conversationId, storyId),
|
metrics: getMessageMetricsForConversationSync(
|
||||||
|
conversationId,
|
||||||
|
storyId,
|
||||||
|
isGroup
|
||||||
|
),
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,21 @@
|
||||||
import { getEnvironment, Environment } from '../environment';
|
import { getEnvironment, Environment } from '../environment';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In production and beta, logs a warning and continues. For development it
|
||||||
|
* starts the debugger.
|
||||||
|
*/
|
||||||
|
export function softAssert(condition: unknown, message: string): void {
|
||||||
|
if (!condition) {
|
||||||
|
if (getEnvironment() === Environment.Development) {
|
||||||
|
debugger; // eslint-disable-line no-debugger
|
||||||
|
}
|
||||||
|
|
||||||
|
const err = new Error(message);
|
||||||
|
log.warn('softAssert failure:', err && err.stack ? err.stack : err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In production, logs an error and continues. In all other environments, throws an error.
|
* In production, logs an error and continues. In all other environments, throws an error.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue