Retro Bulletin Board Systems on atproto. Web app and TUI. lazy mirror of alyraffauf/atbbs atbbs.xyz
forums python tui atproto bbs
3
fork

Configure Feed

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

web: invalidate bbs cache on write

+17 -5
+1 -1
web/src/lib/bbs.ts
··· 68 68 news: News[]; 69 69 } 70 70 71 - const CACHE_TTL = 5000; // 5 seconds — long enough for parent+child loaders 71 + const CACHE_TTL = 5 * 60 * 1000; // 5 minutes — invalidated explicitly on writes 72 72 let cache: { key: string; bbs: BBS; expires: number } | null = null; 73 73 74 74 export function invalidateBBSCache() {
+13 -4
web/src/lib/writes.ts
··· 2 2 3 3 import type { Client } from "@atcute/client"; 4 4 import { SITE, BOARD, NEWS, THREAD, REPLY, BAN, HIDE } from "./lexicon"; 5 + import { invalidateBBSCache } from "./bbs"; 5 6 import { nowIso } from "./util"; 6 7 import { getCurrentUser } from "./auth"; 7 8 import type { ··· 188 189 // --- Sysop: site, board, news --- 189 190 190 191 export async function putSite(rpc: Client, site: SiteValue) { 191 - return putRecord(rpc, SITE, "self", site); 192 + const resp = await putRecord(rpc, SITE, "self", site); 193 + invalidateBBSCache(); 194 + return resp; 192 195 } 193 196 194 197 export async function putBoard( ··· 203 206 description, 204 207 createdAt: createdAt as BoardValue["createdAt"], 205 208 }; 206 - return putRecord(rpc, BOARD, slug, value); 209 + const resp = await putRecord(rpc, BOARD, slug, value); 210 + invalidateBBSCache(); 211 + return resp; 207 212 } 208 213 209 214 export async function createNews( ··· 232 237 did: did as BanValue["did"], 233 238 createdAt: nowIso(), 234 239 }; 235 - return createRecord(rpc, BAN, value); 240 + const resp = await createRecord(rpc, BAN, value); 241 + invalidateBBSCache(); 242 + return resp; 236 243 } 237 244 238 245 export async function createHide(rpc: Client, uri: string) { ··· 240 247 uri: uri as HideValue["uri"], 241 248 createdAt: nowIso(), 242 249 }; 243 - return createRecord(rpc, HIDE, value); 250 + const resp = await createRecord(rpc, HIDE, value); 251 + invalidateBBSCache(); 252 + return resp; 244 253 }
+3
web/src/pages/SysopModerate.tsx
··· 3 3 import { useAuth } from "../lib/auth"; 4 4 import { resolveIdentity } from "../lib/atproto"; 5 5 import { BAN, HIDE } from "../lib/lexicon"; 6 + import { invalidateBBSCache } from "../lib/bbs"; 6 7 import HandleInput from "../components/HandleInput"; 7 8 import { useTitle } from "../hooks/useTitle"; 8 9 import { createBan, createHide, deleteRecord } from "../lib/writes"; ··· 49 50 if (!agent) return; 50 51 if (!confirm("Unban this user?")) return; 51 52 await deleteRecord(agent, BAN, rkey); 53 + invalidateBBSCache(); 52 54 revalidator.revalidate(); 53 55 } 54 56 ··· 68 70 if (!agent) return; 69 71 if (!confirm("Unhide this post?")) return; 70 72 await deleteRecord(agent, HIDE, rkey); 73 + invalidateBBSCache(); 71 74 revalidator.revalidate(); 72 75 } 73 76