Skip to content

Commit

Permalink
chore: cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Mar 14, 2024
1 parent 1191c1d commit 46b986f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/other/jupyterlite/JupyterLiteSession.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {JupyterliteMessageSchema} from "@mat3ra/esse/lib/js/types";
import { JupyterliteMessageSchema } from "@mat3ra/esse/lib/js/types";
import React from "react";

interface JupyterLiteSessionProps {
Expand Down Expand Up @@ -33,29 +33,29 @@ class JupyterLiteSession extends React.Component<JupyterLiteSessionProps> {
if (event.origin !== new URL(this.props.originURL).origin) return;
const message = event.data;

const handlerConfig = this.props.handlers.find(handler => {
return handler.type === message.type &&
handler.filter.keys.every(key => message.payload.hasOwnProperty(key));
const handlerConfig = this.props.handlers.find((handler) => {
return (
handler.type === message.type &&
handler.filter.keys.every((key) => message.payload.hasOwnProperty(key))
);
});

if (handlerConfig) {
const {handler, filter, extraParameters} = handlerConfig;
const { handler, filter, extraParameters } = handlerConfig;
handler(message.payload);
// TODO: make more generic
const requestData = message.payload.requestData;
const variableName = message.payload.variableName;
const { requestData, variableName } = message.payload;
if (requestData && variableName) {
const data = handler(variableName)();
this.sendMessage(data, variableName);
}
}
};


sendMessage = (data: any, variableName: string) => {
const message: JupyterliteMessageSchema = {
type: "from-host-to-iframe",
payload: {data, variableName},
payload: { data, variableName },
};
const iframe = document.getElementById(this.props.frameId) as HTMLIFrameElement | null;
if (iframe && iframe.contentWindow) {
Expand All @@ -66,7 +66,7 @@ class JupyterLiteSession extends React.Component<JupyterLiteSessionProps> {
};

render() {
const {defaultNotebookPath, originURL, frameId} = this.props;
const { defaultNotebookPath, originURL, frameId } = this.props;
const src = defaultNotebookPath
? `${originURL}/lab/tree?path=${defaultNotebookPath}`
: `${originURL}/lab`;
Expand Down

0 comments on commit 46b986f

Please sign in to comment.