Error popover, no more alert()s
This commit is contained in:
@@ -200,6 +200,10 @@ i:not(.disabled):hover {
|
|||||||
cursor: none;
|
cursor: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app.hide-header .header {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.header .title {
|
.header .title {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -719,6 +723,47 @@ body.drag .torrent-placeholder span {
|
|||||||
color: #9af;
|
color: #9af;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ERRORS
|
||||||
|
*/
|
||||||
|
|
||||||
|
.error-popover {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 1001;
|
||||||
|
top: 36px;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app.hide-header .error-popover {
|
||||||
|
top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-popover.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-popover .error,
|
||||||
|
.error-popover .title {
|
||||||
|
padding: 10px;
|
||||||
|
background-color: rgba(0, 0, 0, 0.8);
|
||||||
|
border-bottom: 1px solid #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-popover .title {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #c44;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-popover .error {
|
||||||
|
color: #bbb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-popover .error:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MEDIA QUERIES
|
* MEDIA QUERIES
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -636,8 +636,11 @@ function restoreBounds () {
|
|||||||
|
|
||||||
function onError (err) {
|
function onError (err) {
|
||||||
console.error(err.stack)
|
console.error(err.stack)
|
||||||
window.alert(err.message || err)
|
|
||||||
playInterfaceSound(config.SOUND_ERROR)
|
playInterfaceSound(config.SOUND_ERROR)
|
||||||
|
state.errors.push({
|
||||||
|
time: new Date().getTime(),
|
||||||
|
message: err.message || err
|
||||||
|
})
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ module.exports = {
|
|||||||
badge: 0,
|
badge: 0,
|
||||||
progress: 0
|
progress: 0
|
||||||
},
|
},
|
||||||
|
errors: [], /* user-facing errors */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Saved state is read from and written to a file every time the app runs.
|
* Saved state is read from and written to a file every time the app runs.
|
||||||
|
|||||||
@@ -23,28 +23,41 @@ function App (state, dispatch) {
|
|||||||
!state.video.isPaused &&
|
!state.video.isPaused &&
|
||||||
state.video.location === 'local'
|
state.video.location === 'local'
|
||||||
|
|
||||||
|
// Hide the header on Windows/Linux when in the player
|
||||||
|
// On OSX, the header appears as part of the title bar
|
||||||
|
var hideHeader = process.platform !== 'darwin' && state.url === 'player'
|
||||||
|
|
||||||
var cls = [
|
var cls = [
|
||||||
'view-' + state.url, /* e.g. view-home, view-player */
|
'view-' + state.url, /* e.g. view-home, view-player */
|
||||||
'is-' + process.platform /* e.g. is-darwin, is-win32, is-linux */
|
'is-' + process.platform /* e.g. is-darwin, is-win32, is-linux */
|
||||||
]
|
]
|
||||||
|
|
||||||
if (state.window.isFullScreen) cls.push('is-fullscreen')
|
if (state.window.isFullScreen) cls.push('is-fullscreen')
|
||||||
if (state.window.isFocused) cls.push('is-focused')
|
if (state.window.isFocused) cls.push('is-focused')
|
||||||
if (hideControls) cls.push('hide-video-controls')
|
if (hideControls) cls.push('hide-video-controls')
|
||||||
|
if (hideHeader) cls.push('hide-header')
|
||||||
|
|
||||||
return hx`
|
return hx`
|
||||||
<div class='app ${cls.join(' ')}'>
|
<div class='app ${cls.join(' ')}'>
|
||||||
${getHeader()}
|
${Header(state, dispatch)}
|
||||||
|
${getErrorPopover()}
|
||||||
<div class='content'>${getView()}</div>
|
<div class='content'>${getView()}</div>
|
||||||
${getModal()}
|
${getModal()}
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
function getHeader () {
|
function getErrorPopover () {
|
||||||
var isOSX = process.platform === 'darwin'
|
var now = new Date().getTime()
|
||||||
// Hide the header on Windows/Linux when in the player
|
var recentErrors = state.errors.filter((x) => now - x.time < 5000)
|
||||||
if (isOSX || state.url !== 'player') {
|
|
||||||
return Header(state, dispatch)
|
var errorElems = recentErrors.map(function (error) {
|
||||||
}
|
return hx`<div class='error'>${error.message}</div>`
|
||||||
|
})
|
||||||
|
return hx`
|
||||||
|
<div class='error-popover ${recentErrors.length > 0 ? 'visible' : 'hidden'}'>
|
||||||
|
<div class='title'>Error</div>
|
||||||
|
${errorElems}
|
||||||
|
</div>
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
function getModal () {
|
function getModal () {
|
||||||
|
|||||||
Reference in New Issue
Block a user