Skip to content

Commit

Permalink
Fix resource loading from URL
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Oct 28, 2024
1 parent fefc22a commit 2a3b4c3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/wasm/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { computed, ref } from 'vue';
import Emulator from "@/components/Emulator.vue";
const pickedFile = ref<ArrayBuffer | null>(null);
const isLoading = ref(false);
const isLoading = ref(0);
const autoStart = ref(true);
const initTime = ref(true);
Expand All @@ -64,6 +64,8 @@ const sampleUrl = computed(() => {
});
async function parseOptions(params: URLSearchParams) {
isLoading.value++;
if (params.has("firmware")) {
await loadFileFromURL(params.get("firmware")!);
}
Expand All @@ -81,19 +83,21 @@ async function parseOptions(params: URLSearchParams) {
if (params.has("initTime")) {
initTime.value = params.get("initTime") == "true";
}
isLoading.value--;
}
parseOptions(new URLSearchParams(location.search));
async function loadFileFromURL(url: string) {
isLoading.value = true;
isLoading.value++;
try {
const response = await fetch(url);
const programFile = await response.arrayBuffer();
pickedFile.value = programFile;
} finally {
isLoading.value = false;
isLoading.value--;
}
}
Expand Down

0 comments on commit 2a3b4c3

Please sign in to comment.