your personal website on atproto - mirror blento.app

fix updated blentos cache

Florian 436ca9ac d0d10703

+6 -6
+4 -4
src/lib/cards/SpecialCards/UpdatedBlentos/index.ts
··· 6 6 export const UpdatedBlentosCardDefitition = { 7 7 type: 'updatedBlentos', 8 8 contentComponent: UpdatedBlentosCard, 9 - loadData: async (items, { platform }) => { 9 + loadData: async (items, { cache }) => { 10 10 try { 11 11 const response = await fetch( 12 12 'https://ufos-api.microcosm.blue/records?collection=app.blento.card' 13 13 ); 14 14 const recentRecords = await response.json(); 15 - const existingUsers = await platform?.env?.USER_DATA_CACHE?.get('updatedBlentos'); 15 + const existingUsers = await cache?.get('updatedBlentos'); 16 16 const existingUsersArray: ProfileViewDetailed[] = existingUsers 17 17 ? JSON.parse(existingUsers) 18 18 : []; ··· 34 34 35 35 const result = [...(await Promise.all(profiles)), ...existingUsersArray]; 36 36 37 - if (platform?.env?.USER_DATA_CACHE) { 38 - await platform?.env?.USER_DATA_CACHE.put('updatedBlentos', JSON.stringify(result)); 37 + if (cache) { 38 + await cache?.put('updatedBlentos', JSON.stringify(result)); 39 39 } 40 40 return JSON.parse(JSON.stringify(result)); 41 41 } catch (error) {
+2 -2
src/lib/cards/types.ts
··· 1 1 import type { Component } from 'svelte'; 2 - import type { Item } from '$lib/types'; 2 + import type { Item, UserCache } from '$lib/types'; 3 3 4 4 export type CreationModalComponentProps = { 5 5 item: Item; ··· 41 41 // optionally load some extra data 42 42 loadData?: ( 43 43 items: Item[], 44 - { did, handle, platform }: { did: string; handle: string; platform?: App.Platform } 44 + { did, handle, cache }: { did: string; handle: string; cache?: UserCache } 45 45 ) => Promise<unknown>; 46 46 47 47 // show color selection popup