Browse Source

Fix conversation creation process

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 5 years ago
parent
commit
ccb554e1f5

+ 1 - 1
app/src/main/java/com/nextcloud/talk/controllers/ChatController.java

@@ -358,7 +358,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
     }
 
     private void loadAvatarForStatusBar() {
-        if (currentConversation != null && currentConversation.getType().equals(Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) && getActivity() != null && conversationVoiceCallMenuItem != null) {
+        if (currentConversation != null && currentConversation.getType() != null && currentConversation.getType().equals(Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) && getActivity() != null && conversationVoiceCallMenuItem != null) {
             int avatarSize =
                     (int) DisplayUtils.convertDpToPixel(conversationVoiceCallMenuItem.getIcon().getIntrinsicWidth(), getActivity());
 

+ 30 - 4
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java

@@ -264,11 +264,37 @@ public class ContactsController extends BaseController implements SearchView.OnQ
                             bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId());
 
                             if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
-                                bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(),
-                                        Parcels.wrap(roomOverall.getOcs().getData()));
+                                ncApi.getRoom(credentials,
+                                        ApiUtils.getRoom(currentUser.getBaseUrl(),
+                                                roomOverall.getOcs().getData().getToken()))
+                                        .subscribeOn(Schedulers.io())
+                                        .observeOn(AndroidSchedulers.mainThread())
+                                        .subscribe(new Observer<RoomOverall>() {
 
-                                ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
-                                        roomOverall.getOcs().getData().getToken(), bundle, true);
+                                            @Override
+                                            public void onSubscribe(Disposable d) {
+
+                                            }
+
+                                            @Override
+                                            public void onNext(RoomOverall roomOverall) {
+                                                bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(),
+                                                        Parcels.wrap(roomOverall.getOcs().getData()));
+
+                                                ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
+                                                        roomOverall.getOcs().getData().getToken(), bundle, true);
+                                            }
+
+                                            @Override
+                                            public void onError(Throwable e) {
+
+                                            }
+
+                                            @Override
+                                            public void onComplete() {
+
+                                            }
+                                        });
                             } else {
                                 conversationIntent.putExtras(bundle);
                                 startActivity(conversationIntent);

+ 33 - 5
app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java

@@ -296,11 +296,39 @@ public class OperationsMenuController extends BaseController {
                                 @Override
                                 public void onNext(RoomOverall roomOverall) {
                                     conversation = roomOverall.getOcs().getData();
-                                    if (conversationType.equals(Conversation.ConversationType.ROOM_PUBLIC_CALL) && isGroupCallWorkaroundFinal) {
-                                        performGroupCallWorkaround(credentials);
-                                    } else {
-                                        inviteUsersToAConversation();
-                                    }
+
+                                    ncApi.getRoom(credentials,
+                                            ApiUtils.getRoom(currentUser.getBaseUrl(), conversation.getToken()))
+                                            .subscribeOn(Schedulers.io())
+                                            .observeOn(AndroidSchedulers.mainThread())
+                                            .subscribe(new Observer<RoomOverall>() {
+                                                @Override
+                                                public void onSubscribe(Disposable d) {
+
+                                                }
+
+                                                @Override
+                                                public void onNext(RoomOverall roomOverall) {
+                                                    conversation = roomOverall.getOcs().getData();
+                                                    if (conversationType.equals(Conversation.ConversationType.ROOM_PUBLIC_CALL) && isGroupCallWorkaroundFinal) {
+                                                        performGroupCallWorkaround(credentials);
+                                                    } else {
+                                                        inviteUsersToAConversation();
+                                                    }
+                                                }
+
+                                                @Override
+                                                public void onError(Throwable e) {
+                                                    showResultImage(false, false);
+                                                    dispose();
+                                                }
+
+                                                @Override
+                                                public void onComplete() {
+
+                                                }
+                                            });
+
                                 }
 
                                 @Override