fixed bug
This commit is contained in:
1 parent
0714b8eb48
commit
d93167a114
4 files changed
+49
-14
No files matched your search
@@ -232,17 +232,38 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Safe Get Comment List Helper
|
||||
function getCommentListSafe(artalkInstance) {
|
||||
var inst = artalkInstance || window.artalk;
|
||||
if (!inst) return [];
|
||||
|
||||
if (typeof inst.getCommentList === 'function') return inst.getCommentList();
|
||||
if (typeof inst.getComments === 'function') return inst.getComments();
|
||||
|
||||
// Try context access (Artalk v2)
|
||||
if (inst.ctx && typeof inst.ctx.get === 'function') {
|
||||
var list = inst.ctx.get('list');
|
||||
if (list && typeof list.getComments === 'function') {
|
||||
return list.getComments();
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function setupArtalkHook(artalk) {
|
||||
// Initial load
|
||||
var list = artalk.getCommentList();
|
||||
var list = getCommentListSafe(artalk);
|
||||
if (list && list.length > 0) {
|
||||
processComments();
|
||||
}
|
||||
|
||||
// Listen for updates
|
||||
artalk.on('list-loaded', function() {
|
||||
setTimeout(processComments, 500);
|
||||
});
|
||||
if (typeof artalk.on === 'function') {
|
||||
artalk.on('list-loaded', function() {
|
||||
setTimeout(processComments, 500);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Performance Optimized: Build Index Once
|
||||
@@ -284,7 +305,7 @@
|
||||
});
|
||||
document.querySelectorAll('.paragraph-comment-count').forEach(el => el.remove());
|
||||
|
||||
var comments = window.artalk.getCommentList();
|
||||
var comments = getCommentListSafe(window.artalk);
|
||||
var quoteMap = {};
|
||||
|
||||
// Group comments by quote
|
||||
|
||||
Reference in new issue
Block a user