This commit is contained in:
Mateusz Gruszczyński committed 2026-10-16 22:49:22 +02:00
1 parent 4da41a1404
commit 5cb6960b04
31 files changed
+1611 -2123

No files matched your search

+20 -3
View File
@@ -100,6 +100,7 @@ document.querySelector("#workspace-form").addEventListener("submit", async (even
await handleAccountConfirmationToken() || await handleResetToken() || await handleAccountActionToken() || await handleShareInvitationToken();
const identityDialog = document.querySelector("#identity-dialog");
const accountSlot = document.querySelector("#footer-account-slot");
const guestAccount = document.querySelector("#footer-account-guest");
const userAccount = document.querySelector("#footer-account-user");
const userLabel = document.querySelector("#footer-user-label");
@@ -121,6 +122,7 @@ const aboutDialog = document.querySelector("#about-dialog");
const profileForm = document.querySelector("#profile-form");
let currentSession = null;
let accountStateRevision = 0;
function authHeaders() { return {}; }
function escapeHtml(value) { const node = document.createElement("div"); node.textContent = String(value ?? ""); return node.innerHTML; }
@@ -440,6 +442,7 @@ resourcesPagination?.addEventListener("click", event => { const button = event.t
function renderAccount(session) {
accountStateRevision += 1;
currentSession = session;
guestAccount.hidden = Boolean(session);
userAccount.hidden = !session;
@@ -473,6 +476,13 @@ function renderAccount(session) {
userLabelSecondary.hidden = true;
}
registerLink.hidden = !registrationEnabled;
if (accountSlot) {
accountSlot.dataset.state = "ready";
accountSlot.setAttribute("aria-busy", "false");
const retry = document.querySelector("#footer-account-retry");
if (retry) retry.hidden = true;
}
}
document.querySelector("#footer-about")?.addEventListener("click", () => aboutDialog?.showModal());
@@ -523,7 +533,7 @@ if (identityDialog) {
profileDialog.showModal();
});
document.addEventListener("rustpad:languagechange", () => {
renderAccount(currentSession);
if (accountSlot?.dataset.state === "ready") renderAccount(currentSession);
if (!profileDialog?.open) return;
populateLanguageSelect(document.querySelector("#profile-language"), getLanguage());
});
@@ -601,6 +611,13 @@ if (identityDialog) {
});
window.addEventListener("rustpad:session-expired", () => renderAccount(null));
renderAccount(null);
validateCurrentSession().then(renderAccount);
const lookupRevision = accountStateRevision;
validateCurrentSession()
.then(session => {
if (accountStateRevision === lookupRevision) renderAccount(session);
})
.catch(error => {
console.warn("Could not validate the saved session", error);
if (accountStateRevision === lookupRevision) renderAccount(null);
});
}