session storage to make selected account per tab

This commit is contained in:
MathMan05 2024-12-23 12:58:45 -06:00
parent de4f0bc0ca
commit 837e9b01ee
3 changed files with 6 additions and 2 deletions

View file

@ -64,6 +64,7 @@ import {I18n} from "./i18n.js";
thisUser = new Localuser(specialUser); thisUser = new Localuser(specialUser);
users.currentuser = specialUser.uid; users.currentuser = specialUser.uid;
sessionStorage.setItem("currentuser", specialUser.uid);
localStorage.setItem("userinfos", JSON.stringify(users)); localStorage.setItem("userinfos", JSON.stringify(users));
thisUser.initwebsocket().then(() => { thisUser.initwebsocket().then(() => {
@ -107,8 +108,9 @@ import {I18n} from "./i18n.js";
let thisUser: Localuser; let thisUser: Localuser;
try { try {
console.log(users.users, users.currentuser); const current = sessionStorage.getItem("currentuser") || users.currentuser;
thisUser = new Localuser(users.users[users.currentuser]); console.log(users.users, current);
thisUser = new Localuser(users.users[current]);
thisUser.initwebsocket().then(() => { thisUser.initwebsocket().then(() => {
thisUser.loaduser(); thisUser.loaduser();
thisUser.init(); thisUser.init();

View file

@ -112,6 +112,7 @@ import {getBulkUsers, Specialuser} from "./utils/utils.js";
}, },
}).then(() => { }).then(() => {
users.currentuser = user.uid; users.currentuser = user.uid;
sessionStorage.setItem("currentuser", user.uid);
localStorage.setItem("userinfos", JSON.stringify(users)); localStorage.setItem("userinfos", JSON.stringify(users));
window.location.href = "/channels/" + guildinfo.id; window.location.href = "/channels/" + guildinfo.id;
}); });

View file

@ -59,6 +59,7 @@ function adduser(user: typeof Specialuser.prototype.json) {
const info = getBulkInfo(); const info = getBulkInfo();
info.users[user.uid] = user; info.users[user.uid] = user;
info.currentuser = user.uid; info.currentuser = user.uid;
sessionStorage.setItem("currentuser", user.uid);
localStorage.setItem("userinfos", JSON.stringify(info)); localStorage.setItem("userinfos", JSON.stringify(info));
return user; return user;
} }