Skip to content

Commit

Permalink
fix import-export directly referring OverlayPluginApi without safety, c…
Browse files Browse the repository at this point in the history
…loses #42
  • Loading branch information
hibiyasleep committed Jul 31, 2017
1 parent 61a3664 commit 2a336e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/lib/import-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
config.update(k, d.data[k])
}
config.save()
OverlayPluginApi.broadcastMessage('reload')
sendMessage('reload')
location.reload()
}
})
Expand Down
25 changes: 13 additions & 12 deletions config/lib/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ const switchTab = function switchTab(target) {
$('body', 0).classList.toggle('hide-header', target === 'info')
}

const sendMessage = function sendMessage (message) {
if(window.OverlayPluginApi) {
OverlayPluginApi.broadcastMessage(message)
} else if(window.opener) {
window.opener.postMessage(message, '*')
} else {
new dialog('error', {
title: window.locale.get('ui.config.dialog.manual-reload.title'),
content: window.locale.get('ui.config.dialog.manual-reload.content')
})
}
}

;(function() {

let sendMessage = (message) => {
if(window.OverlayPluginApi) {
OverlayPluginApi.broadcastMessage(message)
} else if(window.opener) {
window.opener.postMessage(message, '*')
} else {
new dialog('error', {
title: window.locale.get('ui.config.dialog.manual-reload.title'),
content: window.locale.get('ui.config.dialog.manual-reload.content')
})
}
}

window.addEventListener('load', function(e) {

Expand Down

0 comments on commit 2a336e8

Please sign in to comment.