Commit 14b2e34
authored
fix: recover profile and avatar loading (#566)
### Description
Fixes profile and avatar loading regressions introduced around the
MSC4440 bio compatibility work.
This PR addresses two related problems:
- Own profile data could disappear when `useUserProfile` encountered
`gay.fomx.biography` in an unexpected shape or when the field was
missing entirely.
- Avatar components could get stuck in fallback mode after a transient
image load failure, causing the account avatar and other avatars to
disappear until a full reload.
The fix does three things:
- parses `gay.fomx.biography` defensively with optional access instead
of assuming `m.text[0].body` always exists
- retries profile fetches when the cache was previously poisoned into an
`_fetched`-only state after normalization failed
- resets avatar error state when the image `src` changes so transient
media/auth failures can recover on later renders
This was verified against the broken Account settings / account switcher
behavior where avatar, banner, bio, status, and pronouns could appear
missing.
Fixup of #559
#### Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
### Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
### AI disclosure:
- [x] Partially AI assisted (GitHub Copilot)
`useUserProfile.ts`: Hardened MSC4440 bio parsing so missing or
malformed `gay.fomx.biography` data does not throw during normalization,
and allowed refetching when the profile cache only contains `_fetched:
true` from a prior failed normalization.
`UserAvatar.tsx` and `RoomAvatar.tsx`: Reset local image error state
when `src` changes so a temporary image load failure does not
permanently lock the component into fallback rendering.3 files changed
Lines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| |||
0 commit comments