mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 20:32:27 +00:00
Ensure login UI updates after NIP-07 approval
This commit is contained in:
1 parent
2e516ca989
commit
3bf380dfc6
2 files changed
+38
-3
No files matched your search
@@ -1722,10 +1722,25 @@ class Application {
|
||||
"[app.js] loginNIP07 clicked! Attempting extension login..."
|
||||
);
|
||||
try {
|
||||
const { pubkey } = await this.authService.requestLogin();
|
||||
const { pubkey, detail } = await this.authService.requestLogin();
|
||||
console.log("[NIP-07] login returned pubkey:", pubkey);
|
||||
|
||||
if (pubkey) {
|
||||
if (
|
||||
detail &&
|
||||
typeof detail === "object" &&
|
||||
detail.__handled !== true
|
||||
) {
|
||||
try {
|
||||
await this.handleAuthLogin(detail);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"[NIP-07] handleAuthLogin fallback failed:",
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const loginModal = document.getElementById("loginModal");
|
||||
if (loginModal) {
|
||||
loginModal.classList.add("hidden");
|
||||
@@ -2516,6 +2531,14 @@ class Application {
|
||||
}
|
||||
|
||||
async handleAuthLogin(detail = {}) {
|
||||
if (detail && typeof detail === "object") {
|
||||
try {
|
||||
detail.__handled = true;
|
||||
} catch (error) {
|
||||
// Ignore attempts to mutate read-only descriptors.
|
||||
}
|
||||
}
|
||||
|
||||
const normalizedActive = this.normalizeHexPubkey(
|
||||
detail?.pubkey || this.pubkey
|
||||
);
|
||||
|
||||
@@ -251,11 +251,11 @@ export default class AuthService {
|
||||
return { pubkey: trimmed };
|
||||
}
|
||||
|
||||
await this.login(trimmed, {
|
||||
const detail = await this.login(trimmed, {
|
||||
persistActive: options?.persistActive !== false,
|
||||
});
|
||||
|
||||
return { pubkey: trimmed };
|
||||
return { pubkey: trimmed, detail };
|
||||
}
|
||||
|
||||
async handleUploadSubmit(payload, { publish } = {}) {
|
||||
@@ -372,6 +372,18 @@ export default class AuthService {
|
||||
postLogin,
|
||||
};
|
||||
|
||||
try {
|
||||
Object.defineProperty(detail, "__handled", {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: false,
|
||||
});
|
||||
} catch (error) {
|
||||
// Ignore descriptor errors (e.g., frozen objects) and fall back to direct assignment.
|
||||
detail.__handled = false;
|
||||
}
|
||||
|
||||
this.emit("auth:login", detail);
|
||||
return detail;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user