Fix logout not working when server offline
authorAjay Bura <32841439+ajbura@users.noreply.github.com>
Thu, 11 Aug 2022 08:11:07 +0000 (13:41 +0530)
committerAjay Bura <32841439+ajbura@users.noreply.github.com>
Thu, 11 Aug 2022 08:11:07 +0000 (13:41 +0530)
src/client/action/logout.js

index 3c7b84864804b8a9bb5aa9ddd28fbcaa68f27a98..c4047bb780c6b5b93ced613356b688025b3d7891 100644 (file)
@@ -1,13 +1,16 @@
 import initMatrix from '../initMatrix';
 
-function logout() {
+async function logout() {
   const mx = initMatrix.matrixClient;
   mx.stopClient();
-  mx.logout().then(() => {
-    mx.clearStores();
-    window.localStorage.clear();
-    window.location.reload();
-  });
+  try {
+    await mx.logout();
+  } catch {
+    // ignore if failed to logout
+  }
+  mx.clearStores();
+  window.localStorage.clear();
+  window.location.reload();
 }
 
 export default logout;