From 0b0d0112335ce2d568977e97a0346cdbf5b5abc5 Mon Sep 17 00:00:00 2001 From: Paul Lewis Date: Mon, 18 May 2015 11:27:32 +0100 Subject: [PATCH] Fixes #1 --- package.json | 2 +- src/scripts/controller/RecordController.js | 17 +++++++++++++++++ src/scripts/libs/Dialog.js | 7 ++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c9e7218..b431ecd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Voice Memos", - "version": "0.1.22", + "version": "0.1.23", "private": true, "engines": { "node": ">=0.10.0" diff --git a/src/scripts/controller/RecordController.js b/src/scripts/controller/RecordController.js index 4db504b..522209f 100644 --- a/src/scripts/controller/RecordController.js +++ b/src/scripts/controller/RecordController.js @@ -19,6 +19,7 @@ import Controller from './Controller'; import MemoModel from '../model/MemoModel'; import PubSubInstance from '../libs/PubSub'; import RouterInstance from '../libs/Router'; +import DialogInstance from '../libs/Dialog'; export default class RecordController extends Controller { @@ -271,6 +272,22 @@ export default class RecordController extends Controller { // } }); + this.recorder.addEventListener('streamError', () => { + + DialogInstance() + .then(dialog => { + + var hideCancelButton = true; + + return dialog.show( + 'Booooo!', + 'There is a problem getting access to the microphone.', + hideCancelButton); + + }) + .catch( () => {}); + + }); } stopRecording () { diff --git a/src/scripts/libs/Dialog.js b/src/scripts/libs/Dialog.js index 7419d1d..b3a58ac 100644 --- a/src/scripts/libs/Dialog.js +++ b/src/scripts/libs/Dialog.js @@ -35,12 +35,17 @@ class Dialog { this.okayButton = this.view.querySelector('.js-okay'); } - show (title, message) { + show (title, message, hideCancel) { this.title.textContent = title; this.message.textContent = message; this.view.classList.add('dialog-view--visible'); + if (hideCancel) + this.cancelButton.classList.add('hidden'); + else + this.cancelButton.classList.remove('hidden'); + return new Promise((resolve, reject) => { var removeEventListenersAndHide = () => {