Fix packaged app blank screen handling
Some checks failed
Release / Build Linux (push) Has been cancelled
Release / Build macOS (push) Has been cancelled

This commit is contained in:
Daniel 2026-05-15 18:03:34 +02:00
parent 0076b37a23
commit ead14077f1
4 changed files with 57 additions and 10 deletions

View file

@ -54,10 +54,14 @@ function getStoredCredentials() {
function writeCredentials(credentials) {
if (!safeStorage.isEncryptionAvailable()) {
throw new Error('Secure credential storage is not available on this system')
throw new Error('macOS Keychain is locked or unavailable. Unlock Keychain and try signing in again.')
}
try {
const encrypted = safeStorage.encryptString(JSON.stringify(credentials))
fs.writeFileSync(userDataPath(credentialFileName), encrypted)
} catch (err) {
throw new Error(`Could not save credentials to secure storage: ${err.message || err}`)
}
const encrypted = safeStorage.encryptString(JSON.stringify(credentials))
fs.writeFileSync(userDataPath(credentialFileName), encrypted)
}
function clearCredentials() {
@ -162,6 +166,7 @@ async function syncNotes(credentials, pruneBefore) {
}
function createWindow() {
const appIndex = path.join(__dirname, '..', 'dist', 'index.html')
const window = new BrowserWindow({
width: 1180,
height: 780,
@ -187,14 +192,23 @@ function createWindow() {
callback(false)
})
window.webContents.on('will-navigate', event => {
if (!isDev) event.preventDefault()
window.webContents.on('will-navigate', (event, url) => {
const allowedUrl = isDev ? 'http://127.0.0.1:5173/' : `file://${appIndex}`
if (url !== allowedUrl) event.preventDefault()
})
window.webContents.on('render-process-gone', (_event, details) => {
console.error('Renderer process gone:', details.reason, details.exitCode)
})
window.webContents.on('console-message', (_event, level, message, line, sourceId) => {
console.log(`[renderer:${level}] ${message} (${sourceId}:${line})`)
})
if (isDev) {
window.loadURL('http://127.0.0.1:5173')
} else {
window.loadFile(path.join(__dirname, '..', 'dist', 'index.html'))
window.loadFile(appIndex)
}
}

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "nextcloud-notes-desktop",
"version": "0.1.2",
"version": "0.1.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "nextcloud-notes-desktop",
"version": "0.1.2",
"version": "0.1.3",
"dependencies": {
"react": "^19.2.6",
"react-dom": "^19.2.6",

View file

@ -1,6 +1,6 @@
{
"name": "nextcloud-notes-desktop",
"version": "0.1.2",
"version": "0.1.3",
"private": true,
"description": "Fast cross-platform desktop client for Nextcloud Notes",
"author": {

View file

@ -102,6 +102,37 @@ function Login({ onLogin }) {
)
}
class ErrorBoundary extends React.Component {
constructor(props) {
super(props)
this.state = { error: null }
}
static getDerivedStateFromError(error) {
return { error }
}
componentDidCatch(error, errorInfo) {
console.error('Renderer error:', error, errorInfo)
}
render() {
if (this.state.error) {
return (
<main className="login-shell">
<section className="login-card">
<div className="brand-mark">!</div>
<h1>Nextcloud Notes hit an error</h1>
<p>The app did not start cleanly. This message replaces the blank screen so the issue can be diagnosed.</p>
<div className="error-box">{this.state.error.message || String(this.state.error)}</div>
</section>
</main>
)
}
return this.props.children
}
}
function App() {
const [account, setAccount] = React.useState(null)
const [notes, setNotes] = React.useState([])
@ -375,6 +406,8 @@ function App() {
createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
<ErrorBoundary>
<App />
</ErrorBoundary>
</React.StrictMode>
)