瀏覽代碼

Replace non null check with early return if null

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Daniel Calviño Sánchez 2 年之前
父節點
當前提交
b07aaee140
共有 1 個文件被更改,包括 10 次插入8 次删除
  1. 10 8
      app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

+ 10 - 8
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -2147,15 +2147,17 @@ class ChatController(args: Bundle) :
     }
 
     private fun setupWebsocket() {
-        if (conversationUser != null) {
-            webSocketInstance =
-                if (WebSocketConnectionHelper.getMagicWebSocketInstanceForUserId(conversationUser.id!!) != null) {
-                    WebSocketConnectionHelper.getMagicWebSocketInstanceForUserId(conversationUser.id!!)
-                } else {
-                    Log.d(TAG, "magicWebSocketInstance became null")
-                    null
-                }
+        if (conversationUser == null) {
+            return
         }
+
+        webSocketInstance =
+            if (WebSocketConnectionHelper.getMagicWebSocketInstanceForUserId(conversationUser.id!!) != null) {
+                WebSocketConnectionHelper.getMagicWebSocketInstanceForUserId(conversationUser.id!!)
+            } else {
+                Log.d(TAG, "magicWebSocketInstance became null")
+                null
+            }
     }
 
     fun pullChatMessages(lookIntoFuture: Int, setReadMarker: Int = 1, xChatLastCommonRead: Int? = null) {