Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions opennow-stable/capacitor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
},
"allowMixedContent": false,
"captureInput": true,
"webContentsDebuggingEnabled": false
"webContentsDebuggingEnabled": true
Comment thread
capy-ai[bot] marked this conversation as resolved.
},
"plugins": {
"SplashScreen": {
"launchShowDuration": 1500,
"launchAutoHide": true,
"launchShowDuration": 0,
"launchAutoHide": false,
"backgroundColor": "#0f172a",
"androidSplashResourceName": "splash",
"showSpinner": false
Expand Down
65 changes: 65 additions & 0 deletions opennow-stable/src/renderer/src/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Component, type ReactNode, type ErrorInfo } from "react";

interface Props {
children: ReactNode;
}

interface State {
error: Error | null;
}

export class ErrorBoundary extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { error: null };
}

static getDerivedStateFromError(error: Error): State {
return { error };
}

componentDidCatch(error: Error, info: ErrorInfo) {
console.error("[ErrorBoundary] Caught:", error, info);
}

render() {
if (this.state.error) {
return (
<div style={{
position: "fixed", inset: 0,
display: "flex", flexDirection: "column",
alignItems: "center", justifyContent: "center",
background: "#0a0a0c", color: "#ececef",
padding: "24px", fontFamily: "monospace",
gap: "16px", textAlign: "center",
}}>
<div style={{ fontSize: "1.2rem", fontWeight: 700, color: "#f87171" }}>
App Error
</div>
<div style={{
background: "#131316", border: "1px solid rgba(255,255,255,0.1)",
borderRadius: "8px", padding: "16px",
fontSize: "0.8rem", color: "#9a9aa3",
maxWidth: "90vw", overflowX: "auto", textAlign: "left",
whiteSpace: "pre-wrap", wordBreak: "break-word",
}}>
{this.state.error.message}
{"\n\n"}
{this.state.error.stack}
</div>
<button
onClick={() => window.location.reload()}
style={{
padding: "10px 24px", borderRadius: "8px",
background: "#58d98a", color: "#062315",
border: "none", fontWeight: 700, cursor: "pointer",
}}
>
Reload
</button>
</div>
);
}
return this.props.children;
}
}
15 changes: 14 additions & 1 deletion opennow-stable/src/renderer/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ import React from "react";
import ReactDOM from "react-dom/client";

import { App } from "./App";
import { ErrorBoundary } from "./ErrorBoundary";
import "./styles.css";

// Hide the Capacitor splash screen as soon as the JS bundle has parsed and
// the React tree is about to render. This prevents the black-screen flash
// that occurs when launchAutoHide dismisses the splash before React is ready.
const cap = (window as any).Capacitor;
if (cap?.isNativePlatform?.()) {
import("@capacitor/splash-screen").then(({ SplashScreen }) => {
SplashScreen.hide({ fadeOutDuration: 200 });
}).catch(() => {});
}

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
<ErrorBoundary>
<App />
</ErrorBoundary>
</React.StrictMode>,
);
Loading