this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Garbage collect status quotes & unfurled links too

Make this less destructive by setting to 15min interval
Ignore whatever errors inside

+19 -8
+19 -8
src/app.jsx
··· 49 49 } from './utils/api'; 50 50 import { getAccessToken } from './utils/auth'; 51 51 import focusDeck from './utils/focus-deck'; 52 - import states, { initStates } from './utils/states'; 52 + import states, { initStates, statusKey } from './utils/states'; 53 53 import store from './utils/store'; 54 54 import { getCurrentAccount } from './utils/store-utils'; 55 55 import './utils/toast-alert'; ··· 81 81 }; 82 82 83 83 // Experimental "garbage collection" for states 84 - // Every 5 minutes 84 + // Every 15 minutes 85 85 // Only posts for now 86 86 setInterval(() => { 87 87 if (!window.__IDLE__) return; 88 - const { statuses } = states; 88 + const { statuses, unfurledLinks } = states; 89 89 for (const key in statuses) { 90 - const $post = document.querySelector(`[data-state-post-id~="${key}"]`); 91 - if (!$post) { 92 - delete states.statuses[key]; 93 - } 90 + try { 91 + const $post = document.querySelector(`[data-state-post-id~="${key}"]`); 92 + if (!$post) { 93 + delete states.statuses[key]; 94 + delete states.statusQuotes[key]; 95 + for (const link in unfurledLinks) { 96 + const unfurled = unfurledLinks[link]; 97 + const sKey = statusKey(unfurled.id, unfurled.instance); 98 + if (sKey === key) { 99 + delete states.unfurledLinks[link]; 100 + break; 101 + } 102 + } 103 + } 104 + } catch (e) {} 94 105 } 95 - }, 5 * 60 * 1000); 106 + }, 15 * 60 * 1000); 96 107 97 108 // Preload icons 98 109 // There's probably a better way to do this