Update NotificationSounds.plugin.js

This commit is contained in:
Mirco Wittrien 2019-03-04 17:10:59 +01:00
parent 584c3029a4
commit 3984d23f8d
1 changed files with 16 additions and 2 deletions

View File

@ -16,9 +16,11 @@ class NotificationSounds {
this.patchModules = { this.patchModules = {
"IncomingCalls":"componentDidMount", "IncomingCalls":"componentDidMount",
"PrivateChannelCall":"componentDidMount" "PrivateChannelCall":"componentDidMount",
"StandardSidebarView":"componentWillUnmount"
}; };
/* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SONGS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */
this.types = { this.types = {
"message1": {implemented:true, name:"New Chatmessage", src:"/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute:true, focus:null}, "message1": {implemented:true, name:"New Chatmessage", src:"/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute:true, focus:null},
"dm": {implemented:true, name:"Direct Message", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute:true, focus:true}, "dm": {implemented:true, name:"Direct Message", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute:true, focus:true},
@ -51,6 +53,7 @@ class NotificationSounds {
"robot_man": {implemented:false, name:"Robot Man Voice", src:"/assets/66598bea6e59eb8acdf32cf2d9d75ba9.mp3", mute:true, focus:null} "robot_man": {implemented:false, name:"Robot Man Voice", src:"/assets/66598bea6e59eb8acdf32cf2d9d75ba9.mp3", mute:true, focus:null}
}; };
/* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SONGS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */
this.defaults = { this.defaults = {
"---": { "---": {
"---": null "---": null
@ -251,6 +254,7 @@ class NotificationSounds {
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this); BDFDB.unloadMessage(this);
this.settingsaudio.pause();
} }
} }
@ -422,7 +426,10 @@ class NotificationSounds {
saveChoice (type, play) { saveChoice (type, play) {
if (!this.choices[type]) return; if (!this.choices[type]) return;
BDFDB.saveData(type, this.choices[type], this, "choices"); BDFDB.saveData(type, this.choices[type], this, "choices");
if (play) this.playAudio(type, this.settingsaudio); if (play) {
this.SettingsUpdated = true;
this.playAudio(type, this.settingsaudio);
}
} }
playAudio (type, audio) { playAudio (type, audio) {
@ -471,4 +478,11 @@ class NotificationSounds {
processPrivateChannelCall (instance, wrapper) { processPrivateChannelCall (instance, wrapper) {
this.patchCallingSound(instance, "PrivateChannelCall", "call_calling"); this.patchCallingSound(instance, "PrivateChannelCall", "call_calling");
} }
processStandardSidebarView (instance, wrapper) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.settingsaudio.pause();
}
}
} }