dm: prompt for login when messaging while logged out

The "Message" button opened the profile modal's messages tab even with no user
logged in, leaving an unusable composer (DMs need a signing identity). Gate
openDirectMessageComposer behind isUserLoggedIn(): surface a login message and
open the login modal (falling back to authService.requestLogin) instead of
opening the messages pane.

Regression: tests/app/dm-composer-login-gate.test.mjs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-06-23 21:22:03 -04:00
1 parent ab68ba51d0
commit fd546fa1e5
2 files changed
+119

No files matched your search

+31
View File
@@ -2974,6 +2974,37 @@ class Application {
return false;
}
// Direct messages require a signing identity. If nobody is logged in, prompt
// for login instead of silently opening an unusable messages tab.
if (!this.isUserLoggedIn()) {
this.showError(
"Please log in with your Nostr account to send a direct message.",
);
try {
if (
this.loginModalController &&
typeof this.loginModalController.openModal === "function" &&
this.loginModalController.openModal({})
) {
return false;
}
} catch (error) {
devLogger.warn(
"[Application] Failed to open login modal for direct message:",
error,
);
}
Promise.resolve(
this.authService?.requestLogin?.({ allowAccountSelection: true }),
).catch((error) => {
devLogger.warn(
"[Application] Direct message login request failed:",
error,
);
});
return false;
}
this.setDmRecipientPubkey(normalized);
if (this.profileController) {