-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: expose room avatars in room subscriptions #203
Closed
Closed
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0b3c86f
Define Room.Avatar
569c441
WIP test cases
4edec89
Global cache: track m.room.avatar
5c717c0
RoomDelta: track when m.room.avatar changes
acf76b0
Heroes: track avatar URLs
9583663
Invites: extract room avatar_url
3e73fc8
WIP UserRoomData has a ResolvedAvatarURL
7ace2d9
Improve tests
e9ebe8a
Remove redundant test fn
b2fd2db
Change avatar serialisation per MSC update
2de017e
RoomMetadata.AvatarURL: rename to AvatarEvent, parse correctly
9ecbb48
Same rename for InviteData
e43beb2
Tweak test
851b18d
Checkpoint
0da3a29
Fix weird hero duplication bug I can't explain
b943a60
Fix not updating heroes' avatars
5051c20
WIP on next test case
c26f29b
It would help if I committed this
cc1681f
And these tests
df98a71
SetRoom: omit the current user as a hero
bfd8448
Checkpoint
3213b92
Chceckpoint
f68d73f
fix rest of that test
dd3f09e
Only use AvatarChange at the output
7cf1d23
SlidingSyncUntilMembership: ignore displayname and avatar
49f9670
Extra test
9e99476
Fixup propagation tests
432397a
new test
10bc834
TODO note
4fb80da
test updates
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package sync3 | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
) | ||
|
||
// An AvatarChange represents a change to a room's avatar. There are three cases: | ||
// - an empty string represents no change, and should be omitted when JSON-serialised; | ||
// - the sentinel `<no-avatar>` represents a room that has never had an avatar, | ||
// or a room whose avatar has been removed. It is JSON-serialised as null. | ||
// - All other strings represent the current avatar of the room and JSON-serialise as | ||
// normal. | ||
type AvatarChange string | ||
|
||
const DeletedAvatar = AvatarChange("<no-avatar>") | ||
const UnchangedAvatar AvatarChange = "" | ||
|
||
// NewAvatarChange interprets an optional avatar string as an AvatarChange. | ||
func NewAvatarChange(avatar string) AvatarChange { | ||
if avatar == "" { | ||
return DeletedAvatar | ||
} | ||
return AvatarChange(avatar) | ||
} | ||
|
||
func (a AvatarChange) MarshalJSON() ([]byte, error) { | ||
if a == DeletedAvatar { | ||
return []byte(`null`), nil | ||
} else { | ||
return json.Marshal(string(a)) | ||
} | ||
} | ||
|
||
// Note: the unmarshalling is only used in tests. | ||
func (a *AvatarChange) UnmarshalJSON(data []byte) error { | ||
if bytes.Equal(data, []byte("null")) { | ||
*a = DeletedAvatar | ||
return nil | ||
} | ||
return json.Unmarshal(data, (*string)(a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confusingly I didn't seem to have to do this---SetRoom did it for me?