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

@ -7,10 +7,10 @@ const LOCAL_STORAGE_KEY = "excalidraw";
const LOCAL_STORAGE_KEY_STATE = "excalidraw-state";
const LOCAL_STORAGE_KEY_COLLAB = "excalidraw-collab";
export function saveUsernameToLocalStorage(id: string, username: string) {
export function saveUsernameToLocalStorage(username: string) {
try {
localStorage.setItem(
`${LOCAL_STORAGE_KEY_COLLAB}-${id}`,
LOCAL_STORAGE_KEY_COLLAB,
JSON.stringify({ username }),
);
} catch (error) {
@ -19,9 +19,9 @@ export function saveUsernameToLocalStorage(id: string, username: string) {
}
}
export function restoreUsernameFromLocalStorage(id: string): string | null {
export function restoreUsernameFromLocalStorage(): string | null {
try {
const data = localStorage.getItem(`${LOCAL_STORAGE_KEY_COLLAB}-${id}`);
const data = localStorage.getItem(LOCAL_STORAGE_KEY_COLLAB);
if (data) {
return JSON.parse(data).username;
}