mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-14 02:38:40 +03:00
Wrap avatar fetch in try catch
This commit is contained in:
parent
64b683a0df
commit
00ee3efbff
1 changed files with 17 additions and 9 deletions
|
@ -42,10 +42,14 @@ export default class HTMLExporter extends Exporter {
|
|||
const avatarUrl = Avatar.avatarUrlForRoom(this.room, 32, 32, "crop");
|
||||
const avatarPath = "room.png";
|
||||
if (avatarUrl) {
|
||||
const image = await fetch(avatarUrl);
|
||||
blob = await image.blob();
|
||||
this.totalSize += blob.size;
|
||||
this.addFile(avatarPath, blob);
|
||||
try {
|
||||
const image = await fetch(avatarUrl);
|
||||
blob = await image.blob();
|
||||
this.totalSize += blob.size;
|
||||
this.addFile(avatarPath, blob);
|
||||
} catch (err) {
|
||||
console.log("Failed to fetch room's avatar" + err);
|
||||
}
|
||||
}
|
||||
const avatar = (
|
||||
<BaseAvatar
|
||||
|
@ -205,11 +209,15 @@ export default class HTMLExporter extends Exporter {
|
|||
protected async saveAvatarIfNeeded(event: MatrixEvent) {
|
||||
const member = event.sender;
|
||||
if (!this.avatars.has(member.userId)) {
|
||||
const avatarUrl = this.getAvatarURL(event);
|
||||
this.avatars.set(member.userId, true);
|
||||
const image = await fetch(avatarUrl);
|
||||
const blob = await image.blob();
|
||||
this.addFile(`users/${member.userId.replace(/:/g, '-')}.png`, blob);
|
||||
try {
|
||||
const avatarUrl = this.getAvatarURL(event);
|
||||
this.avatars.set(member.userId, true);
|
||||
const image = await fetch(avatarUrl);
|
||||
const blob = await image.blob();
|
||||
this.addFile(`users/${member.userId.replace(/:/g, '-')}.png`, blob);
|
||||
} catch (err) {
|
||||
console.log("Failed to fetch user's avatar" + err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue