|
|
@ -84,20 +84,16 @@ window.addEventListener('DOMContentLoaded', (event) => { |
|
|
|
hoveredPost = anchor.nextSibling; |
|
|
|
hoveredPost = anchor.nextSibling; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
let hovercache = localStorage.getItem(`hovercache-${jsonPath}`); |
|
|
|
let hovercache = localStorage.getItem(`hovercache-${jsonPath}`); |
|
|
|
let threadJson; |
|
|
|
|
|
|
|
let postJson; |
|
|
|
let postJson; |
|
|
|
if (hovercache) { |
|
|
|
if (hovercache) { |
|
|
|
hovercache = JSON.parse(hovercache); |
|
|
|
hovercache = JSON.parse(hovercache); |
|
|
|
let highestId = 0; |
|
|
|
if (hovercache.postId == hash) { |
|
|
|
if (hovercache.replies && hovercache.replies.length > 0) { |
|
|
|
postJson = hovercache; |
|
|
|
highestId = Math.max(hovercache.postId, hovercache.replies[hovercache.replies.length-1].postId); |
|
|
|
} else if (hovercache.replies.length > 0) { |
|
|
|
|
|
|
|
postJson = hovercache.replies.find(r => r.postId == hash); |
|
|
|
} |
|
|
|
} |
|
|
|
if (highestId && highestId >= hash) { |
|
|
|
|
|
|
|
//post already in our cache
|
|
|
|
|
|
|
|
threadJson = hovercache; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!postJson) {//wasnt cached or cache outdates
|
|
|
|
if (!threadJson) { |
|
|
|
|
|
|
|
this.style.cursor = 'wait'; |
|
|
|
this.style.cursor = 'wait'; |
|
|
|
let json; |
|
|
|
let json; |
|
|
|
try { |
|
|
|
try { |
|
|
@ -111,8 +107,12 @@ window.addEventListener('DOMContentLoaded', (event) => { |
|
|
|
this.style.cursor = ''; |
|
|
|
this.style.cursor = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
if (json) { |
|
|
|
if (json) { |
|
|
|
threadJson = json; |
|
|
|
setLocalStorage(`hovercache-${jsonPath}`, JSON.stringify(jsonson)); |
|
|
|
setLocalStorage(`hovercache-${jsonPath}`, JSON.stringify(threadJson)); |
|
|
|
if (json.postId == hash) { |
|
|
|
|
|
|
|
postJson = json; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
postJson = json.replies.find(r => r.postId == hash); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return localStorage.removeItem(`hovercache-${jsonPath}`); //thread deleted
|
|
|
|
return localStorage.removeItem(`hovercache-${jsonPath}`); //thread deleted
|
|
|
|
} |
|
|
|
} |
|
|
@ -120,13 +120,8 @@ window.addEventListener('DOMContentLoaded', (event) => { |
|
|
|
if (lastHover !== loading) { |
|
|
|
if (lastHover !== loading) { |
|
|
|
return; //dont show for ones not hovering
|
|
|
|
return; //dont show for ones not hovering
|
|
|
|
} |
|
|
|
} |
|
|
|
if (threadJson.postId == hash) { |
|
|
|
|
|
|
|
postJson = threadJson; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
postJson = threadJson.replies.find(r => r.postId == hash); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!postJson) { |
|
|
|
if (!postJson) { |
|
|
|
return; //post was deleted or missing for some reason
|
|
|
|
return; //post was deleted or missing
|
|
|
|
} |
|
|
|
} |
|
|
|
const postHtml = post({ post: postJson }); |
|
|
|
const postHtml = post({ post: postJson }); |
|
|
|
const wrap = document.createElement('div'); |
|
|
|
const wrap = document.createElement('div'); |
|
|
|