Skip to content

Commit afc4148

Browse files
committed
fix race condition that make extension to be loaded twice, use isLoadedState[id] instead of isLoading to prevent it
1 parent a57ec62 commit afc4148

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "3.0.0-a81"
2+
"version": "3.0.0-a82"
33
}

src/components/App/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
import { h } from "preact"
1919
import { webUIbuild } from "../../targets"
20-
export const webUIversion = "3.0.0-a81"
20+
export const webUIversion = "3.0.0-a82"
2121
export const Esp3dVersion = () => (
2222
<span>
2323
{webUIversion}.{webUIbuild}

src/components/ExtraContent/extraContentItem.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const ExtraContentItem = ({
8282
setContentUrl(url)
8383
setHasError(false)
8484
setIsLoading(false)
85+
isLoadedState[id] = true;
8586
}, [type])
8687

8788
const handleContentError = useCallback((error) => {
@@ -103,21 +104,24 @@ const ExtraContentItem = ({
103104
return
104105
}
105106
//console.log("Loading content for " + id)
106-
setIsLoading(true)
107107
if (source.startsWith("http")) {
108108
setContentUrl(source)
109109
setHasError(false)
110110
setIsLoading(false)
111-
isLoadedState[id] = true;
111+
isLoadedState[id] = true
112112
} else {
113+
if (isLoadedState[id]){
114+
return
115+
}
116+
setIsLoading(true)
113117
const idquery = type === "content" ? type + id : "download" + id
114118
let url = source
115119
if (url.endsWith(".gz")) {
116120
url = url.substring(0, url.length - 3)
117121
}
118122
createNewRequest(
119123
espHttpURL(url),
120-
{ method: "GET", id: idquery, max: 2 },
124+
{ method: "GET", id: idquery, max: 1 },
121125
{
122126
onSuccess: handleContentSuccess,
123127
onFail: handleContentError,
@@ -138,6 +142,7 @@ const ExtraContentItem = ({
138142
const element = document.getElementById(id)
139143
if ( 'forceRefresh' in msg && msg.forceRefresh) {
140144
//console.log(`Processing forceRefresh for ${id}`);
145+
isLoadedState[id] = false;
141146
loadContent()
142147
}
143148
if ('isVisible' in msg) {

0 commit comments

Comments
 (0)