From 853134176abff13a6386b10b4c3f258a08a13201 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 17 Sep 2024 11:30:36 +0200 Subject: [PATCH] fix to show accounts from older servers in switch account dialog if invitations were not supported, the account did not show up Signed-off-by: Marcel Hibbe --- .../dialog/ChooseAccountDialogFragment.java | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java b/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java index 24c7de5e11..8e53821479 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java @@ -170,27 +170,21 @@ public void onSubscribe(Disposable d) { @Override public void onNext(InvitationsModel invitationsModel) { - Participant participant; - participant = new Participant(); - participant.setActorType(Participant.ActorType.USERS); - participant.setActorId(userId); - participant.setDisplayName(finalUserEntity.getDisplayName()); - userItems.add( - new AdvancedUserItem( - participant, - finalUserEntity, - null, - viewThemeUtils, - invitationsModel.getInvitations().size() - )); - adapter.addListener(onSwitchItemClickListener); - adapter.addListener(onSwitchItemLongClickListener); - adapter.updateDataSet(userItems, false); + addAccountToSwitcherList( + userId, + finalUserEntity, + invitationsModel.getInvitations().size() + ); } @Override public void onError(@io.reactivex.annotations.NonNull Throwable e) { Log.e(TAG, "Failed to fetch invitations", e); + addAccountToSwitcherList( + userId, + finalUserEntity, + 0 + ); } @Override @@ -203,6 +197,29 @@ public void onComplete() { } } + private void addAccountToSwitcherList( + String userId, + User finalUserEntity, + int actionsRequiredCount + ) { + Participant participant; + participant = new Participant(); + participant.setActorType(Participant.ActorType.USERS); + participant.setActorId(userId); + participant.setDisplayName(finalUserEntity.getDisplayName()); + userItems.add( + new AdvancedUserItem( + participant, + finalUserEntity, + null, + viewThemeUtils, + actionsRequiredCount + )); + adapter.addListener(onSwitchItemClickListener); + adapter.addListener(onSwitchItemLongClickListener); + adapter.updateDataSet(userItems, false); + } + private void setupListeners(User user) { // Creating listeners for quick-actions binding.currentAccount.getRoot().setOnClickListener(v -> dismiss());