-
Notifications
You must be signed in to change notification settings - Fork 759
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
Immutable NotifiableEvent models #4182
Immutable NotifiableEvent models #4182
Conversation
@@ -238,87 +232,4 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() { | |||
} | |||
return false | |||
} | |||
|
|||
private fun handleNotificationWithoutSyncingMode(data: Map<String, String>, session: Session?) { |
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.
this was unused, if we want it back we can retrieve it from the source control history
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.
Thanks for the cleanup. In practice I think this code will be lost forever :), but anyway, this is not a big loss
roomId = roomId, | ||
timestamp = event.originServerTs ?: 0, | ||
noisy = false, // will be set later | ||
noisy = isNoisy, | ||
title = stringProvider.getString(R.string.notification_new_invitation), | ||
description = body.toString(), | ||
soundName = null, // will be set 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.
this comment is a lie! the soundName
is in fact never updated
hasBeenDisplayed = false | ||
eventList.replace(eventId) { | ||
when (it) { | ||
is InviteNotifiableEvent -> it.copy(isRedacted = true).apply { hasBeenDisplayed = false } |
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.
updating hasBeenDisplayed
is temporary
in the redesign simply mutating the contents of the eventList
will allow the notifications to be rerendered, no need to use the hasBeenDisplayed
state
the eventList
will be a 1 to 1 mapping of the currently displaying notifications
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.
the eventList will be a 1 to 1 mapping of the currently displaying notifications
Could be nice to have this comment above eventList
declaration
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.
will add 👍
- also makes the notifiable events sealed interfaces so that we can copy the data classes with new redacted values when it changes
…ed or made immutable by the notification redesign
…can be replaced - makes the property immutable as only the creation of the event knows if it can be replace eg it came from a push or the /sync event stream
55681b1
to
d5e73cc
Compare
…tation Including room name in the invitation notification
val content = event.content?.toModel<RoomMemberContent>() ?: return null | ||
val roomId = event.roomId ?: return null | ||
val dName = event.senderId?.let { session.getRoomMember(it, roomId)?.displayName } | ||
if (Membership.INVITE == content.membership) { | ||
val body = noticeEventFormatter.format(event, dName, isDm = session.getRoomSummary(roomId)?.isDirect.orFalse()) | ||
val roomSummary = session.getRoomSummary(roomId) |
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.
the room name change is from #4230 (for next time I'll be sure to better highlight the merge ordering to avoid growing diffs)
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.
LGTM, can be merged to the other branch.
I have to admit I made a fast review, will read (and test) more carefully the PR which will land to develop
.
|
||
val notifiableEvent = resolveMessageEvent(timelineEvent, session) | ||
|
||
if (notifiableEvent == null) { |
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.
resolveMessageEvent
no longer returns null 🎉
@bmarty thanks! this PR is probably the lowest risk compared to the big creation/display split and the diffing changes I could create a separate PR will all the changes merged purely for testing if you think that would help? |
Yes, it will be a PR from branch |
yep exactly ^^^ although now I think about it, it might be better to PR the main logic change and the diffing into the same PR, that way there's only 1 PR remaining. then we don't need to the separate test branch (in this case) it's a bit easier to review new code by itself than new code + changes I'll still raise the full feature PR against develop for PR/commit tracking purposes but it will only contain already reviewed PRs |
A little bit of clean up to attempt to reduce the notification redesign PR size...
Updates the
NotifiableEvent
models to favour immutable state, this allows us to the simplify the mutation flowsNotifiableEventResolver
full control over the creation of the events (when I get time I'll revisit and add tests)isPushGatewayEvent
->canBeReplaced
isNoisy
is calculated at the point of creation rather than appended later onhandleNotificationWithoutSyncingMode
andlockScreenVisibility
Notice how the summary sneaks through in the reading gif, this will also be fixed by the redesign.
*this doesn't include updating
hasBeenDisplayed
as this will be removed entirely*against a feature branch