Skip to content

Commit

Permalink
fix race condition that make extension to be loaded twice, use isLoad…
Browse files Browse the repository at this point in the history
…edState[id] instead of isLoading to prevent it
  • Loading branch information
luc-github committed Dec 5, 2024
1 parent a57ec62 commit afc4148
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "3.0.0-a81"
"version": "3.0.0-a82"
}
2 changes: 1 addition & 1 deletion src/components/App/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
import { h } from "preact"
import { webUIbuild } from "../../targets"
export const webUIversion = "3.0.0-a81"
export const webUIversion = "3.0.0-a82"
export const Esp3dVersion = () => (
<span>
{webUIversion}.{webUIbuild}
Expand Down
11 changes: 8 additions & 3 deletions src/components/ExtraContent/extraContentItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const ExtraContentItem = ({
setContentUrl(url)
setHasError(false)
setIsLoading(false)
isLoadedState[id] = true;
}, [type])

const handleContentError = useCallback((error) => {
Expand All @@ -103,21 +104,24 @@ const ExtraContentItem = ({
return
}
//console.log("Loading content for " + id)
setIsLoading(true)
if (source.startsWith("http")) {
setContentUrl(source)
setHasError(false)
setIsLoading(false)
isLoadedState[id] = true;
isLoadedState[id] = true
} else {
if (isLoadedState[id]){
return
}
setIsLoading(true)
const idquery = type === "content" ? type + id : "download" + id
let url = source
if (url.endsWith(".gz")) {
url = url.substring(0, url.length - 3)
}
createNewRequest(
espHttpURL(url),
{ method: "GET", id: idquery, max: 2 },
{ method: "GET", id: idquery, max: 1 },
{
onSuccess: handleContentSuccess,
onFail: handleContentError,
Expand All @@ -138,6 +142,7 @@ const ExtraContentItem = ({
const element = document.getElementById(id)
if ( 'forceRefresh' in msg && msg.forceRefresh) {
//console.log(`Processing forceRefresh for ${id}`);
isLoadedState[id] = false;
loadContent()
}
if ('isVisible' in msg) {
Expand Down

0 comments on commit afc4148

Please sign in to comment.