Give listFeeds its container: Add a feed loads its Popular list again

The dialog and the Directory/Popular pane both rendered into id="popular", and
listFeeds looked it up by id, so the dialog's list landed in the pane behind it.

Fixes #1

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZbKERNSt4vQfyGV8rvkqp
This commit is contained in:
2026-09-14 21:28:49 +00:00
parent eeb72fd677
commit af38583b53
6 changed files with 55 additions and 6 deletions

View File

@@ -1625,11 +1625,11 @@ $('#addFeed').onclick=()=>{
<input type="text" id="nkw"><span class="hint">Only items matching a keyword are downloaded.</span></div>
<label class="check"><input type="checkbox" id="nexp"> Allow items marked explicit</label>
<div class="field"><label>Popular on this server</label>
<div class="childlist" id="popular"><p class="hint">Loading…</p></div></div>
<div class="childlist" id="npopular"><p class="hint">Loading…</p></div></div>
<div class="cardacts"><button class="btn ico" onclick="closeModal()" title="Cancel" aria-label="Cancel">${ICON.close}</button>
<button class="btn ico primary" id="nsave" title="Add feed" aria-label="Add feed">${ICON.plus}</button></div>`);
$('#nurl').focus();
listFeeds('/api/popular');
listFeeds('/api/popular',$('#npopular'));
$('#nsave').onclick=async()=>{
const url=$('#nurl').value.trim(); if(!url) return;
$('#nsave').disabled=true; $('#nsave').title='Adding…';
@@ -1644,9 +1644,9 @@ $('#addFeed').onclick=()=>{
};
// What everyone here reads, you included, as a place to start. The rows carry an id, never a
// URL, so a key in someone's feed address never reaches this page.
async function listFeeds(url){
const box=$('#popular');
// URL, so a key in someone's feed address never reaches this page. The caller hands over the
// box: looked up by id, the Add a feed dialog's list landed in the Directory pane behind it.
async function listFeeds(url,box){
let rows=[];
try{ rows=await api(url)||[]; }catch{}
box.innerHTML=rows.length?'':'<p class="hint">Nothing yet. Feeds people here subscribe to show up here.</p>';
@@ -1691,7 +1691,7 @@ async function renderListed(v){
${listening?`<div class="sub" style="margin:18px 0 8px;font-weight:600;color:var(--fg)">Currently Listening</div>
<div class="childlist" id="listening"><p class="hint">Loading…</p></div>`:''}`;
$('#count').textContent=v.title;
const n=await listFeeds(v.url);
const n=await listFeeds(v.url,$('#popular',box));
if(VIEWS[S.feed]===v) $('#count').textContent=`${v.title}: ${n} feed${n===1?'':'s'}`;
if(listening) renderListening();
}