소스 검색

Add a reload button to error boundary

There are sometimes edge cases on iOS which cause the app to crash,
it’s good to have a reload button as there’s no browser chrome (reload,
back, forward) in an iOS standalone PWA.
nimbleghost 2 년 전
부모
커밋
9ba733d4e0
2개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 0
      web/public/static/langs/en.json
  2. 6 2
      web/src/components/ErrorBoundary.jsx

+ 1 - 0
web/public/static/langs/en.json

@@ -389,6 +389,7 @@
   "error_boundary_title": "Oh no, ntfy crashed",
   "error_boundary_title": "Oh no, ntfy crashed",
   "error_boundary_description": "This should obviously not happen. Very sorry about this.<br/>If you have a minute, please <githubLink>report this on GitHub</githubLink>, or let us know via <discordLink>Discord</discordLink> or <matrixLink>Matrix</matrixLink>.",
   "error_boundary_description": "This should obviously not happen. Very sorry about this.<br/>If you have a minute, please <githubLink>report this on GitHub</githubLink>, or let us know via <discordLink>Discord</discordLink> or <matrixLink>Matrix</matrixLink>.",
   "error_boundary_button_copy_stack_trace": "Copy stack trace",
   "error_boundary_button_copy_stack_trace": "Copy stack trace",
+  "error_boundary_button_reload_ntfy": "Reload ntfy",
   "error_boundary_stack_trace": "Stack trace",
   "error_boundary_stack_trace": "Stack trace",
   "error_boundary_gathering_info": "Gather more info …",
   "error_boundary_gathering_info": "Gather more info …",
   "error_boundary_unsupported_indexeddb_title": "Private browsing not supported",
   "error_boundary_unsupported_indexeddb_title": "Private browsing not supported",

+ 6 - 2
web/src/components/ErrorBoundary.jsx

@@ -101,11 +101,15 @@ class ErrorBoundaryImpl extends React.Component {
             }}
             }}
           />
           />
         </p>
         </p>
-        <p>
+        <div style={{ display: "flex", gap: 5 }}>
           <Button variant="outlined" onClick={() => this.copyStack()}>
           <Button variant="outlined" onClick={() => this.copyStack()}>
             {t("error_boundary_button_copy_stack_trace")}
             {t("error_boundary_button_copy_stack_trace")}
           </Button>
           </Button>
-        </p>
+
+          <Button variant="outlined" onClick={() => window.location.reload()}>
+            {t("error_boundary_button_reload_ntfy")}
+          </Button>
+        </div>
         <h3>{t("error_boundary_stack_trace")}</h3>
         <h3>{t("error_boundary_stack_trace")}</h3>
         {this.state.niceStack ? (
         {this.state.niceStack ? (
           <pre>{this.state.niceStack}</pre>
           <pre>{this.state.niceStack}</pre>