pl-fe: static image should never fallback to a non-static one
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -8,9 +8,9 @@ const normalizeAccount = (account: BaseAccount) => {
|
||||
mute_expires_at: null,
|
||||
...account,
|
||||
avatar: account.avatar || account.avatar_static || missingAvatar,
|
||||
avatar_static: account.avatar_static || account.avatar || missingAvatar,
|
||||
avatar_static: account.avatar_static || missingAvatar,
|
||||
header: account.header || account.header_static || missingHeader,
|
||||
header_static: account.header_static || account.header || missingHeader,
|
||||
header_static: account.header_static || missingHeader,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -1,27 +1,15 @@
|
||||
import type { Group as BaseGroup } from 'pl-api';
|
||||
|
||||
const getDomainFromURL = (group: Pick<BaseGroup, 'url'>): string => {
|
||||
try {
|
||||
const url = group.url;
|
||||
return new URL(url).host;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
const normalizeGroup = (group: BaseGroup) => {
|
||||
const missingAvatar = require('pl-fe/assets/images/avatar-missing.png');
|
||||
const missingHeader = require('pl-fe/assets/images/header-missing.png');
|
||||
|
||||
const domain = getDomainFromURL(group);
|
||||
|
||||
return {
|
||||
...group,
|
||||
avatar: group.avatar || group.avatar_static || missingAvatar,
|
||||
avatar_static: group.avatar_static || group.avatar || missingAvatar,
|
||||
avatar_static: group.avatar_static || missingAvatar,
|
||||
header: group.header || group.header_static || missingHeader,
|
||||
header_static: group.header_static || group.header || missingHeader,
|
||||
domain,
|
||||
header_static: group.header_static || missingHeader,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user