feat(chan): use /abyss/:board/:tid path format for thread scroller
This commit is contained in:
+24
-16
@@ -1456,7 +1456,7 @@
|
||||
? `<a class="scroll-id-link" href="https://boards.4chan.org/${item.external_board}/thread/${item.external_tid}#p${item.external_id}" target="_blank">/${item.external_board}/thread/${item.external_tid}</a>`
|
||||
: (item.local_id
|
||||
? `<a class="scroll-id-link" href="/${item.local_id}" target="_blank">#${item.local_id}</a>`
|
||||
: `<a class="scroll-id-link" href="/abyss#${item.id}">#${item.id}</a>`)}
|
||||
: `<a class="scroll-id-link" href="/abyss/${item.id}">#${item.id}</a>`)}
|
||||
</div>`;
|
||||
slide.appendChild(meta);
|
||||
|
||||
@@ -1636,8 +1636,8 @@
|
||||
const localId = slide?.dataset.localId;
|
||||
const id = localId || shareBtn.dataset.id;
|
||||
const abyssUrl = localId
|
||||
? `${location.origin}/abyss#${localId}`
|
||||
: `${location.origin}/abyss#${id}`;
|
||||
? `${location.origin}/abyss/${localId}`
|
||||
: (id ? `${location.origin}/abyss/${id}` : `${location.origin}/abyss`);
|
||||
openSharePanel(abyssUrl);
|
||||
});
|
||||
const rehostBtn = actions.querySelector('.rehost-btn');
|
||||
@@ -3139,7 +3139,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ── Auto-load 4chan thread from hash (e.g. #wsg/6132740) ────────────────
|
||||
// ── Auto-load 4chan thread from path or hash (e.g. /abyss/wsg/6211653 or #wsg/6211653) ────────────────
|
||||
let chanHashPending = null; // async promise if we need server lookup
|
||||
{
|
||||
const hid = hashId();
|
||||
@@ -3153,21 +3153,29 @@
|
||||
const postMap = JSON.parse(localStorage.getItem('4chan_post_threads') || '{}');
|
||||
tid = postMap[hid]; // hid is "board/postno"
|
||||
} catch(_) {}
|
||||
if (tid) {
|
||||
applied.externalUrl = `https://boards.4chan.org/${board}/thread/${tid}`;
|
||||
applied.order = 'oldest';
|
||||
unlock4chan();
|
||||
} else {
|
||||
// No local mapping — ask the server to find the thread
|
||||
|
||||
const effectiveTid = tid || postno;
|
||||
applied.externalUrl = `https://boards.4chan.org/${board}/thread/${effectiveTid}`;
|
||||
applied.order = 'oldest';
|
||||
unlock4chan();
|
||||
|
||||
if (!tid) {
|
||||
// In case postno was a reply post rather than thread OP, query find in background
|
||||
chanHashPending = fetch(`/api/v2/scroller/external/4chan/${board}/find/${postno}`)
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
window.f0ckDebug('[CHAN] Find result:', data);
|
||||
window.f0ckDebug && window.f0ckDebug('[CHAN] Find result:', data);
|
||||
if (data.success && data.tid) {
|
||||
applied.externalUrl = `https://boards.4chan.org/${board}/thread/${data.tid}`;
|
||||
applied.order = 'oldest';
|
||||
unlock4chan();
|
||||
window.f0ckDebug('[CHAN] Set externalUrl:', applied.externalUrl);
|
||||
try {
|
||||
const postMap = JSON.parse(localStorage.getItem('4chan_post_threads') || '{}');
|
||||
postMap[hid] = data.tid;
|
||||
localStorage.setItem('4chan_post_threads', JSON.stringify(postMap));
|
||||
} catch(_) {}
|
||||
if (String(data.tid) !== String(effectiveTid)) {
|
||||
applied.externalUrl = `https://boards.4chan.org/${board}/thread/${data.tid}`;
|
||||
applied.order = 'oldest';
|
||||
reloadFeed();
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => { console.error('[CHAN] Find error:', err); });
|
||||
@@ -3923,7 +3931,7 @@
|
||||
|
||||
const restored = tryRestoreFromCache();
|
||||
if (!restored) {
|
||||
if (chanHashPending) {
|
||||
if (chanHashPending && !applied.externalUrl) {
|
||||
chanHashPending.then(() => fetchItems());
|
||||
} else {
|
||||
fetchItems();
|
||||
|
||||
Reference in New Issue
Block a user