-
Notifications
You must be signed in to change notification settings - Fork 739
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
Fix crash when opening an unknown room #6978
Conversation
…)` is called a few lines above.
…instead of `room.roomId`.
) : VectorViewModel<RoomDetailViewState, RoomDetailAction, RoomDetailViewEvents>(initialState), | ||
Timeline.Listener, ChatEffectManager.Delegate, CallProtocolsChecker.Listener, LocationSharingServiceConnection.Callback { | ||
|
||
private val room = session.getRoom(initialState.roomId)!! | ||
private val room = session.getRoom(initialState.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.
room
can be null now.
@@ -266,6 +278,7 @@ class TimelineViewModel @AssistedInject constructor( | |||
} | |||
|
|||
private fun prepareForEncryption() { | |||
if (room == null) return |
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.
I could have used ?
like room?.
and timeline?.
everywhere, but I think this is cleaner like this. When the room is null, there is nothing we can really do with this ViewModel.
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!
@@ -538,11 +553,13 @@ class TimelineViewModel @AssistedInject constructor( | |||
} | |||
|
|||
private fun handleJumpToReadReceipt(action: RoomDetailAction.JumpToReadReceipt) { | |||
if (room == null) return |
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.
For this kind of single line 'if room not null, do X' I'd just use optional chaining (room?
). It's a bit subjective, though.
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.
Yes, I have use the same pattern (nearly) everywhere for code consistency, but I admit that sometimes it's a bit too much.
Also doing like this has the advantage to not impact the git blame
.
|
SonarCloud Quality Gate failed. |
Buildkite will be happy, failure is due to matrix-org/pipelines#202 |
This error was seen before but has been reintroduced during refactoring. - see #6978
Type of change
Content
Fix a crash when user opens a Timeline of a unknown room. This PR also contains some code cleanup, can be reviewed commit per commit if necessary.
This PR does not fix the root cause, which is quite unclear for now. This can be related to thread / space / etc. But it fixes the crash, and display a full screen error to the user.
If we got rageshake with the screen content in developer mode, we may have more info on the room which is tried to be open.
Note: I have seen #6543, but I think this is compatible with this change. I would prefer to first merge this PR, and then handle #6543.
Motivation and context
Less crash.
fixes #5611
Screenshots / GIFs
In developer mode, more info will be displayed:
Tests
session.getRoom(initialState.roomId + "_you_will_not_find_me")
Tested devices
Checklist