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

Unverified Commit 43e29c9d authored by Danny Lin's avatar Danny Lin
Browse files

Merge branch 'migrate-to-typescript'

This migrates the entire library to strict TypeScript, mostly using the
default TypeScript settings generated by `tsc --init`.

Several mistakes were caught and fixed in the migration. In particular,
aditional checks were added for undefined and null to improve
robustness.

Suggested-by: Arden Sinclair <general@ardensinclair.com> (#1)
parents 334e0895 e7ef5dce
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
import * as common from "../lib/common.js";

const DB_NAME = "BlobStore";
const DB_VERSION = 1;

@@ -65,20 +63,20 @@ export class BlobStore {
     * Downloads the file from the given URL and saves it to this BlobStore.
     *
     * @param {string} url - URL of the file to download.
     * @returns {blob} Blob containing the downloaded data.
     * @returns {Promise<Blob>} Blob containing the downloaded data.
     */
    async download(url) {
        let filename = url.split("/").pop();
        let blob = await this.loadFile(filename);
        if (blob === null) {
            common.logDebug(`Downloading ${url}`);
            console.log(`Downloading ${url}`);
            let resp = await fetch(new Request(url));
            blob = await resp.blob();
            common.logDebug("File downloaded, saving...");
            console.log("File downloaded, saving...");
            await this.saveFile(filename, blob);
            common.logDebug("File saved");
            console.log("File saved");
        } else {
            common.logDebug(
            console.log(
                `Loaded ${filename} from blob store, skipping download`
            );
        }
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import * as fastboot from "../dist/fastboot.mjs";
import { BlobStore } from "./download.js";

let device = new fastboot.FastbootDevice();
window.device = device;
let blobStore = new BlobStore();

// Enable verbose debug logging
+6250 −1268

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading