Skip to content

Commit c113840

Browse files
committed
Choose manifest from URL param
1 parent 52b5549 commit c113840

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/app/Flash.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react'
22

33
import { FlashManager, StepCode, ErrorCode } from '../utils/manager'
44
import { useImageManager } from '../utils/image'
5+
import { getManifestUrl } from '../utils/manifest'
56
import { isLinux } from '../utils/platform'
67
import config from '../config'
78

@@ -188,8 +189,10 @@ export default function Flash() {
188189
fetch(config.loader.url)
189190
.then((res) => res.arrayBuffer())
190191
.then((programmer) => {
192+
const manifestUrl = getManifestUrl(config.manifests, 'release')
193+
191194
// Create QDL manager with callbacks that update React state
192-
qdlManager.current = new FlashManager(config.manifests.release, programmer, {
195+
qdlManager.current = new FlashManager(manifestUrl, programmer, {
193196
onStepChange: setStep,
194197
onMessageChange: setMessage,
195198
onProgressChange: setProgress,

src/utils/manifest.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,16 @@ export function getManifest(url) {
8484
.then((response) => response.text())
8585
.then((text) => JSON.parse(text).map((image) => new ManifestImage(image)))
8686
}
87+
88+
/**
89+
* @param {Record<string, string>} manifests
90+
* @param {string} defaultKey
91+
* @returns {string}
92+
*/
93+
export function getManifestUrl(manifests, defaultKey) {
94+
const params = new URLSearchParams(window.location.search)
95+
const manifest = params.get('manifest')
96+
if (!manifest) return manifests[defaultKey]
97+
if (manifests[manifest]) return manifests[manifest]
98+
return manifest
99+
}

0 commit comments

Comments
 (0)