view src/app/app.component.ts @ 17:ff964b28a272

Clear waveform before redrawing, otherwise the waveform is not drawn. also remove some debug outputs.
author Lucas Thompson <dev@lucas.im>
date Thu, 27 Oct 2016 17:47:20 +0100
parents 7e3ab6f8792f
children 953932e9ba82
line wrap: on
line source
import {Component, Inject, NgZone} from '@angular/core';
import {MailService} from "./mail.service";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'Ugly';

  count = 0;
  audioBuffer: AudioBuffer = undefined;

  constructor(
    private mail: MailService,
    @Inject('piper-server-uri') private serverUri,
    private zone: NgZone
  ) {}

  onUpdate(id, text) {
    this.mail.update(id, text);
  }

  onAudioLoaded(buffer: AudioBuffer) {
    this.zone.run(() => { // TODO why the f does this only recognise changes immediately (and not the next tick) inside zone.run?
      this.audioBuffer = buffer;
      this.count++;
    });
  }

  testRef() {
    this.count++;
  }
}