Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca91272f authored by Raj Khemani's avatar Raj Khemani
Browse files

feat(download): only allow local ZIP on specific URL

parent ea518ec4
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ export class Controller {
      new Step("device-detection", "connect adb", true),
    ];
    this.currentIndex = 0;
    this.downloadChoiceEnabled = false;
  }

  async init(view) {
@@ -26,6 +27,10 @@ export class Controller {
    this.view = view;
  }

  setDownloadChoiceEnabled(enabled) {
    this.downloadChoiceEnabled = enabled;
  }

  async next() {
    let current = this.steps[this.currentIndex];
    let next = this.steps[this.currentIndex + 1];
@@ -413,7 +418,8 @@ export class Controller {
  setResources(resources) {
    this.resources = resources;
    if (this.resources.steps) {
      this.steps.push(new Step("downloading", "download", true));
      const needsUserGesture = this.downloadChoiceEnabled;
      this.steps.push(new Step("downloading", "download", needsUserGesture));
      this.steps.push(
        ...this.resources.steps.map((step) => {
          return new Step(
+21 −1
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ export default class ViewManager {
    this.WDebug = WDebug;
    this.ErrorManager = ErrorManager;
    this.controller = new Controller();
    this.downloadChoiceEnabled =
      new URLSearchParams(window.location.search).get("download") === "0";
    this.controller.setDownloadChoiceEnabled(this.downloadChoiceEnabled);
    await this.controller.init(this);
    this.translationManager = new TranslationManager();
    await this.translationManager.init();
@@ -32,8 +35,25 @@ export default class ViewManager {
      $copyStep.id = step.id;
      $copyStep.classList.add("active");
      $copyStep.classList.remove("inactive");
      $copyStep.style.position = "relative";
      if (step.name === "downloading") {
        const progressArea = $copyStep.querySelector(
          ".download-progress-area",
        );
        const actions = $copyStep.querySelector(".download-actions");
        if (this.downloadChoiceEnabled) {
          if (progressArea) {
            progressArea.style.display = "none";
          }
          this.bindDownloadChoice($copyStep, step);
        } else {
          if (actions) {
            actions.style.display = "none";
          }
          if (progressArea) {
            progressArea.style.display = "block";
          }
        }
      } else {
        const $button = $copyStep.querySelector("button");
        if ($button) {