|
|
@ -179,10 +179,15 @@ const processPost = async (post: HTMLDivElement) => { |
|
|
|
if (!res2 || res2.length == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
let test = res2?.flatMap(e => e![0].map(k => [k, e![1]] as [EmbeddedFile, EMBED_TYPES])); |
|
|
|
// processAttachments(post, res2?.flatMap(e => e![0].map(k => [k, e![1]] as [EmbeddedFile, boolean])));
|
|
|
|
processAttachments(post, res2?.flatMap(e => |
|
|
|
e![0].map(k => { |
|
|
|
let filtered = res2?.filter(e => e != null) as [EmbeddedFile[], EMBED_TYPES][]; |
|
|
|
if(filtered.length === 0){ |
|
|
|
console.warn("ImageProcessors returned empty for post.") |
|
|
|
console.warn(post) |
|
|
|
return; |
|
|
|
} |
|
|
|
processAttachments(post, filtered.flatMap(e => |
|
|
|
e[0].map(k => { |
|
|
|
if(k?.isBlacklisted === true){ |
|
|
|
post.querySelector('.reply')?.classList.add('hasblack'); |
|
|
|
} |
|
|
@ -237,18 +242,35 @@ const startup = async () => { |
|
|
|
...cappState, |
|
|
|
isCatalog: !!document.querySelector('.catalog-small') || !!location.pathname.match(/\/catalog$/), |
|
|
|
}); |
|
|
|
|
|
|
|
/* Temporary change for better performance */ |
|
|
|
const obs = new IntersectionObserver((entries, obs) => { |
|
|
|
setTimeout(()=>{ |
|
|
|
for(const item of entries) { |
|
|
|
if(!item.isIntersecting) continue; |
|
|
|
const target = item.target; |
|
|
|
if(target instanceof HTMLDivElement){ |
|
|
|
processPost(target); |
|
|
|
}else{ |
|
|
|
debugger; |
|
|
|
} |
|
|
|
obs.unobserve(target); |
|
|
|
} |
|
|
|
}, 1); |
|
|
|
}, {root:null, rootMargin: '3200px', threshold: 0.01}); |
|
|
|
posts.map(e => obs.observe(e as any)); |
|
|
|
|
|
|
|
// for (let i = 159; i < 160 ;++i)
|
|
|
|
// await processPost(posts[i] as any);
|
|
|
|
|
|
|
|
const n = 7; |
|
|
|
//console.log(posts);
|
|
|
|
const range = ~~(posts.length / n) + 1; |
|
|
|
await Promise.all([...new Array(n + 1)].map(async (e, i) => { |
|
|
|
const postsslice = posts.slice(i * range, (i + 1) * range); |
|
|
|
for (const post of postsslice) { |
|
|
|
await processPost(post as any); |
|
|
|
} |
|
|
|
})); |
|
|
|
// const n = 7;
|
|
|
|
// const range = ~~(posts.length / n) + 1;
|
|
|
|
// await Promise.all([...new Array(n + 1)].map(async (e, i) => {
|
|
|
|
// const postsslice = posts.slice(i * range, (i + 1) * range);
|
|
|
|
// for (const post of postsslice) {
|
|
|
|
// await processPost(post as any);
|
|
|
|
// }
|
|
|
|
// }));
|
|
|
|
//await Promise.all(posts.map(e => processPost(e as any)));
|
|
|
|
}; |
|
|
|
|
|
|
|