Add reload button to control interface

This commit is contained in:
Max Goodhart
2020-06-19 08:01:59 -07:00
parent 1a3c82b2a5
commit a58a94aa51
5 changed files with 81 additions and 26 deletions

View File

@@ -175,6 +175,17 @@ export default class StreamWindow extends EventEmitter {
}
}
reloadView(viewIdx) {
const view = this.views.find(
(v) =>
v.state.matches('displaying') &&
v.state.context.pos.spaces.includes(viewIdx),
)
if (view) {
view.send('RELOAD')
}
}
send(...args) {
this.overlayView.webContents.send(...args)
}

View File

@@ -60,6 +60,8 @@ async function main() {
streamWindow.setViews(new Map(msg.views))
} else if (msg.type === 'set-listening-view') {
streamWindow.setListeningView(msg.viewIdx)
} else if (msg.type === 'reload-view') {
streamWindow.reloadView(msg.viewIdx)
}
}

View File

@@ -16,14 +16,11 @@ const viewStateMachine = Machine(
},
states: {
empty: {
entry: [
assign({
pos: {},
info: {},
url: null,
}),
'hideView',
],
entry: assign({
pos: {},
info: {},
url: null,
}),
invoke: {
src: 'clearView',
onError: {
@@ -45,6 +42,7 @@ const viewStateMachine = Machine(
}),
cond: 'urlUnchanged',
},
RELOAD: '.loading',
},
states: {
loading: {
@@ -80,6 +78,7 @@ const viewStateMachine = Machine(
running: {
initial: 'muted',
entry: 'positionView',
exit: 'hideView',
on: {
DISPLAY: {
actions: [