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][]> => {
|
Promise<[string, IPreviewUrlResponse][]> => {
|
||||||
return Promise.all<[string, IPreviewUrlResponse] | void>(links.map(async link => {
|
return Promise.all<[string, IPreviewUrlResponse] | void>(links.map(async link => {
|
||||||
try {
|
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) {
|
} catch (error) {
|
||||||
console.error("Failed to get URL preview: " + error);
|
console.error("Failed to get URL preview: " + error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue