mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 09:15:33 +03:00
Some sort of "garbage collection"
This commit is contained in:
parent
660cbebbc4
commit
9f31cc8e07
3 changed files with 25 additions and 0 deletions
23
src/app.jsx
23
src/app.jsx
|
@ -68,8 +68,31 @@ window.__STATES_STATS__ = () => {
|
|||
counts[key] = Object.keys(states[key]).length;
|
||||
});
|
||||
console.warn('STATE stats', counts);
|
||||
|
||||
const { statuses } = states;
|
||||
const unmountedPosts = [];
|
||||
for (const key in statuses) {
|
||||
const $post = document.querySelector(`[data-state-post-id="${key}"]`);
|
||||
if (!$post) {
|
||||
unmountedPosts.push(key);
|
||||
}
|
||||
}
|
||||
console.warn('Unmounted posts', unmountedPosts.length, unmountedPosts);
|
||||
};
|
||||
|
||||
// Experimental "garbage collection" for states
|
||||
// Every 5 minutes
|
||||
// Only posts for now
|
||||
setInterval(() => {
|
||||
const { statuses } = states;
|
||||
for (const key in statuses) {
|
||||
const $post = document.querySelector(`[data-state-post-id="${key}"]`);
|
||||
if (!$post) {
|
||||
delete states.statuses[key];
|
||||
}
|
||||
}
|
||||
}, 5 * 60 * 1000);
|
||||
|
||||
// Preload icons
|
||||
// There's probably a better way to do this
|
||||
// Related: https://github.com/vitejs/vite/issues/10600
|
||||
|
|
|
@ -116,6 +116,7 @@ function MediaPost({
|
|||
const filterTitleStr = filterInfo?.titlesStr;
|
||||
return (
|
||||
<Parent
|
||||
data-state-post-id={sKey}
|
||||
onMouseEnter={debugHover}
|
||||
key={mediaKey}
|
||||
data-spoiler-text={
|
||||
|
|
|
@ -973,6 +973,7 @@ function Status({
|
|||
|
||||
return (
|
||||
<article
|
||||
data-state-post-id={sKey}
|
||||
ref={(node) => {
|
||||
statusRef.current = node;
|
||||
// Use parent node if it's in focus
|
||||
|
|
Loading…
Reference in a new issue