Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Commit 336f0d8

Browse files
committed
fix: revert load promises
1 parent 55649c8 commit 336f0d8

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

__brick__/web/flutter_bootstrap.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
2-
{{=<% %>=}}{{flutter_js}}<%={{ }}=%>
3-
{{=<% %>=}}{{flutter_build_config}}<%={{ }}=%>
2+
{ {=<% %>=} } { { flutter_js } }<%={ { } }=%>
3+
{{=<% %>=}}{ { flutter_build_config } }<%={ { } }=%>
44

55
const progressText = document.querySelector('#progress-text');
66
const progressIndicator = document.querySelector('#progress-indicator');
@@ -59,15 +59,16 @@ async function beginPreloading() {
5959
return;
6060
}
6161

62-
const batchSize = {{batch_size}};
62+
const batchSize = {{ batch_size }
63+
};
6364

64-
progressIndicator.style.width = '0%';
65-
progressText.textContent = `Loaded ${loadedAssets} of ${totalAssets} assets`;
65+
progressIndicator.style.width = '0%';
66+
progressText.textContent = `Loaded ${loadedAssets} of ${totalAssets} assets`;
6667

67-
for (let i = 0; i < assets.length; i += batchSize) {
68-
const batch = assets.slice(i, i + batchSize);
69-
await loadBatch(batch);
70-
}
68+
for (let i = 0; i < assets.length; i += batchSize) {
69+
const batch = assets.slice(i, i + batchSize);
70+
await loadBatch(batch);
71+
}
7172
}
7273

7374
function reportProgress() {
@@ -94,18 +95,19 @@ async function load(url) {
9495
}
9596

9697
async function loadBatch(urls) {
98+
const loadPromises = urls.map(async (url) => {
99+
await load(url);
100+
reportProgress();
101+
});
97102
try {
98-
await Promise.all(urls.map(async (url) => {
99-
await load(url);
100-
reportProgress();
101-
}));
103+
return await Promise.all(loadPromises);
102104
} catch (error) {
103-
console.error('Error loading asset:', error);
105+
console.error('Error loading one or more asset:', error);
104106
}
105107
}
106108

107109
_flutter.loader.load({
108-
onEntrypointLoaded: async function(engineInitializer) {
110+
onEntrypointLoaded: async function (engineInitializer) {
109111
await Promise.all([
110112
beginPreloading(),
111113
engineInitializer.initializeEngine(),

0 commit comments

Comments
 (0)