mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-16 15:21:48 +03:00
Garbage collect status quotes & unfurled links too
Make this less destructive by setting to 15min interval Ignore whatever errors inside
This commit is contained in:
parent
986187141e
commit
b461823d60
1 changed files with 19 additions and 8 deletions
27
src/app.jsx
27
src/app.jsx
|
@ -49,7 +49,7 @@ import {
|
|||
} from './utils/api';
|
||||
import { getAccessToken } from './utils/auth';
|
||||
import focusDeck from './utils/focus-deck';
|
||||
import states, { initStates } from './utils/states';
|
||||
import states, { initStates, statusKey } from './utils/states';
|
||||
import store from './utils/store';
|
||||
import { getCurrentAccount } from './utils/store-utils';
|
||||
import './utils/toast-alert';
|
||||
|
@ -81,18 +81,29 @@ window.__STATES_STATS__ = () => {
|
|||
};
|
||||
|
||||
// Experimental "garbage collection" for states
|
||||
// Every 5 minutes
|
||||
// Every 15 minutes
|
||||
// Only posts for now
|
||||
setInterval(() => {
|
||||
if (!window.__IDLE__) return;
|
||||
const { statuses } = states;
|
||||
const { statuses, unfurledLinks } = states;
|
||||
for (const key in statuses) {
|
||||
const $post = document.querySelector(`[data-state-post-id~="${key}"]`);
|
||||
if (!$post) {
|
||||
delete states.statuses[key];
|
||||
}
|
||||
try {
|
||||
const $post = document.querySelector(`[data-state-post-id~="${key}"]`);
|
||||
if (!$post) {
|
||||
delete states.statuses[key];
|
||||
delete states.statusQuotes[key];
|
||||
for (const link in unfurledLinks) {
|
||||
const unfurled = unfurledLinks[link];
|
||||
const sKey = statusKey(unfurled.id, unfurled.instance);
|
||||
if (sKey === key) {
|
||||
delete states.unfurledLinks[link];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}, 5 * 60 * 1000);
|
||||
}, 15 * 60 * 1000);
|
||||
|
||||
// Preload icons
|
||||
// There's probably a better way to do this
|
||||
|
|
Loading…
Add table
Reference in a new issue