aboutsummaryrefslogtreecommitdiffstats
path: root/src/media-cache.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/media-cache.js')
-rw-r--r--src/media-cache.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/media-cache.js b/src/media-cache.js
index ee9e118..74c574a 100644
--- a/src/media-cache.js
+++ b/src/media-cache.js
@@ -41,6 +41,8 @@ async function tx(mode, fn) {
});
}
+export const ARTICLES_KEEP = 150; // articles per feed — whole, so a tap reads offline
+
// what a grid needs of a post: who, when, the words, and its imeta
export const compactMediaEvent = (e) => ({
id: e.id, pubkey: e.pubkey, created_at: e.created_at, kind: e.kind, content: String(e.content || '').slice(0, 2000),
@@ -55,7 +57,9 @@ export async function saveMediaIndex(key, rec) {
try {
await tx('readwrite', (s) => {
s.put({ ...rec, images: (rec.images || []).slice(0, MEDIA_KEEP).map(compactMediaEvent),
- videos: (rec.videos || []).slice(0, MEDIA_KEEP).map(compactMediaEvent), at: Date.now() }, key);
+ videos: (rec.videos || []).slice(0, MEDIA_KEEP).map(compactMediaEvent),
+ articles: (rec.articles || []).slice(0, ARTICLES_KEEP)
+ .map((e) => ({ ...e, content: String(e.content || '').slice(0, 100_000) })), at: Date.now() }, key);
});
} catch {}
}