fix(app): apply instance branding to system DM (#3355)

This commit is contained in:
Tarek authored and GitHub committed 2026-10-10 20:36:02 +02:00
1 parent 7197371123
commit 6b6ae13919
11 files changed
+178 -12

No files matched your search

@@ -1,11 +1,14 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
import {getUserAccentColor} from '@app/features/theme/utils/AccentColorUtils';
import {ProfileBody} from '@app/features/user/components/modals/user_profile_modal/ProfileBody';
import {ProfileMediaHeader} from '@app/features/user/components/modals/user_profile_modal/ProfileMediaHeader';
import type {ProfileModalContentProps} from '@app/features/user/components/modals/user_profile_modal/UserProfileModalShared';
import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';
import * as ProfileDisplayUtils from '@app/features/user/utils/ProfileDisplayUtils';
import {resolveProfileGuildMembership, toProfileDisplayContext} from '@app/features/user/utils/ProfileGuildMembership';
import {FLUXERBOT_ID} from '@fluxer/constants/src/AppConstants';
import {
MEDIA_PROXY_AVATAR_SIZE_PROFILE,
MEDIA_PROXY_PROFILE_BANNER_SIZE_MODAL,
@@ -26,7 +29,12 @@ export const ProfileModalContent: React.FC<ProfileModalContentProps> = observer(
showProfileDataWarning,
}) => {
const effectiveProfile = profile?.getEffectiveProfile() ?? null;
const bannerColor = getUserAccentColor(user, effectiveProfile?.accent_color);
const isSystemUser = user.id === FLUXERBOT_ID;
const systemThemeColor =
isSystemUser && RuntimeConfig.isSelfHosted()
? RuntimeConfig.getSnapshotOrNull()?.appPublic.branding.theme_color
: null;
const bannerColor = systemThemeColor ?? getUserAccentColor(user, effectiveProfile?.accent_color);
const membership = resolveProfileGuildMembership(profile);
const profileContext = useMemo<ProfileDisplayUtils.ProfileDisplayContext>(
() =>
@@ -38,10 +46,13 @@ export const ProfileModalContent: React.FC<ProfileModalContentProps> = observer(
}),
[user, profile, membership],
);
const {avatarUrl, hoverAvatarUrl} = useMemo(
const {avatarUrl: profileAvatarUrl, hoverAvatarUrl: profileHoverAvatarUrl} = useMemo(
() => ProfileDisplayUtils.getProfileAvatarUrls(profileContext, previewOverrides, MEDIA_PROXY_AVATAR_SIZE_PROFILE),
[profileContext, previewOverrides],
);
const systemAvatarUrl = AvatarUtils.getSystemUserBrandingAvatarURL(user.id);
const avatarUrl = systemAvatarUrl ?? profileAvatarUrl;
const hoverAvatarUrl = systemAvatarUrl ?? profileHoverAvatarUrl;
const {bannerUrl, hoverBannerUrl} = useMemo(
() =>
ProfileDisplayUtils.getProfileBannerUrls(
@@ -59,8 +70,8 @@ export const ProfileModalContent: React.FC<ProfileModalContentProps> = observer(
profileContext={profileContext}
previewOverrides={previewOverrides}
bannerColor={bannerColor}
bannerUrl={bannerUrl}
hoverBannerUrl={hoverBannerUrl}
bannerUrl={isSystemUser ? null : bannerUrl}
hoverBannerUrl={isSystemUser ? null : hoverBannerUrl}
avatarUrl={avatarUrl}
hoverAvatarUrl={hoverAvatarUrl}
renderActionButtons={renderActionButtons}