Fix removals

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-12-06 12:46:25 +01:00
parent 5d9f4456ed
commit db96e94a60

View File

@ -320,22 +320,32 @@ public class SettingsController extends BaseController {
dispose(profileQueryDisposable); dispose(profileQueryDisposable);
}, () -> dispose(profileQueryDisposable)); }, () -> dispose(profileQueryDisposable));
removeAccountButton.setEnabled(true);
removeAccountButton.setOnClickListener(view1 -> { removeAccountButton.setOnClickListener(view1 -> {
removeAccountButton.setEnabled(false);
cookieManager.getCookieStore().removeAll(); cookieManager.getCookieStore().removeAll();
boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(userEntity.getId()); boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(userEntity.getId());
new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true)
.startNow().build().schedule();
if (otherUserExists && getView() != null) { if (otherUserExists && getView() != null) {
onViewBound(getView()); onViewBound(getView());
onAttach(getView()); onAttach(getView());
} else if (!otherUserExists) { } else if (!otherUserExists) {
getParentController().getRouter().setRoot(RouterTransaction.with( if (getParentController() == null || getParentController().getRouter() == null) {
new ServerSelectionController()) if (getActivity() != null) {
.pushChangeHandler(new VerticalChangeHandler()) // Something went very wrong, finish the app
.popChangeHandler(new VerticalChangeHandler())); getActivity().finish();
}
} else {
getParentController().getRouter().setRoot(RouterTransaction.with(
new ServerSelectionController())
.pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler()));
}
} }
new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true)
.startNow().build().schedule();
}); });
} }