diff --git a/desktop-app/src/app/files/files.component.html b/desktop-app/src/app/files/files.component.html index 5e7a99e..00b1a25 100644 --- a/desktop-app/src/app/files/files.component.html +++ b/desktop-app/src/app/files/files.component.html @@ -26,7 +26,7 @@ + mTooltip [attr.data-tooltip]="favourite.name">
@@ -55,32 +55,34 @@

+
- + add - + +
diff --git a/desktop-app/src/app/files/files.component.ts b/desktop-app/src/app/files/files.component.ts index 2004ed5..b712c16 100644 --- a/desktop-app/src/app/files/files.component.ts +++ b/desktop-app/src/app/files/files.component.ts @@ -1,4 +1,12 @@ -import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { + afterNextRender, + AfterRenderPhase, + AfterViewInit, + Component, + OnDestroy, + OnInit, + ViewChild, +} from '@angular/core'; import { AdbClientService, ConnectionStatus } from '../adb-client.service'; import { AppService } from '../app.service'; import { LoadingSpinnerService } from '../loading-spinner.service'; @@ -21,7 +29,7 @@ declare let M; templateUrl: './files.component.html', styleUrls: ['./files.component.scss'], }) -export class FilesComponent implements OnInit { +export class FilesComponent implements OnInit, AfterViewInit { @ViewChild('filesModal') filesModal; @ViewChild('fixedAction') fixedAction; @ViewChild('downloadMediaModal') downloadMediaModal; @@ -49,9 +57,20 @@ export class FilesComponent implements OnInit { // appService.isFilesOpen = true; appService.webService.isWebviewOpen = false; } - ngOnAfterViewInit() { - M.FloatingActionButton.init(this.fixedAction.nativeElement, {}); + + ngAfterViewInit() { + this.setupActionButton(); } + + private setupActionButton() { + // We have to wait until it is actually ready, this component isn't ready even afterViewInit, so we have to loop wait + if (this.fixedAction == null) { + setTimeout(() => this.setupActionButton(), 100); + return; + } + M.FloatingActionButton.init(this.fixedAction.nativeElement, {}); + } + ngOnInit() { this.appService.setTitle('Headset Files'); } @@ -411,4 +430,5 @@ export class FilesComponent implements OnInit { }); return dirContents; } + } diff --git a/desktop-app/src/app/packages/package.service.ts b/desktop-app/src/app/packages/package.service.ts index 85255ca..db6048d 100644 --- a/desktop-app/src/app/packages/package.service.ts +++ b/desktop-app/src/app/packages/package.service.ts @@ -13,11 +13,10 @@ export class PackageService { } async getAppIndex() { const request = await fetch(this.indexUrl, { - method: 'GET', - headers: { "Content-Type": "application/json" } + method: 'GET' }); - let json = await request.json(); + let blob = await request.blob(); const request2 = await fetch(this.indexUrl + 'app-index.json', { method: 'GET', headers: { "Content-Type": "application/json" } diff --git a/electron/app.ts b/electron/app.ts index 98d8252..1035cc4 100644 --- a/electron/app.ts +++ b/electron/app.ts @@ -457,24 +457,28 @@ class ADB { if (!this.client) return ecb('Not connected.'); const device = this.client.getDevice(serial); + // TODO: See if we can pipe this thru a stream to get progress device .push(fs.createReadStream(path), savePath) .then(transfer => { - let _stats, autoCancel; + let _stats = {bytesTransferred: 0}, counter=0; + let lastNumber = 0; const interval = setInterval(() => { - scb(_stats); + // We are cheating here, frequently the progress event will just stop firing but still will be transferring + // We are faking it at a slower pace so that the user still sees something is happening + if (lastNumber === _stats.bytesTransferred) { + counter += 1024; + scb({bytesTransferred: _stats.bytesTransferred + counter * 10240}) + } else { + counter = 0; + scb(_stats); + lastNumber = _stats.bytesTransferred; + } }, 1000); transfer.on('progress', stats => { - // clearTimeout(autoCancel); - console.log("Progress", stats, Date.now()); _stats = stats; - /* autoCancel = setTimeout(() => { - clearInterval(interval); - cb(); - }, 90000); */ }); transfer.on('end', () => { - // clearTimeout(autoCancel); clearInterval(interval); cb(); });