Filter out invalid previews
The call to cli.getUrlPreview() might return an empty object ({}), which means there is in fact no preview for that URL. Signed-off-by: Paulo Pinto <paulo.pinto@automattic.com>
This commit is contained in:
parent
dabc13c98f
commit
432dd994bd
1 changed files with 4 additions and 1 deletions
|
@ -87,7 +87,10 @@ const fetchPreviews = (cli: MatrixClient, links: string[], ts: number):
|
|||
Promise<[string, IPreviewUrlResponse][]> => {
|
||||
return Promise.all<[string, IPreviewUrlResponse] | void>(links.map(async link => {
|
||||
try {
|
||||
return [link, await cli.getUrlPreview(link, ts)];
|
||||
const preview = await cli.getUrlPreview(link, ts);
|
||||
if (preview && Object.keys(preview).length > 0) {
|
||||
return [link, preview];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to get URL preview: " + error);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue