Exit the app when there is only this EOL account

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-05 09:02:28 +02:00 committed by Andy Scherzinger
parent 1f8905394e
commit c789152122
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 11 additions and 1 deletions

View file

@ -301,7 +301,12 @@ public class ConversationsListController extends BaseController implements Searc
.setNegativeButton(R.string.nc_cancel, new View.OnClickListener() {
@Override
public void onClick(View v) {
if (userUtils.hasMultipleUsers()) {
getRouter().pushController(RouterTransaction.with(new SwitchAccountController()));
} else {
getActivity().finishAffinity();
getActivity().finish();
}
}
})
.setInstanceStateHandler(ID_DELETE_CONVERSATION_DIALOG, saveStateHandler)

View file

@ -48,6 +48,11 @@ public class UserUtils {
.limit(1).get().value() > 0);
}
public boolean hasMultipleUsers() {
return (dataStore.count(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.notEqual(Boolean.TRUE))
.get().value() > 1);
}
public List getUsers() {
Result findUsersQueryResult = dataStore.select(User.class).where
(UserEntity.SCHEDULED_FOR_DELETION.notEqual(true)).get();