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);
|
||||
strictAssert(
|
||||
messageAttributes,
|
||||
`MessageCache.accessAttributesOrThrow/${source}: no message`
|
||||
`MessageCache.accessAttributesOrThrow/${source}: no message for id ${messageId}`
|
||||
);
|
||||
return messageAttributes;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ export class MessageCache {
|
|||
|
||||
strictAssert(
|
||||
messageAttributesFromDatabase,
|
||||
`MessageCache.resolveAttributes/${source}: no message`
|
||||
`MessageCache.resolveAttributes/${source}: no message for id ${messageId}`
|
||||
);
|
||||
|
||||
return this.freezeAttributes(messageAttributesFromDatabase);
|
||||
|
|
|
@ -18,10 +18,15 @@ export async function hydrateStoryContext(
|
|||
shouldSave?: boolean;
|
||||
} = {}
|
||||
): Promise<void> {
|
||||
const messageAttributes = await window.MessageCache.resolveAttributes(
|
||||
'hydrateStoryContext',
|
||||
messageId
|
||||
);
|
||||
let messageAttributes: MessageAttributesType;
|
||||
try {
|
||||
messageAttributes = await window.MessageCache.resolveAttributes(
|
||||
'hydrateStoryContext',
|
||||
messageId
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
const { storyId } = messageAttributes;
|
||||
if (!storyId) {
|
||||
|
@ -34,13 +39,18 @@ export async function hydrateStoryContext(
|
|||
return;
|
||||
}
|
||||
|
||||
const storyMessage =
|
||||
storyMessageParam === undefined
|
||||
? await window.MessageCache.resolveAttributes(
|
||||
'hydrateStoryContext/story',
|
||||
storyId
|
||||
)
|
||||
: window.MessageCache.toMessageAttributes(storyMessageParam);
|
||||
let storyMessage: MessageAttributesType | undefined;
|
||||
try {
|
||||
storyMessage =
|
||||
storyMessageParam === undefined
|
||||
? await window.MessageCache.resolveAttributes(
|
||||
'hydrateStoryContext/story',
|
||||
storyId
|
||||
)
|
||||
: window.MessageCache.toMessageAttributes(storyMessageParam);
|
||||
} catch {
|
||||
storyMessage = undefined;
|
||||
}
|
||||
|
||||
if (!storyMessage) {
|
||||
const conversation = window.ConversationController.get(
|
||||
|
|
Loading…
Add table
Reference in a new issue