state.contextItems
This commit is contained in:
parent
00aaba6479
commit
e595235584
2 changed files with 19 additions and 22 deletions
|
|
@ -5,19 +5,15 @@ import CodeSnippetPreview from "../markdown/CodeSnippetPreview";
|
|||
import { useSelector } from "react-redux";
|
||||
import { RootState } from "../../redux/store";
|
||||
|
||||
export const CodeBlockComponent = ({
|
||||
node,
|
||||
deleteNode,
|
||||
selected,
|
||||
editor,
|
||||
updateAttributes,
|
||||
}: any) => {
|
||||
export const CodeBlockComponent = (props: any) => {
|
||||
const { node, deleteNode, selected, editor, updateAttributes } = props;
|
||||
const item: ContextItemWithId = node.attrs.item;
|
||||
const contextItems = useSelector(
|
||||
(store: RootState) =>
|
||||
store.state.history[store.state.history.length - 1].contextItems,
|
||||
);
|
||||
const isFirstContextItem = item.id === contextItems[0].id;
|
||||
const isFirstContextItem = item.id === contextItems[0]?.id;
|
||||
// const isFirstContextItem = false;
|
||||
|
||||
return (
|
||||
<NodeViewWrapper className="code-block-with-content" as="p">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Dispatch } from "@reduxjs/toolkit";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import { VSC_THEME_COLOR_VARS } from "../components";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
|
|
@ -14,7 +14,7 @@ import {
|
|||
} from "../redux/slices/stateSlice";
|
||||
import { RootState } from "../redux/store";
|
||||
|
||||
import { debounce } from "lodash";
|
||||
import { debounce, initial } from "lodash";
|
||||
import { isJetBrains } from "../util";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import useChatHandler from "./useChatHandler";
|
||||
|
|
@ -25,7 +25,8 @@ function useSetup(dispatch: Dispatch<any>) {
|
|||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const loadConfig = async () => {
|
||||
const initialConfigLoad = useRef(false);
|
||||
const loadConfig = useCallback(async () => {
|
||||
const result = await ideMessenger.request(
|
||||
"config/getSerializedProfileInfo",
|
||||
undefined,
|
||||
|
|
@ -36,7 +37,7 @@ function useSetup(dispatch: Dispatch<any>) {
|
|||
const { config, profileId } = result.content;
|
||||
dispatch(setConfig(config));
|
||||
dispatch(setSelectedProfileId(profileId));
|
||||
// setConfigLoaded(true);
|
||||
initialConfigLoad.current = true;
|
||||
setLocalStorage("disableIndexing", config.disableIndexing || false);
|
||||
|
||||
// Perform any actions needed with the config
|
||||
|
|
@ -44,21 +45,21 @@ function useSetup(dispatch: Dispatch<any>) {
|
|||
setLocalStorage("fontSize", config.ui.fontSize);
|
||||
document.body.style.fontSize = `${config.ui.fontSize}px`;
|
||||
}
|
||||
};
|
||||
}, [dispatch, ideMessenger, initialConfigLoad]);
|
||||
|
||||
// Load config from the IDE
|
||||
useEffect(() => {
|
||||
loadConfig();
|
||||
// const interval = setInterval(() => {
|
||||
// if (configLoaded) {
|
||||
// clearInterval(interval);
|
||||
// return;
|
||||
// }
|
||||
// loadConfig();
|
||||
// }, 2_000);
|
||||
const interval = setInterval(() => {
|
||||
if (initialConfigLoad.current) {
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
loadConfig();
|
||||
}, 2_000);
|
||||
|
||||
// return () => clearInterval(interval);
|
||||
}, []);
|
||||
return () => clearInterval(interval);
|
||||
}, [initialConfigLoad]);
|
||||
|
||||
useEffect(() => {
|
||||
// Override persisted state
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue