diff --git a/src/routes/repos/[naddr]/+page.svelte b/src/routes/repos/[naddr]/+page.svelte
index 1a3e498..f6d83f5 100644
--- a/src/routes/repos/[naddr]/+page.svelte
+++ b/src/routes/repos/[naddr]/+page.svelte
@@ -418,7 +418,7 @@
}
}
- async function loadIssueStatuses() {
+ async function loadIssueStatuses(forceNetwork = false) {
if (issues.length === 0) return;
try {
@@ -438,6 +438,7 @@
// Status events are different kinds: 1630 (Open), 1631 (Applied/Merged/Resolved), 1632 (Closed), 1633 (Draft)
// They have "e" tags pointing to issues with marker "root"
+ // Use 'relay-first' when forcing network fetch (e.g., after status change) to bypass cached empty results
const statuses = await nostrClient.fetchEvents(
[{
'#e': issueIds,
@@ -445,7 +446,7 @@
limit: 200
}],
relays,
- { useCache: 'cache-first', cacheResults: true } // Prioritize cache
+ { useCache: forceNetwork ? 'relay-first' : 'cache-first', cacheResults: true }
);
// Process statuses for this batch
@@ -486,8 +487,18 @@
}
}
+ // Merge with existing state to preserve any local updates that haven't propagated yet
+ // Keep the newer status for each issue
+ const mergedStatuses = new Map(issueStatuses);
+ for (const [issueId, newStatus] of statusMap.entries()) {
+ const existingStatus = mergedStatuses.get(issueId);
+ if (!existingStatus || newStatus.created_at > existingStatus.created_at) {
+ mergedStatuses.set(issueId, newStatus);
+ }
+ }
+
// Update state after each batch so newest issues show statuses first
- issueStatuses = new Map(statusMap);
+ issueStatuses = mergedStatuses;
}
} catch (error) {
// Failed to load issue statuses
@@ -552,6 +563,12 @@
issueStatuses.set(issueId, signedEvent);
issueStatuses = new Map(issueStatuses); // Trigger reactivity
+ // Refresh the view immediately using cache-first to show the newly cached event
+ // This ensures the cached event is displayed right away
+ loadIssueStatuses(false).catch(() => {
+ // Non-critical - status is already updated locally
+ });
+
// Publish to relays in background (don't wait for it)
const relays = relayManager.getProfileReadRelays();
signAndPublish(event, relays).then((result) => {
@@ -559,10 +576,13 @@
console.warn('Failed to publish status change to some relays:', result.failed);
// Don't show alert - event is cached and will sync eventually
}
- // Reload statuses to get any other updates from relays
- loadIssueStatuses().catch(() => {
- // Non-critical - status is already updated locally
- });
+ // Optionally reload from network to get any other updates from relays
+ // Use a small delay to allow the event to propagate
+ setTimeout(() => {
+ loadIssueStatuses(true).catch(() => {
+ // Non-critical - status is already updated locally
+ });
+ }, 1000);
}).catch((error) => {
console.error('Error publishing status change:', error);
// Don't show alert - event is cached and will sync eventually
@@ -854,6 +874,15 @@
}
}
+ function getRepoATag(): string | null {
+ if (!repoEvent) return null;
+ const dTag = repoEvent.tags.find(t => Array.isArray(t) && t[0] === 'd')?.[1] || '';
+ if (dTag) {
+ return `${repoEvent.kind}:${repoEvent.pubkey}:${dTag}`;
+ }
+ return null;
+ }
+
function getRepoName(): string {
try {
if (!repoEvent) return 'Repository';
@@ -1470,31 +1499,40 @@
{:else if issues.length > 0}