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

[FIX] Admin panel custom sounds, multiple sound playback fix and added single play/pause button #16215

Merged
merged 5 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/custom-sounds/client/admin/adminSounds.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
</td>
<td width="20%">
<div class="rc-table-wrapper">
{{>icon _id=_id icon="play" block="icon-play-circled"}}
{{>icon _id=_id icon="pause" block="icon-pause-circled"}}
{{#if isPlaying _id}}
{{>icon _id=_id icon="pause" block="icon-pause-circled"}}
{{else}}
{{>icon _id=_id icon="play" block="icon-play-circled"}}
{{/if}}
{{>icon _id=_id icon="ban" block="icon-reset-circled"}}
</div>
</td>
Expand Down
18 changes: 16 additions & 2 deletions app/custom-sounds/client/admin/adminSounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Template.adminSounds.helpers({
const instance = Template.instance();
return instance.filter && instance.filter.get();
},
isPlaying(_id) {
return Template.instance().isPlayingId.get() === _id;
},
customsounds() {
return Template.instance().sounds.get();
},
Expand Down Expand Up @@ -62,6 +65,7 @@ Template.adminSounds.onCreated(function() {
this.query = new ReactiveVar({});
this.isLoading = new ReactiveVar(false);
this.filter = new ReactiveVar('');
this.isPlayingId = new ReactiveVar('');

this.tabBar = new RocketChatTabBar();
this.tabBar.showGroup(FlowRouter.current().route.name);
Expand Down Expand Up @@ -138,18 +142,28 @@ Template.adminSounds.events({
t.filter.set(e.currentTarget.value);
t.offset.set(0);
},
'click .icon-play-circled'(e) {
'click .icon-play-circled'(e, t) {
e.preventDefault();
e.stopPropagation();
CustomSounds.play(this._id);
const audio = document.getElementById(t.isPlayingId.get());
if (audio) {
audio.pause();
}
document.getElementById(this._id).onended = () => {
t.isPlayingId.set('');
this.onended = null;
};
t.isPlayingId.set(this._id);
},
'click .icon-pause-circled'(e) {
'click .icon-pause-circled'(e, t) {
e.preventDefault();
e.stopPropagation();
const audio = document.getElementById(this._id);
if (audio && !audio.paused) {
audio.pause();
}
t.isPlayingId.set('');
},
'click .icon-reset-circled'(e) {
e.preventDefault();
Expand Down