-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh server connection when MI server settings change (#24649)
- Loading branch information
Showing
5 changed files
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
import debounce from 'lodash.debounce'; | ||
|
||
import { settings } from '../../settings/server'; | ||
import { Voip } from '../../../server/sdk'; | ||
|
||
const debouncedRefresh = debounce(Voip.refresh, 1000); | ||
|
||
settings.watch('VoIP_Enabled', (value: boolean) => { | ||
return value ? Voip.init() : Voip.stop(); | ||
}); | ||
|
||
settings.changeMultiple( | ||
['VoIP_Management_Server_Host', 'VoIP_Management_Server_Port', 'VoIP_Management_Server_Username', 'VoIP_Management_Server_Password'], | ||
(_values) => { | ||
// Here, if 4 settings are changed at once, we're getting 4 diff callbacks. The good part is that all callbacks are fired almost instantly | ||
// So to avoid stopping/starting voip too often, we debounce the call and restart 1 second after the last setting has reached us. | ||
return debouncedRefresh(); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters