Consume changed plugins message in the UI
Summary: Relay message to the React app via postmessage. Later, we will subscribe to these messages and update the plugins Reviewed By: lblasa Differential Revision: D39539590 fbshipit-source-id: c6742e45330e71b63c135c0267e6e9c5817fc9ff
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c69d102ca1
commit
d3d2e189d0
@@ -68,6 +68,13 @@
|
||||
suppressErrors = true;
|
||||
});
|
||||
|
||||
socket.on('plugins-source-updated', (pluginsChanged) => {
|
||||
window.postMessage({
|
||||
type: 'plugins-source-updated',
|
||||
data: pluginsChanged
|
||||
})
|
||||
})
|
||||
|
||||
function openError(text) {
|
||||
if (suppressErrors) {
|
||||
return;
|
||||
@@ -105,4 +112,4 @@
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -65,13 +65,26 @@
|
||||
let suppressErrors = false;
|
||||
|
||||
const socket = new WebSocket(`ws://${location.host}`);
|
||||
window.devSocket = socket;
|
||||
|
||||
socket.addEventListener('message', ({ data: dataRaw }) => {
|
||||
const message = JSON.parse(dataRaw.toString())
|
||||
|
||||
if (message.event === 'hasErrors') {
|
||||
openError(message.payload);
|
||||
suppressErrors = true;
|
||||
if (typeof message.event === 'string') {
|
||||
switch (message.event) {
|
||||
case 'hasErrors': {
|
||||
openError(message.payload);
|
||||
suppressErrors = true;
|
||||
break;
|
||||
}
|
||||
case 'plugins-source-updated': {
|
||||
window.postMessage({
|
||||
type: 'plugins-source-updated',
|
||||
data: message.payload
|
||||
})
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -128,4 +141,4 @@
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user