Account for stories that are sometimes not found in the database
This commit is contained in:
parent
0d9d561b99
commit
c1f4bac802
2 changed files with 23 additions and 13 deletions
|
@ -47,7 +47,7 @@ export class MessageCache {
|
||||||
const messageAttributes = this.accessAttributes(messageId);
|
const messageAttributes = this.accessAttributes(messageId);
|
||||||
strictAssert(
|
strictAssert(
|
||||||
messageAttributes,
|
messageAttributes,
|
||||||
`MessageCache.accessAttributesOrThrow/${source}: no message`
|
`MessageCache.accessAttributesOrThrow/${source}: no message for id ${messageId}`
|
||||||
);
|
);
|
||||||
return messageAttributes;
|
return messageAttributes;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ export class MessageCache {
|
||||||
|
|
||||||
strictAssert(
|
strictAssert(
|
||||||
messageAttributesFromDatabase,
|
messageAttributesFromDatabase,
|
||||||
`MessageCache.resolveAttributes/${source}: no message`
|
`MessageCache.resolveAttributes/${source}: no message for id ${messageId}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return this.freezeAttributes(messageAttributesFromDatabase);
|
return this.freezeAttributes(messageAttributesFromDatabase);
|
||||||
|
|
|
@ -18,10 +18,15 @@ export async function hydrateStoryContext(
|
||||||
shouldSave?: boolean;
|
shouldSave?: boolean;
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const messageAttributes = await window.MessageCache.resolveAttributes(
|
let messageAttributes: MessageAttributesType;
|
||||||
'hydrateStoryContext',
|
try {
|
||||||
messageId
|
messageAttributes = await window.MessageCache.resolveAttributes(
|
||||||
);
|
'hydrateStoryContext',
|
||||||
|
messageId
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { storyId } = messageAttributes;
|
const { storyId } = messageAttributes;
|
||||||
if (!storyId) {
|
if (!storyId) {
|
||||||
|
@ -34,13 +39,18 @@ export async function hydrateStoryContext(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const storyMessage =
|
let storyMessage: MessageAttributesType | undefined;
|
||||||
storyMessageParam === undefined
|
try {
|
||||||
? await window.MessageCache.resolveAttributes(
|
storyMessage =
|
||||||
'hydrateStoryContext/story',
|
storyMessageParam === undefined
|
||||||
storyId
|
? await window.MessageCache.resolveAttributes(
|
||||||
)
|
'hydrateStoryContext/story',
|
||||||
: window.MessageCache.toMessageAttributes(storyMessageParam);
|
storyId
|
||||||
|
)
|
||||||
|
: window.MessageCache.toMessageAttributes(storyMessageParam);
|
||||||
|
} catch {
|
||||||
|
storyMessage = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (!storyMessage) {
|
if (!storyMessage) {
|
||||||
const conversation = window.ConversationController.get(
|
const conversation = window.ConversationController.get(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue