your personal website on atproto - mirror blento.app

small fixes

+24 -18
+19 -14
src/lib/cache.ts
··· 1 + import type { ActorIdentifier, Did } from '@atcute/lexicons'; 2 + import { isDid } from '@atcute/lexicons/syntax'; 1 3 import type { KVNamespace } from '@cloudflare/workers-types'; 2 4 3 5 /** TTL in seconds for each cache namespace */ 4 6 const NAMESPACE_TTL = { 5 - user: 60 * 60 * 24, // 24 hours 7 + blento: 60 * 60 * 24, // 24 hours 6 8 identity: 60 * 60 * 24 * 7, // 7 days 7 9 github: 60 * 60 * 12, // 12 hours 8 10 'gh-contrib': 60 * 60 * 12, // 12 hours ··· 22 24 return this.kv.get(`${namespace}:${key}`); 23 25 } 24 26 25 - async put(namespace: CacheNamespace, key: string, value: string, ttlSeconds?: number): Promise<void> { 27 + async put( 28 + namespace: CacheNamespace, 29 + key: string, 30 + value: string, 31 + ttlSeconds?: number 32 + ): Promise<void> { 26 33 const ttl = ttlSeconds ?? NAMESPACE_TTL[namespace] ?? 0; 27 34 await this.kv.put(`${namespace}:${key}`, value, ttl > 0 ? { expirationTtl: ttl } : undefined); 28 35 } ··· 54 61 await this.put(namespace, key, JSON.stringify(value), ttlSeconds); 55 62 } 56 63 57 - // === User data (keyed by DID, with handle↔did resolution) === 58 - 59 - async getUser(identifier: string): Promise<string | null> { 64 + // === blento data (keyed by DID, with handle↔did resolution) === 65 + async getBlento(identifier: ActorIdentifier): Promise<string | null> { 60 66 const did = await this.resolveDid(identifier); 61 67 if (!did) return null; 62 - return this.get('user', did); 68 + return this.get('blento', did); 63 69 } 64 70 65 - async putUser(did: string, handle: string, data: string): Promise<void> { 71 + async putBlento(did: string, handle: string, data: string): Promise<void> { 66 72 await Promise.all([ 67 - this.put('user', did, data), 73 + this.put('blento', did, data), 68 74 this.put('identity', `h:${handle}`, did), 69 75 this.put('identity', `d:${did}`, handle) 70 76 ]); 71 77 } 72 78 73 - async listUsers(): Promise<string[]> { 74 - return this.list('user'); 79 + async listBlentos(): Promise<string[]> { 80 + return this.list('blento'); 75 81 } 76 82 77 83 // === Identity resolution === 78 - 79 - async resolveDid(identifier: string): Promise<string | null> { 80 - if (identifier.startsWith('did:')) return identifier; 84 + async resolveDid(identifier: ActorIdentifier): Promise<string | null> { 85 + if (isDid(identifier)) return identifier; 81 86 return this.get('identity', `h:${identifier}`); 82 87 } 83 88 84 - async resolveHandle(did: string): Promise<string | null> { 89 + async resolveHandle(did: Did): Promise<string | null> { 85 90 return this.get('identity', `d:${did}`); 86 91 } 87 92 }
+2 -1
src/lib/layout/EditableGrid.svelte
··· 373 373 ondrop={handleFileDrop} 374 374 /> 375 375 376 - <!-- svelte-ignore a11y_no_static_element_interactions a11y_click_events_have_key_events --> 376 + <!-- svelte-ignore a11y_no_static_element_interactions --> 377 + <!-- svelte-ignore a11y_click_events_have_key_events --> 377 378 <div 378 379 bind:this={container} 379 380 onpointerdown={handlePointerDown}
+3 -3
src/lib/website/load.ts
··· 10 10 11 11 const CURRENT_CACHE_VERSION = 1; 12 12 13 - export async function getCache(identifier: string, page: string, cache?: CacheService) { 13 + export async function getCache(identifier: ActorIdentifier, page: string, cache?: CacheService) { 14 14 try { 15 - const cachedResult = await cache?.getUser(identifier); 15 + const cachedResult = await cache?.getBlento(identifier); 16 16 17 17 if (!cachedResult) return; 18 18 const result = JSON.parse(cachedResult); ··· 134 134 // Only cache results that have cards to avoid caching PDS errors 135 135 if (result.cards.length > 0) { 136 136 const stringifiedResult = JSON.stringify(result); 137 - await cache?.putUser(did, handle as string, stringifiedResult); 137 + await cache?.putBlento(did, handle as string, stringifiedResult); 138 138 } 139 139 140 140 const parsedResult = structuredClone(result) as any;