Get session database for localstorage explicit, getusername

This commit is contained in:
Bel LaPointe
2021-02-28 03:00:30 -06:00
parent 2c0ce69396
commit 3b5ee269f8
2 changed files with 27 additions and 7 deletions

View File

@@ -3334,7 +3334,7 @@
{
pushAllNamespaces(namespace);
$('#page-title').html(namespace);
return new Local().set("namespace", namespace);
return getSessionDatabase().set("namespace", namespace);
}
function popAllNamespaces(namespace)
@@ -3358,13 +3358,13 @@
function setAllNamespaces(namespaces)
{
new Local().set("namespaces", JSON.stringify(namespaces));
getSessionDatabase().set("namespaces", JSON.stringify(namespaces));
updateNamespaceIndex();
}
function getAllNamespaces()
{
var namespaces = new Local().get("namespaces");
var namespaces = getSessionDatabase().get("namespaces");
if (! namespaces || namespaces == "[]")
namespaces = "[\"initial\"]";
return JSON.parse(namespaces);
@@ -3372,7 +3372,23 @@
function getCurrentNamespace()
{
return new Local().get("namespace") || getAllNamespaces()[0];
return getSessionDatabase().get("namespace") || getAllNamespaces()[0];
}
function getCurrentUsername()
{
var username = getSessionDatabase().get("username");
if (username == null)
{
username = prompt("Who are you?");
getSessionDatabase().set("username", username);
}
return username;
}
function getSessionDatabase()
{
return new NamespacedDatabase("session", new Local());
}
setGlobalStorage(getCurrentNamespace());