this repo has no description
0
fork

Configure Feed

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

fix

alice 817e5b69 6e96c0b5

+34 -23
+14 -1
src/background/service-worker.ts
··· 21 21 try { 22 22 const result = await chrome.storage.local.get(DID_HANDLE_CACHE_KEY); 23 23 const stored = result[DID_HANDLE_CACHE_KEY] || {}; 24 - cache = new Map(Object.entries(stored)); 24 + // Keep only object-format entries (legacy strings are discarded) 25 + const entries = Object.entries(stored).filter( 26 + ([, entry]) => entry && typeof entry === 'object' 27 + ); 28 + cache = new Map(entries); 25 29 } catch (error) { 26 30 console.error('Failed to load cache:', error); 27 31 } ··· 124 128 125 129 // Handle messages from the popup 126 130 chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { 131 + if (request.type === 'UPDATE_CACHE' && request.did && request.handle) { 132 + updateCache(request.did, request.handle) 133 + .then(() => sendResponse({ success: true })) 134 + .catch((error) => { 135 + console.error('Failed to update cache via message:', error); 136 + sendResponse({ success: false, error: error.message }); 137 + }); 138 + return true; // Indicates async response 139 + } 127 140 if (request.type === 'CLEAR_CACHE') { 128 141 // Clear the in-memory cache 129 142 cache.clear();
+13 -22
src/popup/popup.ts
··· 37 37 let ds = window.WormholeTransform.buildDestinations(info); // Initial build (might be without handle) 38 38 render(ds); // Initial render 39 39 40 + 40 41 if (info.did && !info.handle) { 41 42 let handleToUse = null; 42 43 let errorStatusWasSet = false; // Flag to track if an error message was shown 44 + 43 45 const { didHandleCache = {} } = await chrome.storage.local.get('didHandleCache'); 44 - const cachedHandleValue = didHandleCache[info.did]; 45 - 46 - if (typeof cachedHandleValue === 'string') { 47 - handleToUse = cachedHandleValue; 46 + const cacheEntry = didHandleCache[info.did]; 47 + if (cacheEntry) { 48 + // Use the new object format from storage 49 + handleToUse = cacheEntry.handle; 50 + // Refresh lastAccessed in the SW cache 51 + await chrome.runtime.sendMessage({ type: 'UPDATE_CACHE', did: info.did, handle: handleToUse }); 48 52 } else { 49 - // Not a string in cache (or not present) 50 - if (cachedHandleValue !== undefined) { 51 - console.warn('Cached handle for DID', info.did, 'was not a string, re-fetching. Value:', cachedHandleValue); 52 - } 53 - 54 - // Show "Resolving..." status only if necessary. 55 - // (`!ds.length` implies nothing was renderable initially, `cachedHandleValue !== undefined` implies we are re-fetching a bad cache entry) 56 - if (!ds.length || cachedHandleValue !== undefined) { 57 - showStatus('Resolving...'); 58 - } 59 - 53 + // No cache entry: resolve DID via transform 54 + showStatus('Resolving...'); 60 55 try { 61 56 if (typeof window.WormholeTransform.resolveDidToHandle !== 'function') { 62 57 showStatus('Error: resolve fn missing'); 63 - errorStatusWasSet = true; // Set flag 64 - // handleToUse remains null 58 + errorStatusWasSet = true; 65 59 } else { 66 60 const freshHandle = await window.WormholeTransform.resolveDidToHandle(info.did); 67 61 if (freshHandle) { 68 62 handleToUse = freshHandle; 69 - // Update cache with the correct string format 70 - await chrome.storage.local.set({ didHandleCache: { ...didHandleCache, [info.did]: freshHandle } }); 63 + await chrome.runtime.sendMessage({ type: 'UPDATE_CACHE', did: info.did, handle: freshHandle }); 71 64 } 72 - // If freshHandle is null, handleToUse remains null (no specific error, just no handle found for DID) 73 65 } 74 66 } catch (err) { 75 67 console.error('Error resolving DID to handle:', err); 76 68 showStatus('Error resolving'); 77 - errorStatusWasSet = true; // Set flag 78 - // handleToUse remains null due to error 69 + errorStatusWasSet = true; 79 70 } 80 71 } 81 72
+7
src/shared/transform.ts
··· 32 32 } 33 33 } 34 34 35 + if (url.hostname === 'tangled.sh' && url.pathname.length > 1) { 36 + const handle = url.pathname.slice(1).replace(/^@/, ''); 37 + if (handle) { 38 + return await canonicalize(handle); 39 + } 40 + } 41 + 35 42 const qParam = url.searchParams.get('q'); 36 43 if (qParam && qParam.startsWith('did:')) { 37 44 return await canonicalize(qParam);