Skip to content

Commit

Permalink
ES6: Migrate "audio" with proper logging (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode authored Mar 22, 2017
1 parent c0ee795 commit fad99f3
Show file tree
Hide file tree
Showing 13 changed files with 434 additions and 350 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ globals:
z: true

rules:
brace-style: [2, 1tbs]
comma-dangle: [2, always-multiline]
handle-callback-err: 2
indent: [2, 2, {SwitchCase: 1}]
Expand Down
16 changes: 12 additions & 4 deletions app/script/assets/AssetService.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ z.assets.AssetService = class AssetService {
generate_asset_url(asset_id, conversation_id, force_caching) {
const url = this.client.create_url(`/assets/${asset_id}`);
let asset_url = `${url}?access_token=${this.client.access_token}&conv_id=${conversation_id}`;
if (force_caching) { asset_url = `${asset_url}&forceCaching=true`; }
if (force_caching) {
asset_url = `${asset_url}&forceCaching=true`;
}
return asset_url;
}

Expand All @@ -234,7 +236,9 @@ z.assets.AssetService = class AssetService {
generate_asset_url_v2(asset_id, conversation_id, force_caching) {
const url = this.client.create_url(`/conversations/${conversation_id}/otr/assets/${asset_id}`);
let asset_url = `${url}?access_token=${this.client.access_token}`;
if (force_caching) { asset_url = `${asset_url}&forceCaching=true`; }
if (force_caching) {
asset_url = `${asset_url}&forceCaching=true`;
}
return asset_url;
}

Expand All @@ -249,8 +253,12 @@ z.assets.AssetService = class AssetService {
generate_asset_url_v3(asset_key, asset_token, force_caching) {
const url = this.client.create_url(`/assets/v3/${asset_key}/`);
let asset_url = `${url}?access_token=${this.client.access_token}`;
if (asset_token) { asset_url = `${asset_url}&asset_token=${asset_token}`; }
if (force_caching) { asset_url = `${asset_url}&forceCaching=true`; }
if (asset_token) {
asset_url = `${asset_url}&asset_token=${asset_token}`;
}
if (force_caching) {
asset_url = `${asset_url}&forceCaching=true`;
}
return asset_url;
}

Expand Down
47 changes: 0 additions & 47 deletions app/script/audio/AudioError.coffee

This file was deleted.

60 changes: 60 additions & 0 deletions app/script/audio/AudioError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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 || {};

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

static get TYPE() {
return {
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',
};
}
};


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

0 comments on commit fad99f3

Please sign in to comment.