Skip to content

Commit

Permalink
Fix initial state bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrawal-d committed Jun 16, 2024
1 parent 0b7e447 commit d82c7ac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/webview/frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useReducer } from 'react';
import React, { useState, useEffect } from 'react';
import { createRoot } from 'react-dom/client';
import {
Problem,
Expand Down Expand Up @@ -40,10 +40,12 @@ function Judge(props: {
const [webviewState, setWebviewState] = useState<WebViewpersistenceState>(
() => {
const vscodeState = vscodeApi.getState();
console.log('Restored state:', vscodeState);
return {
const ret = {
dialogCloseDate: vscodeState?.dialogCloseDate || Date.now(),
};
vscodeApi.setState(ret);
console.log('Restored to state:', ret);
return ret;
},
);

Expand Down Expand Up @@ -595,7 +597,6 @@ function App() {
const [deferSaveTimer, setDeferSaveTimer] = useState<number | null>(null);
const [, setSaving] = useState<boolean>(false);
const [showFallback, setShowFallback] = useState<boolean>(false);
const [, forceUpdate] = useReducer((x) => x + 1, 0);

// Save the problem
const save = () => {
Expand Down

0 comments on commit d82c7ac

Please sign in to comment.