From 73922680c1485a29a00d74736da26b844e3b6d6e Mon Sep 17 00:00:00 2001 From: John Livingston Date: Thu, 16 Nov 2023 10:46:58 +0100 Subject: [PATCH] Fix #276: Peertube v6.0.0 compatibility in chatrooms page: Using channel.avatars if channel.avatar is not available. --- CHANGELOG.md | 3 ++- client/common/configuration/templates/home.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee5e46dd..86deb965 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ ### Minor changes and fixes * Peertube v6.0.0 compatibility: - * avatars: using account.avatars if account.avatar is not available (Fix #275). + * xmpp avatars: using account.avatars if account.avatar is not available (Fix #275). + * chatrooms screen: using channel.avatars if channel.avatar is not available (Fix #276). * Translation updates: German, Dutch, Japanese, Basque. ## 8.0.2 diff --git a/client/common/configuration/templates/home.ts b/client/common/configuration/templates/home.ts index 7570476e..9a3d0882 100644 --- a/client/common/configuration/templates/home.ts +++ b/client/common/configuration/templates/home.ts @@ -33,6 +33,17 @@ async function renderConfigurationHome (registerClientOptions: RegisterClientOpt for (const channel of channels.data) { channel.livechatConfigurationUri = '/p/livechat/configuration/channel?channelId=' + encodeURIComponent(channel.id) + + // Note: since Peertube v6.0.0, channel.avatar is dropped, and we have to use channel.avatars. + // So, if !channel.avatar, we will search a suitable one in channel.avatars, and fill channel.avatar. + if (!channel.avatar && channel.avatars && Array.isArray(channel.avatars)) { + for (const avatar of channel.avatars) { + if (avatar.width === 120) { + channel.avatar = avatar + break + } + } + } } const view = {