Commit 20b5f062 authored by tom's avatar tom

don't load model if it has already been loaded

parent 85e973c3
...@@ -43,9 +43,12 @@ const CodeEditor = ({ data }: Props) => { ...@@ -43,9 +43,12 @@ const CodeEditor = ({ data }: Props) => {
monaco.editor.defineTheme('blockscout-dark', themes.dark); monaco.editor.defineTheme('blockscout-dark', themes.dark);
monaco.editor.setTheme(colorMode === 'light' ? 'blockscout-light' : 'blockscout-dark'); monaco.editor.setTheme(colorMode === 'light' ? 'blockscout-light' : 'blockscout-dark');
data.slice(1).forEach((file) => { const loadedModelsPaths = monaco.editor.getModels().map((model) => model.uri.path);
monaco.editor.createModel(file.source_code, 'sol', monaco.Uri.parse(file.file_path)); data.slice(1)
}); .filter((file) => !loadedModelsPaths.includes(file.file_path))
.forEach((file) => {
monaco.editor.createModel(file.source_code, 'sol', monaco.Uri.parse(file.file_path));
});
// componentDidMount // componentDidMount
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [ ]); }, [ ]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment