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:
Andrey Goncharov
2022-09-15 10:02:19 -07:00
committed by Facebook GitHub Bot
parent c69d102ca1
commit d3d2e189d0
2 changed files with 25 additions and 5 deletions

View File

@@ -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;
@@ -105,4 +112,4 @@
</script> </script>
</body> </body>
</html> </html>

View File

@@ -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') {
openError(message.payload); switch (message.event) {
suppressErrors = true; 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> </script>
</body> </body>
</html> </html>