fix: remove spurious reconnect sound on deploy/laptop wake, fix federated typing/asset display

This commit is contained in:
Jannis Braun
2026-03-04 20:40:05 +01:00
parent 65e9ee5203
commit c65a7387fa
4 changed files with 31 additions and 36 deletions
+16 -1
View File
@@ -15,9 +15,24 @@ export function resolveAssetUrl(filename: string | null | undefined, origin: str
* Mutates in-place for efficiency (called on arrays of members/messages).
*/
export function normalizeUserAssets<T extends { avatar?: string | null }>(user: T, origin: string): T {
if (origin && user.avatar) {
if (!origin) return user;
if (user.avatar) {
user.avatar = resolveAssetUrl(user.avatar, origin) ?? user.avatar;
}
// Qualify users local to the remote instance with their origin domain.
// These users have no homeInstance (they're native there), so the client
// can't distinguish them from its own local users without this step.
const u = user as Record<string, unknown>;
if (typeof u.username === 'string' && typeof u.id === 'string' && !u.homeInstance) {
try {
const host = new URL(origin).host;
u.homeInstance = host;
if (!u.homeUserId) u.homeUserId = u.id;
if (!(u.username as string).includes('@')) {
u.username = `${u.username}@${host}`;
}
} catch {}
}
return user;
}