Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPLT-1019] feat: store debug list in LocalStorage #90

Merged
merged 2 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion frontend/src/components/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ const Editor = ({
onLoadErrorText,
actionButtonText,
}) => {
const DEBUG_LIST_STORAGE_KEY = useMemo(() => `QueryAPI:debugList:${accountId}#${indexerName}`, [accountId, indexerName])
roshaans marked this conversation as resolved.
Show resolved Hide resolved
const [error, setError] = useState(undefined);
const [blockHeightError, setBlockHeightError] = useState(undefined);
const [showResetCodeModel, setShowResetCodeModel] = useState(false);
const [fileName, setFileName] = useState("indexingLogic.js");
const [originalSQLCode, setOriginalSQLCode] = useState(defaultSchema);
const [originalIndexingCode, setOriginalIndexingCode] = useState(defaultCode);
const [debugMode, setDebugMode] = useState(false);
const [heights, setHeights] = useState([]);
const [heights, setHeights] = useState(localStorage.getItem(DEBUG_LIST_STORAGE_KEY) || []);
const [showPublishModal, setShowPublishModal] = useState(false);
const [debugModeInfoDisabled, setDebugModeInfoDisabled] = useState(false);
const handleLog = (blockHeight, log, callback) => {
Expand Down Expand Up @@ -78,6 +79,10 @@ const Editor = ({
}
}, [selectedTab]);

useEffect(() => {
localStorage.setItem(`QueryAPI:debugList:${accountId}#${indexerName}`, heights);
roshaans marked this conversation as resolved.
Show resolved Hide resolved
}, [heights]);

useEffect(() => {
if (selectedOption == "latestBlockHeight") {
setBlockHeightError(null);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ overrideLocalStorage();

export default function App({ Component, pageProps }: AppProps) {
return (
<NearSocialBridgeProvider fallback={<Spinner />}>
<NearSocialBridgeProvider waitForStorage fallback={<Spinner />}>
<Component {...pageProps} />
</NearSocialBridgeProvider>
);
Expand Down