mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-30 13:19:16 +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;
|
counts[key] = Object.keys(states[key]).length;
|
||||||
});
|
});
|
||||||
console.warn('STATE stats', counts);
|
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
|
// Preload icons
|
||||||
// There's probably a better way to do this
|
// There's probably a better way to do this
|
||||||
// Related: https://github.com/vitejs/vite/issues/10600
|
// Related: https://github.com/vitejs/vite/issues/10600
|
||||||
|
|
|
@ -116,6 +116,7 @@ function MediaPost({
|
||||||
const filterTitleStr = filterInfo?.titlesStr;
|
const filterTitleStr = filterInfo?.titlesStr;
|
||||||
return (
|
return (
|
||||||
<Parent
|
<Parent
|
||||||
|
data-state-post-id={sKey}
|
||||||
onMouseEnter={debugHover}
|
onMouseEnter={debugHover}
|
||||||
key={mediaKey}
|
key={mediaKey}
|
||||||
data-spoiler-text={
|
data-spoiler-text={
|
||||||
|
|
|
@ -973,6 +973,7 @@ function Status({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article
|
<article
|
||||||
|
data-state-post-id={sKey}
|
||||||
ref={(node) => {
|
ref={(node) => {
|
||||||
statusRef.current = node;
|
statusRef.current = node;
|
||||||
// Use parent node if it's in focus
|
// Use parent node if it's in focus
|
||||||
|
|
Loading…
Add table
Reference in a new issue