Skip to content

Commit

Permalink
Allow users to update their name
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkaufman committed Jan 12, 2021
1 parent fe31acd commit 4aef788
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions html/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,11 @@ export class SingerClient extends EventTarget {
});
}

updateUserName(newUserName) {
this.username = newUserName;
this.connection.updateUserName(newUserName);
}

get speakerMuted() {
return this.speakerMuted_;
}
Expand Down Expand Up @@ -1188,6 +1193,10 @@ export class SingerClientConnection {
this.running = true;
}

updateUserName(newUserName) {
this.username = newUserName;
}

async start_singing() {
return this.server_connection.start();
}
Expand Down
12 changes: 12 additions & 0 deletions html/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,18 @@ window.headerExpandCollapse.addEventListener("click", () => {
window.headerExpandCollapse.innerHTML = headerCollapsed ? "↓" : "↑";
});

window.changeNameButton.addEventListener("click", () => {
window.userName.value = window.changeName.value;
localStorage.setItem("userName", window.userName.value);
if (singer_client) {
singer_client.updateUserName(window.userName.value);
}
});
window.userName.addEventListener("change", () => {
window.changeName.value = window.userName.value;
});
window.changeName.value = window.userName.value;

document.querySelectorAll("#tutorial_questions button").forEach(
(button) => button.addEventListener("click", () => tutorial_answer(button)));

Expand Down
5 changes: 5 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ <h3>Settings that affect everyone</h3>
<input type="range" min="0" max="160" value="100" id="backingVolumeSlider">
</div>

<div>
<input id=changeName></input>
<button id=changeNameButton>Update</button>
</div>

<!-- DELAY_INTERVAL * LAYERING_DEPTH -->
<div>Time Travel: <input type=text id=audioOffset value="18">s</div>

Expand Down
1 change: 1 addition & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ def update_users(userid, username, server_clock, client_read_clock) -> None:

users[userid].last_heard_server_clock = server_clock
users[userid].delay_samples = delay_samples
users[userid].name = username

def clean_users(server_clock) -> None:
to_delete = []
Expand Down

0 comments on commit 4aef788

Please sign in to comment.