fix(app): show the server avatar on message notifications (#1879)

This commit is contained in:
Hampus authored and GitHub committed 2026-08-24 12:37:01 +02:00
1 parent e21544eac2
commit 5821a68816
5 files changed
+47 -14

No files matched your search

@@ -0,0 +1,35 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import GuildMembers from '@app/features/member/state/GuildMembers';
import {isDesktop} from '@app/features/ui/utils/NativeUtils';
import type {User} from '@app/features/user/models/User';
import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';
import type {MediaProxyImageSize} from '@fluxer/constants/src/MediaProxyImageSizes';
export const NATIVE_NOTIFICATION_ICON_CSS_SIZE: MediaProxyImageSize = 128;
export function getNotificationIconURL(user: Pick<User, 'id' | 'avatar'>, guildId?: string | null): string {
const member = guildId ? GuildMembers.getMember(guildId, user.id) : null;
const nativeIcon = isDesktop();
if (guildId && member) {
return nativeIcon
? AvatarUtils.getGuildMemberNotificationAvatarURL({
guildId,
userId: user.id,
avatar: user.avatar,
memberAvatar: member.avatar,
avatarUnset: member.isAvatarUnset(),
size: NATIVE_NOTIFICATION_ICON_CSS_SIZE,
})
: AvatarUtils.getGuildMemberDisplayAvatarURL({
guildId,
user,
memberAvatar: member.avatar,
avatarUnset: member.isAvatarUnset(),
animated: false,
});
}
return nativeIcon
? AvatarUtils.getUserNotificationAvatarURL(user, NATIVE_NOTIFICATION_ICON_CSS_SIZE)
: AvatarUtils.getUserAvatarURL(user, false);
}
@@ -2,6 +2,7 @@
import Authentication from '@app/features/auth/state/Authentication';
import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';
import {getNotificationIconURL} from '@app/features/notification/utils/NotificationIconURL';
import {SoundType} from '@app/features/notification/utils/SoundUtils';
import type {NotificationAlertOptions} from '@app/features/platform/notifications/NotificationAlertOptions';
import {getNotificationAlertOptions} from '@app/features/platform/notifications/NotificationAlertOptions';
@@ -12,7 +13,6 @@ import Sound from '@app/features/ui/state/Sound';
import {getElectronAPI, hasUnavailableElectronNativeContext, isDesktop} from '@app/features/ui/utils/NativeUtils';
import {isInstalledIOSPwa, isInstalledPwa, isMobileOrTablet} from '@app/features/ui/utils/PwaUtils';
import Users from '@app/features/user/state/Users';
import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';
import type {I18n} from '@lingui/core';
import {msg} from '@lingui/core/macro';
@@ -126,12 +126,13 @@ const requestBrowserPermission = async (): Promise<PermissionResult> => {
return 'denied';
}
};
const getCurrentUserAvatar = (): string | null => {
const currentUserId = Authentication.currentUserId;
if (!currentUserId) return null;
const currentUser = Users.getUser(currentUserId);
if (!currentUser) return null;
return AvatarUtils.getUserNotificationAvatarURL(currentUser);
return getNotificationIconURL(currentUser);
};
async function handleDeniedPermission(i18n: I18n): Promise<void> {