Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6: Migrate "audio" with proper logging #925

Merged
merged 13 commits into from
Mar 22, 2017
47 changes: 0 additions & 47 deletions app/script/audio/AudioError.coffee

This file was deleted.

61 changes: 61 additions & 0 deletions app/script/audio/AudioError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Wire
* Copyright (C) 2016 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

(function() {
function AudioError(type) {
this.name = this.constructor.name;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant we use es6 classes here?

this.stack = (new Error()).stack;
this.type = type || z.audio.AudioError.prototype.TYPE.UNKNOWN;
switch (this.type) {
case z.audio.AudioError.prototype.TYPE.ALREADY_PLAYING:
this.message = 'Sound is already playing';
break;
case z.audio.AudioError.prototype.TYPE.FAILED_TO_PLAY:
this.message = 'Failed to play sound';
break;
case z.audio.AudioError.prototype.TYPE.IGNORED_SOUND:
this.message = 'Ignored request to play sound';
break;
case z.audio.AudioError.prototype.TYPE.NOT_FOUND:
this.message = 'AudioElement or ID not found';
break;
default:
this.message = 'Unknown AudioError';
}
}

AudioError.prototype = new Error();

AudioError.prototype.constructor = AudioError;

AudioError.prototype.TYPE = {
ALREADY_PLAYING: 'z.audio.AudioError::TYPE.ALREADY_PLAYING',
FAILED_TO_PLAY: 'z.audio.AudioError::TYPE.FAILED_TO_PLAY',
IGNORED_SOUND: 'z.audio.AudioError::TYPE.IGNORED_SOUND',
NOT_FOUND: 'z.audio.AudioError::TYPE.NOT_FOUND',
UNKNOWN: 'z.audio.AudioError::TYPE.UNKNOWN',
};

window.z = window.z || {};
window.z.audio = z.audio || {};
window.z.audio.AudioError = AudioError;
})();

40 changes: 0 additions & 40 deletions app/script/audio/AudioPlayingType.coffee

This file was deleted.

43 changes: 43 additions & 0 deletions app/script/audio/AudioPlayingType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Wire
* Copyright (C) 2016 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.audio = z.audio || {};

z.audio.AudioPlayingType = {
NONE: [
z.audio.AudioType.CALL_DROP,
z.audio.AudioType.NETWORK_INTERRUPTION,
z.audio.AudioType.OUTGOING_CALL,
z.audio.AudioType.READY_TO_TALK,
z.audio.AudioType.TALK_LATER,
],
SOME: [
z.audio.AudioType.CALL_DROP,
z.audio.AudioType.INCOMING_CALL,
z.audio.AudioType.INCOMING_PING,
z.audio.AudioType.NETWORK_INTERRUPTION,
z.audio.AudioType.OUTGOING_CALL,
z.audio.AudioType.OUTGOING_PING,
z.audio.AudioType.READY_TO_TALK,
z.audio.AudioType.TALK_LATER,
],
};
26 changes: 0 additions & 26 deletions app/script/audio/AudioPreference.coffee

This file was deleted.

29 changes: 29 additions & 0 deletions app/script/audio/AudioPreference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Wire
* Copyright (C) 2016 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.audio = z.audio || {};

z.audio.AudioPreference = {
ALL: 'all',
NONE: 'none',
SOME: 'some',
};
Loading