Add Clear cache and reload button (#793)
authormorguldir <morguldir@protonmail.com>
Sat, 17 Sep 2022 07:51:22 +0000 (09:51 +0200)
committerGitHub <noreply@github.com>
Sat, 17 Sep 2022 07:51:22 +0000 (13:21 +0530)
Inspired by: https://github.com/matrix-org/matrix-react-sdk/blob/3c5c2bef6dbac51ce6e1864056523815ca4c38d9/src/components/views/elements/ErrorBoundary.tsx#L61-L68

Signed-off-by: morguldir <morguldir@protonmail.com>
Signed-off-by: morguldir <morguldir@protonmail.com>
src/app/organisms/settings/Settings.jsx
src/client/state/settings.js

index 2e0f64bda510f239639d7b0f22f020e57e06b786..8baf589c743a658910d7c783ff28d47eadbc2d3e 100644 (file)
@@ -239,6 +239,7 @@ function AboutSection() {
             <div className="settings-about__btns">
               <Button onClick={() => window.open('https://github.com/ajbura/cinny')}>Source code</Button>
               <Button onClick={() => window.open('https://cinny.in/#sponsor')}>Support</Button>
+              <Button onClick={() => settings.clearCacheAndReload()} variant="danger">Clear cache & reload</Button>
             </div>
           </div>
         </div>
index 32f55fcc611ed9cec8c0c983d650f44b53e327ed..7b9635d333c7d932e4dc5d31d849e28d59fa67e9 100644 (file)
@@ -147,6 +147,14 @@ class Settings extends EventEmitter {
     return settings.isNotificationSounds;
   }
 
+  clearCacheAndReload() {
+    const mx = initMatrix.matrixClient;
+    mx.stopClient()
+    mx.store.deleteAllData().then(() => {
+        window.location.reload();
+    });
+}
+
   setter(action) {
     const actions = {
       [cons.actions.settings.TOGGLE_SYSTEM_THEME]: () => {