del
All checks were successful
/ upload (release) Successful in 22s

This commit is contained in:
pavel 2026-02-24 02:12:26 +01:00
commit e4cc833ccc
4 changed files with 143 additions and 1 deletions

View file

@ -1049,13 +1049,46 @@ function renderSounds(sounds) {
sounds.forEach(sound => {
const item = document.createElement('div');
item.className = 'sound-item';
// Only show delete button if user is creator or owner
const canDelete = state.user && (state.user.id === sound.created_by_user_id || (state.guilds.find(g => g.id === state.selectedGuildId)?.owner_user_id === state.user.id));
item.innerHTML = `
<div class="sound-icon">${sound.icon}</div>
<div class="sound-name">${sound.name}</div>
${canDelete ? `<button class="sound-delete" title="Delete sound"><i data-lucide="x"></i></button>` : ''}
`;
item.onclick = () => playRemoteSound(sound.file_path);
item.onclick = (e) => {
if (e.target.closest('.sound-delete')) {
e.stopPropagation();
if (confirm(`Are you sure you want to delete "${sound.name}"?`)) {
deleteSound(sound.id);
}
return;
}
playRemoteSound(sound.file_path);
};
el.soundboardGrid.appendChild(item);
});
lucide.createIcons();
}
async function deleteSound(soundId) {
if (!state.selectedGuildId) return;
try {
const response = await fetch(`/guilds/${state.selectedGuildId}/sounds/${soundId}`, {
method: 'DELETE'
});
if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Delete failed');
}
await loadSounds();
} catch (err) {
alert(err.message);
}
}
function playRemoteSound(url) {