From 0bdc85a4a772f0be9630fcfce7dd0bf46a8ac120 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 10 Jan 2018 10:40:20 +0100 Subject: [PATCH] MOBILE-2253 core: Remove PWA files since they aren't used --- src/app/app.component.ts | 2 + src/core/emulator/classes/sqlitedb.ts | 2 +- src/core/emulator/providers/file.ts | 79 +++++++++++++++++++-------- src/core/login/providers/helper.ts | 2 +- src/manifest.json | 13 ----- src/service-worker.js | 31 ----------- 6 files changed, 59 insertions(+), 70 deletions(-) delete mode 100644 src/manifest.json delete mode 100644 src/service-worker.js diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c70564c1d..ebc4e3bc8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -25,6 +25,8 @@ import { CoreLoginHelperProvider } from '../core/login/providers/helper'; }) export class MyApp implements AfterViewInit { @ViewChild(Nav) navCtrl; + // Use the page name (string) because the page is lazy loaded (Ionic feature). That way we can load pages without + // having to import them. The downside is that each page needs to implement a ngModule. rootPage:any = 'CoreLoginInitPage'; protected logger; protected lastUrls = {}; diff --git a/src/core/emulator/classes/sqlitedb.ts b/src/core/emulator/classes/sqlitedb.ts index 9bc2931e7..7b7b91baa 100644 --- a/src/core/emulator/classes/sqlitedb.ts +++ b/src/core/emulator/classes/sqlitedb.ts @@ -46,7 +46,7 @@ export class SQLiteDBMock extends SQLiteDB { */ emptyDatabase() : Promise { return new Promise((resolve, reject) => { - this.db.transaction(tx => { + this.db.transaction((tx) => { // Query all tables from sqlite_master that we have created and can modify. let args = [], query = `SELECT * FROM sqlite_master diff --git a/src/core/emulator/providers/file.ts b/src/core/emulator/providers/file.ts index 729b1fae5..4eef27146 100644 --- a/src/core/emulator/providers/file.ts +++ b/src/core/emulator/providers/file.ts @@ -63,11 +63,16 @@ export class FileMock extends File { } /** - * @hidden + * Copy a file or directory. + * + * @param {Entry} srce The Entry to copy. + * @param {DirectoryEntry} destDir The directory where to put the copy. + * @param {string} newName New name of the file/dir. + * @returns {Promise} Returns a Promise that resolves to the new Entry object or rejects with an error. */ - private copyMock(srce: Entry, destdir: DirectoryEntry, newName: string): Promise { + private copyMock(srce: Entry, destDir: DirectoryEntry, newName: string): Promise { return new Promise((resolve, reject) => { - srce.copyTo(destdir, newName, (deste) => { + srce.copyTo(destDir, newName, (deste) => { resolve(deste); }, (err) => { this.fillErrorMessageMock(err); @@ -165,7 +170,10 @@ export class FileMock extends File { } /** - * @hidden + * Create a file writer for a certain file. + * + * @param {FileEntry} fe File entry object. + * @returns {Promise} Promise resolved with the FileWriter. */ private createWriterMock(fe: FileEntry): Promise { return new Promise((resolve, reject) => { @@ -179,7 +187,9 @@ export class FileMock extends File { } /** - * @hidden + * Fill the message for an error. + * + * @param {any} err Error. */ private fillErrorMessageMock(err: any): void { try { @@ -350,11 +360,16 @@ export class FileMock extends File { } /** - * @hidden + * Move a file or directory. + * + * @param {Entry} srce The Entry to copy. + * @param {DirectoryEntry} destDir The directory where to move the file/dir. + * @param {string} newName New name of the file/dir. + * @returns {Promise} Returns a Promise that resolves to the new Entry object or rejects with an error. */ - private moveMock(srce: Entry, destdir: DirectoryEntry, newName: string): Promise { + private moveMock(srce: Entry, destDir: DirectoryEntry, newName: string): Promise { return new Promise((resolve, reject) => { - srce.moveTo(destdir, newName, (deste) => { + srce.moveTo(destDir, newName, (deste) => { resolve(deste); }, (err) => { this.fillErrorMessageMock(err); @@ -448,7 +463,10 @@ export class FileMock extends File { } /** - * @hidden + * Read all the files and directories inside a directory. + * + * @param {DirectoryReader} dr The directory reader. + * @return {Promise} Promise resolved with the list of files/dirs. */ private readEntriesMock(dr: DirectoryReader): Promise { return new Promise((resolve, reject) => { @@ -485,7 +503,7 @@ export class FileMock extends File { } }; - fileEntry.file(file => { + fileEntry.file((file) => { reader[`readAs${readAs}`].call(reader, file); }, error => { reject(error); @@ -495,7 +513,10 @@ export class FileMock extends File { } /** - * @hidden + * Delete a file. + * + * @param {Entry} fe The file to remove. + * @return {Promise} Promise resolved when done. */ private removeMock(fe: Entry): Promise { return new Promise((resolve, reject) => { @@ -592,7 +613,10 @@ export class FileMock extends File { } /** - * @hidden + * Remove a directory and all its contents. + * + * @param {DirectoryEntry} de Directory to remove. + * @return {Promise} Promise resolved when done. */ private rimrafMock(de: DirectoryEntry): Promise { return new Promise((resolve, reject) => { @@ -606,11 +630,15 @@ export class FileMock extends File { } /** - * @hidden + * Write some data in a file. + * + * @param {FileWriter} writer File writer. + * @param {any} data The data to write. + * @return {Promise} Promise resolved when done. */ - private writeMock(writer: FileWriter, gu: any): Promise { - if (gu instanceof Blob) { - return this.writeFileInChunksMock(writer, gu); + private writeMock(writer: FileWriter, data: any): Promise { + if (data instanceof Blob) { + return this.writeFileInChunksMock(writer, data); } return new Promise((resolve, reject) => { @@ -621,7 +649,7 @@ export class FileMock extends File { resolve(evt); } }; - writer.write(gu); + writer.write(data); }); } @@ -661,7 +689,6 @@ export class FileMock extends File { /** * Write content to FileEntry. * - * @hidden * @param {FileEntry} fe File entry object. * @param {string | Blob} text Content or blob to write. * @param {IWriteOptions} options replace file if set to true. See WriteOptions for more information. @@ -682,15 +709,19 @@ export class FileMock extends File { } /** - * @hidden - */ - private writeFileInChunksMock(writer: FileWriter, file: Blob) { + * Write a file in chunks. + * + * @param {FileWriter} writer File writer. + * @param {Blob} data Data to write. + * @return {Promise} Promise resolved when done. + */ + private writeFileInChunksMock(writer: FileWriter, data: Blob) : Promise { const BLOCK_SIZE = 1024 * 1024; let writtenSize = 0; function writeNextChunk() { - const size = Math.min(BLOCK_SIZE, file.size - writtenSize); - const chunk = file.slice(writtenSize, writtenSize + size); + const size = Math.min(BLOCK_SIZE, data.size - writtenSize); + const chunk = data.slice(writtenSize, writtenSize + size); writtenSize += size; writer.write(chunk); @@ -699,7 +730,7 @@ export class FileMock extends File { return new Promise((resolve, reject) => { writer.onerror = reject; writer.onwrite = () => { - if (writtenSize < file.size) { + if (writtenSize < data.size) { writeNextChunk(); } else { resolve(); diff --git a/src/core/login/providers/helper.ts b/src/core/login/providers/helper.ts index 100aebaef..2a61eaa71 100644 --- a/src/core/login/providers/helper.ts +++ b/src/core/login/providers/helper.ts @@ -39,7 +39,7 @@ export interface CoreLoginSSOData { }; /** - * Emulates the Cordova Zip plugin in desktop apps and in browser. + * Helper provider that provides some common features regarding authentication. */ @Injectable() export class CoreLoginHelperProvider { diff --git a/src/manifest.json b/src/manifest.json deleted file mode 100644 index 0f3ec999e..000000000 --- a/src/manifest.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "Moodle Mobile", - "short_name": "Moodle Mobile", - "start_url": "index.html", - "display": "standalone", - "icons": [{ - "src": "assets/imgs/logo.png", - "sizes": "512x512", - "type": "image/png" - }], - "background_color": "#4e8ef7", - "theme_color": "#4e8ef7" -} \ No newline at end of file diff --git a/src/service-worker.js b/src/service-worker.js deleted file mode 100644 index ffbbb068f..000000000 --- a/src/service-worker.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Check out https://googlechromelabs.github.io/sw-toolbox/ for - * more info on how to use sw-toolbox to custom configure your service worker. - */ - - -'use strict'; -importScripts('./build/sw-toolbox.js'); - -self.toolbox.options.cache = { - name: 'ionic-cache' -}; - -// pre-cache our key assets -self.toolbox.precache( - [ - './build/main.js', - './build/vendor.js', - './build/main.css', - './build/polyfills.js', - 'index.html', - 'manifest.json' - ] -); - -// dynamically cache any other local assets -self.toolbox.router.any('/*', self.toolbox.fastest); - -// for any other requests go to the network, cache, -// and then only use that cached resource if your user goes offline -self.toolbox.router.default = self.toolbox.networkFirst;