Commit 203d800d authored by Leonardo Aramaki's avatar Leonardo Aramaki

Clear Realm on asynchronous thread and also clear cookies.

parent 9e1504be
......@@ -251,12 +251,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
R.string.server_config_activity_authenticating, Snackbar.LENGTH_INDEFINITE));
}
public void showLogoutMessage() {
statusTicker.updateStatus(StatusTicker.STATUS_LOGGING_OUT,
Snackbar.make(findViewById(getLayoutContainerForFragment()),
"Logging Out...", Snackbar.LENGTH_INDEFINITE));
}
@Override
public void showConnectionOk() {
statusTicker.updateStatus(StatusTicker.STATUS_DISMISS, null);
......@@ -314,11 +308,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
@DebugLog
public void hideLogoutMessage() {
statusTicker.updateStatus(StatusTicker.STATUS_DISMISS, null);
}
@DebugLog
public void onLogout() {
if (new RocketChatCache(getApplicationContext()).getSelectedServerHostname() == null) {
......
......@@ -325,7 +325,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
public void onLogoutCleanUp() {
Activity activity = getActivity();
if (activity != null && activity instanceof MainActivity) {
((MainActivity) activity).hideLogoutMessage();
((MainActivity) activity).onLogout();
presenter.onLogout(task -> {
if (task.isFaulted()) {
......@@ -343,7 +342,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
presenter.beforeLogoutCleanUp();
final Activity activity = getActivity();
if (activity != null && activity instanceof MainActivity) {
((MainActivity) activity).showLogoutMessage();
// Clear subscriptions on MainPresenter.
((MainActivity) activity).beforeLogoutCleanUp();
}
......
......@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.sidebar;
import android.support.annotation.NonNull;
import android.support.v4.util.Pair;
import android.webkit.CookieManager;
import java.util.ArrayList;
import java.util.List;
......@@ -154,7 +155,8 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
String currentHostname = rocketChatCache.getSelectedServerHostname();
RealmHelper realmHelper = RealmStore.getOrCreate(currentHostname);
realmHelper.executeTransaction(realm -> {
realm.deleteAll();
realm.executeTransactionAsync(realmObj -> realmObj.deleteAll());
CookieManager.getInstance().removeAllCookie();
ConnectivityManagerApi connectivityManagerApi = ConnectivityManager.getInstance(RocketChatApplication.getInstance());
connectivityManagerApi.removeServer(currentHostname);
rocketChatCache.removeHostname(currentHostname);
......
......@@ -122,7 +122,7 @@ public class RealmHelper {
return task.getTask();
}
private Task<Void> executeTransactionAsync(final RealmHelper.Transaction transaction) {
public Task<Void> executeTransactionAsync(final RealmHelper.Transaction transaction) {
final TaskCompletionSource<Void> task = new TaskCompletionSource<>();
final Realm realm = instance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment