@@ -242,6 +242,10 @@ i:not(.disabled):hover {
|
||||
* MODAL POPOVERS
|
||||
*/
|
||||
|
||||
.modal {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.modal .modal-background {
|
||||
content: ' ';
|
||||
position: fixed;
|
||||
|
||||
@@ -293,6 +293,14 @@ function dispatch (action, ...args) {
|
||||
if (action === 'exitModal') {
|
||||
state.modal = null
|
||||
}
|
||||
if (action === 'updateAvailable') {
|
||||
updateAvailable(args[0] /* version */)
|
||||
}
|
||||
if (action === 'skipVersion') {
|
||||
if (!state.saved.skippedVersions) state.saved.skippedVersions = []
|
||||
state.saved.skippedVersions.push(args[0] /* version */)
|
||||
saveState()
|
||||
}
|
||||
|
||||
// Update the virtual-dom, unless it's just a mouse move event
|
||||
if (action !== 'mediaMouseMoved') {
|
||||
@@ -300,6 +308,15 @@ function dispatch (action, ...args) {
|
||||
}
|
||||
}
|
||||
|
||||
// Shows a modal saying that we have an update
|
||||
function updateAvailable(version) {
|
||||
if (state.saved.skippedVersions && state.saved.skippedVersions.includes(version)) {
|
||||
console.log('new version skipped by user: v' + version)
|
||||
return
|
||||
}
|
||||
state.modal = { id: 'update-available-modal', version: version }
|
||||
}
|
||||
|
||||
// Plays or pauses the video. If isPaused is undefined, acts as a toggle
|
||||
function playPause (isPaused) {
|
||||
if (isPaused === state.playing.isPaused) {
|
||||
@@ -347,7 +364,7 @@ function setupIpc () {
|
||||
ipcRenderer.on('dispatch', (e, ...args) => dispatch(...args))
|
||||
|
||||
ipcRenderer.on('showOpenTorrentAddress', function (e) {
|
||||
state.modal = 'open-torrent-address-modal'
|
||||
state.modal = { id: 'open-torrent-address-modal' }
|
||||
update()
|
||||
})
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ module.exports = {
|
||||
badge: 0,
|
||||
progress: 0
|
||||
},
|
||||
modal: null, /* modal popover */
|
||||
errors: [], /* user-facing errors */
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,8 @@ var Header = require('./header')
|
||||
var Player = require('./player')
|
||||
var TorrentList = require('./torrent-list')
|
||||
var Modals = {
|
||||
'open-torrent-address-modal': require('./open-torrent-address-modal')
|
||||
'open-torrent-address-modal': require('./open-torrent-address-modal'),
|
||||
'update-available-modal': require('./update-available-modal')
|
||||
}
|
||||
|
||||
function App (state, dispatch) {
|
||||
@@ -62,7 +63,7 @@ function App (state, dispatch) {
|
||||
|
||||
function getModal () {
|
||||
if (state.modal) {
|
||||
var contents = Modals[state.modal](state, dispatch)
|
||||
var contents = Modals[state.modal.id](state, dispatch)
|
||||
return hx`
|
||||
<div class='modal'>
|
||||
<div class='modal-background'></div>
|
||||
|
||||
36
renderer/views/update-available-modal.js
Normal file
36
renderer/views/update-available-modal.js
Normal file
@@ -0,0 +1,36 @@
|
||||
module.exports = UpdateAvailableModal
|
||||
|
||||
var h = require('virtual-dom/h')
|
||||
var hyperx = require('hyperx')
|
||||
var hx = hyperx(h)
|
||||
|
||||
var electron = require('electron')
|
||||
|
||||
var {dispatch} = require('../lib/dispatcher')
|
||||
|
||||
function UpdateAvailableModal (state) {
|
||||
return hx`
|
||||
<div class='update-available-modal'>
|
||||
<p><strong>A new version of WebTorrent is available: v${state.modal.version}</strong></p>
|
||||
<p>We have an auto-updater for Windows and Mac, but not yet for Linux, so you'll have to download it manually. Sorry.</p>
|
||||
<p>
|
||||
<button class='primary' onclick=${handleOK}>Show Download Page</button>
|
||||
<button class='cancel' onclick=${handleCancel}>Skip This Release</button>
|
||||
</p>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
function handleKeyPress (e) {
|
||||
if (e.which === 13) handleOK() /* hit Enter to submit */
|
||||
}
|
||||
|
||||
function handleOK () {
|
||||
electron.shell.openExternal('https://github.com/feross/webtorrent-desktop/releases')
|
||||
dispatch('exitModal')
|
||||
}
|
||||
|
||||
function handleCancel () {
|
||||
dispatch('skipVersion', state.modal.version)
|
||||
dispatch('exitModal')
|
||||
}
|
||||
Reference in New Issue
Block a user