Global username instead of per room (#1382)

* global username

* remove string interpolation

Co-Authored-By: Lipis <lipiridis@gmail.com>

* remove string interpolation

Co-Authored-By: Lipis <lipiridis@gmail.com>

* remove backwards compat

Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
Kostas Bariotis 2020-04-11 21:23:12 +01:00 committed by GitHub
parent 166ad0412c
commit 2adae4132b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View file

@ -244,9 +244,7 @@ export class App extends React.Component<any, AppState> {
onRoomCreate={this.openPortal}
onRoomDestroy={this.closePortal}
onUsernameChange={(username) => {
if (this.portal.socket && this.portal.roomID && username) {
saveUsernameToLocalStorage(this.portal.roomID, username);
}
saveUsernameToLocalStorage(username);
this.setState({
username,
});
@ -921,12 +919,12 @@ export class App extends React.Component<any, AppState> {
);
this.portal.socket!.on("init-room", () => {
if (this.portal.socket && this.portal.roomID) {
const username = restoreUsernameFromLocalStorage(this.portal.roomID);
if (this.portal.socket) {
const username = restoreUsernameFromLocalStorage();
this.portal.socket.emit("join-room", this.portal.roomID);
if (username) {
if (username !== null) {
this.setState({
username,
});