Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed Sep 26, 2023
1 parent dfaad91 commit f278efb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions webapp/src/timeMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const TimeMachine = (props: TimeMachineProps) => {
const [entries, setEntries] = React.useState(getTimelineEntries(history));

const iframeRef = React.useRef<HTMLIFrameElement>();
const fetchingScriptLock = React.useRef(false);

const importProject = React.useRef<(text: pxt.workspace.ScriptText) => Promise<void>>();

Expand Down Expand Up @@ -163,12 +164,11 @@ export const TimeMachine = (props: TimeMachineProps) => {
}, [history]);

const onTimeSelected = async (entry: TimeEntry) => {
if (!importProject.current) return;
if (!importProject.current || fetchingScriptLock.current) return;

if (entry.timestamp === -1) {
entry = undefined;
}
const previouslySelected = selected;

setSelected(entry);

Expand All @@ -177,6 +177,8 @@ export const TimeMachine = (props: TimeMachineProps) => {
return;
}

fetchingScriptLock.current = true;

try {
const { files } = await getTextAtTimestampAsync(text, history, entry);
importProject.current(files)
Expand All @@ -186,10 +188,14 @@ export const TimeMachine = (props: TimeMachineProps) => {
warningNotification(lf("Unable to fetch shared project. Are you offline?"));
}
else {
warningNotification(lf("Unable to restore project version. Try selecting a different time."))
warningNotification(lf("Unable to restore project version. Try selecting a different version."))
}

setSelected(previouslySelected);
setSelected(undefined);
importProject.current(text);
}
finally {
fetchingScriptLock.current = false;
}
};

Expand Down

0 comments on commit f278efb

Please sign in to comment.