this repo has no description
32
fork

Configure Feed

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

Normalize nested repo listRecords responses

authored by

alice and committed by tangled.org a18fcdbd 44dce6e0

+18 -1
+18 -1
src/browser/lib/dual-api.mjs
··· 40 40 return { ok: res.ok, status: res.status, url: res.url }; 41 41 }; 42 42 43 + const normalizeRepoRecord = (record) => { 44 + if ( 45 + record && 46 + record.value && 47 + typeof record.value === 'object' && 48 + record.value.value && 49 + typeof record.value.value === 'object' && 50 + typeof record.value.value.$type === 'string' 51 + ) { 52 + return { 53 + ...record, 54 + value: record.value.value, 55 + }; 56 + } 57 + return record; 58 + }; 59 + 43 60 const xrpcJson = async (nsid, { method = 'GET', token, params, body, timeoutMs, pdsUrl } = {}) => { 44 61 const basePdsUrl = pdsUrl || config.pdsUrl; 45 62 const url = new URL(`${basePdsUrl}/xrpc/${nsid}`); ··· 91 108 `listRecords failed for ${account.handle} collection ${collection}: ${result.status} ${result.text}`, 92 109 ); 93 110 } 94 - return result.json?.records || []; 111 + return (result.json?.records || []).map(normalizeRepoRecord); 95 112 }; 96 113 97 114 const listOwnPosts = async (account, limit = 100) =>