Handed control of notification sounds over to browser for firefox
Этот коммит содержится в:
@@ -13,6 +13,7 @@ var assign = require('object-assign');
|
|||||||
|
|
||||||
function getNotificationsStateFromStores() {
|
function getNotificationsStateFromStores() {
|
||||||
var user = UserStore.getCurrentUser();
|
var user = UserStore.getCurrentUser();
|
||||||
|
var soundNeeded = (!navigator || navigator.userAgent.toLowerCase().indexOf("firefox") === -1);
|
||||||
var sound = (!user.notify_props || user.notify_props.desktop_sound == undefined) ? "true" : user.notify_props.desktop_sound;
|
var sound = (!user.notify_props || user.notify_props.desktop_sound == undefined) ? "true" : user.notify_props.desktop_sound;
|
||||||
var desktop = (!user.notify_props || user.notify_props.desktop == undefined) ? "all" : user.notify_props.desktop;
|
var desktop = (!user.notify_props || user.notify_props.desktop == undefined) ? "all" : user.notify_props.desktop;
|
||||||
var email = (!user.notify_props || user.notify_props.email == undefined) ? "true" : user.notify_props.email;
|
var email = (!user.notify_props || user.notify_props.email == undefined) ? "true" : user.notify_props.email;
|
||||||
@@ -58,7 +59,7 @@ function getNotificationsStateFromStores() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { notify_level: desktop, enable_email: email, enable_sound: sound, username_key: username_key, mention_key: mention_key, custom_keys: custom_keys, custom_keys_checked: custom_keys.length > 0, first_name_key: first_name_key, all_key: all_key, channel_key: channel_key };
|
return { notify_level: desktop, enable_email: email, soundNeeded: soundNeeded, enable_sound: sound, username_key: username_key, mention_key: mention_key, custom_keys: custom_keys, custom_keys_checked: custom_keys.length > 0, first_name_key: first_name_key, all_key: all_key, channel_key: channel_key };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -236,23 +237,35 @@ var NotificationsTab = React.createClass({
|
|||||||
|
|
||||||
var soundSection;
|
var soundSection;
|
||||||
if (this.props.activeSection === 'sound') {
|
if (this.props.activeSection === 'sound') {
|
||||||
var soundActive = ["",""];
|
|
||||||
if (this.state.enable_sound === "false") {
|
|
||||||
soundActive[1] = "active";
|
|
||||||
} else {
|
|
||||||
soundActive[0] = "active";
|
|
||||||
}
|
|
||||||
|
|
||||||
var inputs = [];
|
var inputs = [];
|
||||||
|
|
||||||
inputs.push(
|
if(this.state.soundNeeded) {
|
||||||
<div>
|
var soundActive = ["",""];
|
||||||
<div className="btn-group" data-toggle="buttons-radio">
|
if (this.state.enable_sound === "false") {
|
||||||
<button className={"btn btn-default "+soundActive[0]} onClick={function(){self.handleSoundRadio("true")}}>On</button>
|
soundActive[1] = "active";
|
||||||
<button className={"btn btn-default "+soundActive[1]} onClick={function(){self.handleSoundRadio("false")}}>Off</button>
|
} else {
|
||||||
|
soundActive[0] = "active";
|
||||||
|
}
|
||||||
|
|
||||||
|
inputs.push(
|
||||||
|
<div>
|
||||||
|
<div className="btn-group" data-toggle="buttons-radio">
|
||||||
|
<button className={"btn btn-default "+soundActive[0]} onClick={function(){self.handleSoundRadio("true")}}>On</button>
|
||||||
|
<button className={"btn btn-default "+soundActive[1]} onClick={function(){self.handleSoundRadio("false")}}>Off</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
} else {
|
||||||
|
inputs.push(
|
||||||
|
<div>
|
||||||
|
<div className='btn-group' data-toggle='buttons-radio'>
|
||||||
|
<button className='btn btn-default' disabled>On</button>
|
||||||
|
<button className='btn btn-default' disabled>Off</button>
|
||||||
|
</div>
|
||||||
|
<div><br/>Please disable notification sounds in your browser settings</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
soundSection = (
|
soundSection = (
|
||||||
<SettingItemMax
|
<SettingItemMax
|
||||||
@@ -265,7 +278,9 @@ var NotificationsTab = React.createClass({
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
var describe = "";
|
var describe = "";
|
||||||
if (this.state.enable_sound === "false") {
|
if (!this.state.soundNeeded) {
|
||||||
|
describe = "See Inside"
|
||||||
|
} else if (this.state.enable_sound === "false") {
|
||||||
describe = "Off";
|
describe = "Off";
|
||||||
} else {
|
} else {
|
||||||
describe = "On";
|
describe = "On";
|
||||||
|
|||||||
@@ -124,8 +124,10 @@ module.exports.notifyMe = function(title, body, channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports.ding = function() {
|
module.exports.ding = function() {
|
||||||
var audio = new Audio('/static/images/ding.mp3');
|
if (!navigator || navigator.userAgent.toLowerCase().indexOf("firefox") === -1) {
|
||||||
audio.play();
|
var audio = new Audio('/static/images/ding.mp3');
|
||||||
|
audio.play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getUrlParameter = function(sParam) {
|
module.exports.getUrlParameter = function(sParam) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user