-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
getMessageById
next to getMessagesById
- Loading branch information
1 parent
8e0b94e
commit 01b0156
Showing
4 changed files
with
36 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2021 Signal Messenger, LLC | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import * as log from '../logging/log'; | ||
import type { MessageModel } from '../models/messages'; | ||
import * as Errors from '../types/errors'; | ||
|
||
export async function getMessageById( | ||
messageId: string | ||
): Promise<MessageModel | undefined> { | ||
let message = window.MessageController.getById(messageId); | ||
if (message) { | ||
return message; | ||
} | ||
|
||
try { | ||
message = await window.Signal.Data.getMessageById(messageId, { | ||
Message: window.Whisper.Message, | ||
}); | ||
} catch (err: unknown) { | ||
log.error( | ||
`failed to load message with id ${messageId} ` + | ||
`due to error ${Errors.toLogFormat(err)}` | ||
); | ||
} | ||
|
||
if (!message) { | ||
return undefined; | ||
} | ||
|
||
message = window.MessageController.register(message.id, message); | ||
return message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters