My personal website!
0
fork

Configure Feed

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

Removed caching of tracks since it's from my PDS

Koehn 98069ba9 00cdbead

+2 -21
-1
src/utils/structs.ts
··· 102 102 export type BannerItem = z.infer<typeof bannerItem>; 103 103 export type ProtocolResponse = z.infer<typeof protocolResponse>; 104 104 export type StandardDocument = z.infer<typeof standardDocument>; 105 - export type TealFMTrack = z.infer<typeof tealfmTrack>;
+2 -20
src/utils/tracks.ts
··· 1 1 import { listRecords } from "./atproto.ts"; 2 - import { type TealFMTrack, tealfmTrack } from "./structs.ts"; 3 - 4 - const cache: { 5 - tracks: TealFMTrack[] | null; 6 - fetchedAt: number; 7 - } = { 8 - tracks: null, 9 - fetchedAt: 0, 10 - }; 2 + import { tealfmTrack } from "./structs.ts"; 11 3 12 4 export async function fetchTracks() { 13 - const now = Date.now(); 14 - if (cache.tracks && now - cache.fetchedAt < 5 * 60 * 1000) { 15 - return cache.tracks; 16 - } 17 - 18 5 const response = await listRecords(["fm.teal.alpha.feed.play"]); 19 6 const trackMap = response.get("fm.teal.alpha.feed.play"); 20 7 ··· 22 9 throw new Error("[ERROR] No records found for fm.teal.alpha.feed.play"); 23 10 } 24 11 25 - const tracks = trackMap.records.map((r) => { 12 + return trackMap.records.map((r) => { 26 13 return tealfmTrack.parse(r.value); 27 14 }); 28 - 29 - cache.tracks = tracks; 30 - cache.fetchedAt = now; 31 - 32 - return tracks; 33 15 }