Skip to content

Commit

Permalink
Upgrade responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jaedb committed Jan 10, 2017
1 parent 15a9da0 commit 93aaffd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
9 changes: 3 additions & 6 deletions mopidy_iris/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,15 @@ def on_message(self, message):
)

# get system version and check for upgrade
elif messageJson['action'] == 'perform_upgrade':
elif messageJson['action'] == 'upgrade':
version = self.frontend.get_version()
version['upgrade_successful'] = self.frontend.perform_upgrade()
upgrade_successful = self.frontend.perform_upgrade()
send_message(
self.connectionid,
'response',
messageJson['request_id'],
{ 'version': version }
{ 'upgrade_successful': upgrade_successful, 'version': version }
)

# notify all clients of this change
broadcast( 'upgraded', { 'version': version })

# restart mopidy
elif messageJson['action'] == 'restart':
Expand Down
12 changes: 7 additions & 5 deletions src/js/services/pusher/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const PusherMiddleware = (function(){
// handle all manner of socket messages
const handleMessage = (ws, store, message) => {

//console.log('handleMessage', message)

switch (message.action){
case 'response':
if (typeof( deferredRequests[ message.request_id ]) !== 'undefined' ){
Expand Down Expand Up @@ -127,13 +129,13 @@ const PusherMiddleware = (function(){
break;

case 'START_UPGRADE':
request({ action: 'perform_upgrade' })
request({ action: 'upgrade' })
.then(
response => {
if (response.data.version.upgrade_successful){
uiActions.createNotification('Upgrade complete')
if (response.data.upgrade_successful){
store.dispatch( uiActions.createNotification('Upgrade complete') )
}else{
uiActions.createNotification('Upgrade failed, manual upgrade required')
store.dispatch( uiActions.createNotification('Upgrade failed, please upgrade manually','bad') )
}
store.dispatch({ type: 'VERSION', data: response.data })
}
Expand Down Expand Up @@ -180,7 +182,7 @@ const PusherMiddleware = (function(){
})
.then(
response => {
uiActions.createNotification('Authorization sent')
store.dispatch( uiActions.createNotification('Authorization sent') )
}
)
break;
Expand Down

0 comments on commit 93aaffd

Please sign in to comment.