the home of serif.blue
5
fork

Configure Feed

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

feat: make removing a user remove them from cache

+15 -28
+15 -28
bluesky-community-verifications.user.js
··· 68 68 return cacheEntry && Date.now() - cacheEntry.timestamp < CACHE_EXPIRY_TIME; 69 69 }; 70 70 71 + // Function to remove a specific user from the verification cache 72 + const removeUserFromCache = (handle) => { 73 + const cache = getVerificationCache(); 74 + if (cache[handle]) { 75 + delete cache[handle]; 76 + saveVerificationCache(cache); 77 + console.log(`Removed ${handle} from verification cache`); 78 + } 79 + }; 80 + 71 81 const clearCache = () => { 72 82 localStorage.removeItem(VERIFICATION_CACHE_STORAGE_KEY); 73 83 console.log("Verification cache cleared"); ··· 174 184 175 185 // If we have verifiers, display the badge 176 186 if (profileVerifiers.length > 0) { 177 - await displayVerificationBadge(profileVerifiers); 187 + displayVerificationBadge(profileVerifiers); 178 188 return true; 179 189 } 180 190 ··· 290 300 }); 291 301 }; 292 302 293 - const findProfileHeaderWithRetry = (retryCount = 0, maxRetries = 10) => { 303 + // Function to display verification badge on the profile 304 + const displayVerificationBadge = (verifierHandles) => { 305 + // Find the profile header or name element to add the badge to 294 306 const nameElements = document.querySelectorAll( 295 307 '[data-testid="profileHeaderDisplayName"]', 296 308 ); 297 309 const nameElement = nameElements[nameElements.length - 1]; 298 310 299 - if (nameElement) { 300 - console.log("Profile header found"); 301 - return nameElement; 302 - } 303 - if (retryCount < maxRetries) { 304 - // Retry with exponential backoff 305 - const delay = Math.min(100 * 1.5 ** retryCount, 2000); 306 - console.log( 307 - `Profile header not found, retrying in ${delay}ms (attempt ${retryCount + 1}/${maxRetries})`, 308 - ); 309 - 310 - return new Promise((resolve) => { 311 - setTimeout(() => { 312 - resolve(findProfileHeaderWithRetry(retryCount + 1, maxRetries)); 313 - }, delay); 314 - }); 315 - } 316 - console.log("Failed to find profile header after maximum retries"); 317 - return null; 318 - }; 319 - 320 - // Function to display verification badge on the profile 321 - const displayVerificationBadge = async (verifierHandles) => { 322 - // Find the profile header or name element to add the badge to 323 - const nameElement = await findProfileHeaderWithRetry(); 324 - 325 311 console.log(nameElement); 326 312 327 313 if (nameElement) { ··· 481 467 btn.addEventListener("click", (e) => { 482 468 const handle = e.target.getAttribute("data-handle"); 483 469 removeTrustedUser(handle); 470 + removeUserFromCache(handle); 484 471 updateTrustedUsersList(); 485 472 }); 486 473 }