Show published note content inline on Home screen

This commit is contained in:
Avi 2026-09-01 13:06:33 -05:00
commit cd5d2d7fd1
7 changed files with 36 additions and 34 deletions

View file

@ -71,7 +71,7 @@ function Shell() {
)}
{screen === 'feed' && <FeedScreen onNavigate={setScreen} />}
{screen === 'profiles' && <ProfilesScreen onCreateProfile={() => setCreateOpen(true)} />}
{screen === 'compose' && <ComposeScreen onNavigate={setScreen} />}
{screen === 'compose' && <ComposeScreen />}
{screen === 'relays' && <RelaysScreen />}
{screen === 'signer' && <SignerScreen />}
{screen === 'settings' && <SettingsScreen />}

View file

@ -66,6 +66,8 @@ export interface PublishReport {
event_id: string;
succeeded: string[];
failed: RelayFailure[];
/** The note content that was published. */
content?: string;
}
/** Per-relay outcome of publishing a profile's name as kind 0 metadata. */
@ -145,6 +147,7 @@ export interface AppState {
event_id: string;
succeeded: string[];
failed: RelayFailure[];
content: string;
} | null;
}

View file

@ -9,7 +9,6 @@ import { Modal } from '../components/Modal';
import { shortenNpub } from '../lib/format';
import { extractImageUrls, extractLinkUrls } from '../lib/media';
import type { LinkPreview } from '../lib/types';
import type { Screen } from '../lib/navigation';
import { useApp } from '../state/AppProvider';
const SOFT_LIMIT = 10_000;
@ -33,11 +32,7 @@ function buildContent(content: string, attachments: Attachment[]): string {
return parts.join('\n');
}
interface ComposeScreenProps {
onNavigate?: (screen: Screen) => void;
}
export function ComposeScreen({ onNavigate }: ComposeScreenProps) {
export function ComposeScreen() {
const {
state,
publishNote,
@ -369,12 +364,6 @@ export function ComposeScreen({ onNavigate }: ComposeScreenProps) {
{shortenNpub(lastReport.event_id, true)}
</span>
<CopyButton text={lastReport.event_id} label="event ID" />
{onNavigate && (
<Button variant="ghost" size="sm" onClick={() => onNavigate('feed')}>
<Icon name="list" size={16} />
View in Feed
</Button>
)}
{lastReport.failed.length > 0 && (
<details className="alert-details">
<summary>Relays that didn't accept it</summary>

View file

@ -184,7 +184,6 @@ export function HomeScreen({ onNavigate, onCreateProfile }: HomeScreenProps) {
<PublicationResult
lastPublish={lastPublish}
onNavigateCompose={() => onNavigate('compose')}
onNavigateFeed={() => onNavigate('feed')}
/>
</div>
</section>
@ -196,11 +195,9 @@ export function HomeScreen({ onNavigate, onCreateProfile }: HomeScreenProps) {
function PublicationResult({
lastPublish,
onNavigateCompose,
onNavigateFeed,
}: {
lastPublish: ReturnType<typeof useApp>['lastPublish'];
onNavigateCompose: () => void;
onNavigateFeed: () => void;
}) {
if (!lastPublish) {
return (
@ -231,6 +228,7 @@ function PublicationResult({
if (report.failed.length === 0) {
return (
<>
<div className="publish-result success">
<Badge tone="success">
<Icon name="check" size={14} /> Published
@ -239,11 +237,9 @@ function PublicationResult({
{shortenNpub(report.event_id, true)}
</span>
<CopyButton text={report.event_id} label="event ID" />
<Button variant="ghost" size="sm" onClick={onNavigateFeed}>
<Icon name="list" size={16} />
View in Feed
</Button>
</div>
{report.content && <p className="publish-preview">{report.content}</p>}
</>
);
}
@ -257,10 +253,7 @@ function PublicationResult({
</code>
</Alert>
<CopyButton text={report.event_id} label="event ID" />
<Button variant="ghost" size="sm" onClick={onNavigateFeed}>
<Icon name="list" size={16} />
View in Feed
</Button>
{report.content && <p className="publish-preview">{report.content}</p>}
<details className="alert-details">
<summary>Relay results</summary>
<ul className="relay-result-list">

View file

@ -1587,6 +1587,18 @@ select {
flex-basis: 100%;
}
.publish-preview {
margin: 8px 0 0;
padding: 10px 12px;
background: var(--surface-2);
border-radius: var(--radius-sm);
font-size: 14px;
line-height: 1.5;
white-space: pre-wrap;
word-break: break-word;
max-width: 65ch;
}
.relay-result-list {
margin: 8px 0 0;
padding-left: 18px;

View file

@ -468,8 +468,11 @@ async fn run_with_app(app: &mut App, request: Request) -> Result<serde_json::Val
event_id: report.event_id.clone(),
succeeded: report.succeeded.clone(),
failed: report.failed.clone(),
content: content.trim().to_string(),
};
let _ = crate::vault::save_last_publish(&stored);
if let Err(e) = crate::vault::save_last_publish(&stored) {
eprintln!("Could not save last publish report: {e}");
}
app.last_publish = Some(stored);
Ok(json!(report))
}

View file

@ -193,6 +193,8 @@ pub struct StoredPublishReport {
pub event_id: String,
pub succeeded: Vec<String>,
pub failed: Vec<crate::publish::RelayFailure>,
#[serde(default)]
pub content: String,
}
/// Load the last publish report, returning `None` when absent or unreadable.