Skip to content
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

try to avoid NPE for currentConversation #4261

Merged
merged 1 commit into from
Sep 24, 2024

Commits on Sep 24, 2024

  1. try to avoid NPE for currentConversation

    On gplay console the following NPE was reported for the line
    
    participantPermissions = ParticipantPermissions(spreedCapabilities, currentConversation!!)
    
     E  FATAL EXCEPTION: main
              Process: com.nextcloud.talk2, PID: 6626
              java.lang.NullPointerException
              at com.nextcloud.talk.chat.ChatActivity.initObservers$lambda$13(ChatActivity.kt:583)
              at com.nextcloud.talk.chat.ChatActivity.$r8$lambda$QKH5JCFLmCzRMlSJ-EV-m4IW5ig(Unknown Source:0)
    
    which seems that currentConversation was null. If it would have been spreedCapabilities, then the error would have been thrown in the line before..
    
    A reason MAY BE that the observer is triggered before setData on the ViewModel is executed.
    While this fix is just not executing code when currentConversation is null, it's unsure if it will follow up problems (like an empty chat) or if the observer is triggered another time when currentConversation is available.
    
    So it's just a hotfix.
    To improve the situation in the long term, we should move more logic to viewModel and only use Flow instead to mix it with LiveData.
    
    Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
    mahibi authored and sowjanyakch committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    b78267d View commit details
    Browse the repository at this point in the history