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;
|
suppressErrors = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('plugins-source-updated', (pluginsChanged) => {
|
||||||
|
window.postMessage({
|
||||||
|
type: 'plugins-source-updated',
|
||||||
|
data: pluginsChanged
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
function openError(text) {
|
function openError(text) {
|
||||||
if (suppressErrors) {
|
if (suppressErrors) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -65,13 +65,26 @@
|
|||||||
let suppressErrors = false;
|
let suppressErrors = false;
|
||||||
|
|
||||||
const socket = new WebSocket(`ws://${location.host}`);
|
const socket = new WebSocket(`ws://${location.host}`);
|
||||||
|
window.devSocket = socket;
|
||||||
|
|
||||||
socket.addEventListener('message', ({ data: dataRaw }) => {
|
socket.addEventListener('message', ({ data: dataRaw }) => {
|
||||||
const message = JSON.parse(dataRaw.toString())
|
const message = JSON.parse(dataRaw.toString())
|
||||||
|
|
||||||
if (message.event === 'hasErrors') {
|
if (typeof message.event === 'string') {
|
||||||
|
switch (message.event) {
|
||||||
|
case 'hasErrors': {
|
||||||
openError(message.payload);
|
openError(message.payload);
|
||||||
suppressErrors = true;
|
suppressErrors = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'plugins-source-updated': {
|
||||||
|
window.postMessage({
|
||||||
|
type: 'plugins-source-updated',
|
||||||
|
data: message.payload
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user