feat: add manual save button for player name and update UI interactions
All checks were successful
Build and Push Docker Image / docker (push) Successful in 6s

This commit is contained in:
2025-10-12 23:21:46 +02:00
parent 0e51e233c3
commit 6001143bbf
4 changed files with 353 additions and 322 deletions

View File

@@ -21,6 +21,7 @@ import {
$leaveRoom,
$playBtn,
$volumeSlider,
$saveName,
} from './dom.js';
import { state } from './state.js';
import { initAudioUI, stopAudioPlayback } from './audio.js';
@@ -50,7 +51,26 @@ export function wireUi() {
}
}
// Button removed: autosave handles everything
// Manual save button
if ($saveName) {
wire($saveName, 'click', () => {
if (nameDebounce) {
clearTimeout(nameDebounce);
nameDebounce = null;
}
const val = ($nameLobby?.value || '').trim();
if (!val) {
showToast('⚠️ Bitte gib einen Namen ein!');
return;
}
const prev = localStorage.getItem('playerName') || '';
if (prev === val) {
showToast('✓ Name bereits gespeichert!');
return;
}
saveNameIfChanged(val);
});
}
// Autosave on input with debounce
if ($nameLobby) {