in src/controller/addonController.ts [124:165]
async getVersionChoice(input: string, urlVersion?: string) {
const versions: AddonVersion[] = [];
let next: string | undefined = undefined;
let init = true;
do {
if (next || init) {
init = false;
const res = await this.getAddonVersions(input, next);
versions.push(...res.results);
next = res.next;
}
const versionItems = versions.map((version) => version.version);
next ? versionItems.push("More") : null;
// if opened from a vscode:// link, use the version from the link
const choice =
urlVersion || (await AddonView.promptVersionChoice(versionItems));
if (choice === "More") {
continue;
} else if (choice) {
const chosenVersion = versions.find(
(version) => version.version === choice
);
if (chosenVersion) {
return {
fileID: chosenVersion.file.id,
version: chosenVersion.version,
};
} else {
vscode.window.showErrorMessage("No version file found");
throw new Error("No version file found");
}
} else {
throw new Error("No version choice selected");
}
// eslint-disable-next-line no-constant-condition
} while (true);
}