@@ -30,10 +30,10 @@ async function search(searchTerm) {
3030 result = [ result ] ;
3131 }
3232
33- return await Promise . all ( result . map ( async lens => {
33+ return result . map ( lens => {
3434 lens . web_import = 1 ;
3535 return lens ;
36- } ) ) ;
36+ } ) ;
3737 } catch ( e ) {
3838 console . error ( e ) ;
3939 }
@@ -66,13 +66,18 @@ async function getLensByHash(uuid) {
6666}
6767
6868async function getUnlockByHash ( uuid ) {
69- let [ lens , archivedLens ] = await Promise . all ( [
69+ const [ lensResult , archivedLensResult ] = await Promise . allSettled ( [
7070 getLensByHash ( uuid ) ,
7171 Crawler . getLensByArchivedSnapshot ( uuid )
7272 ] ) ;
7373
74- lens = lens instanceof CrawlerFailure ? { } : lens ;
75- archivedLens = archivedLens instanceof CrawlerFailure ? { } : archivedLens ;
74+ const lens = lensResult . status === "fulfilled" && ! ( lensResult . value instanceof CrawlerFailure )
75+ ? lensResult . value
76+ : { } ;
77+
78+ const archivedLens = archivedLensResult . status === "fulfilled" && ! ( archivedLensResult . value instanceof CrawlerFailure )
79+ ? archivedLensResult . value
80+ : { } ;
7681
7782 const unlock = SnapLensWebCrawler . mergeLensItems ( archivedLens , lens ) ;
7883 if ( unlock && unlock . lens_id && unlock . lens_url ) {
@@ -89,8 +94,8 @@ async function mirrorSearchResults(webResults) {
8994 if ( webResults [ i ] . uuid ) {
9095 try {
9196 // object has both lens/unlock attributes on success (with more info)
92- const lens = await getLensByHash ( webResults [ i ] . uuid ) ;
93- if ( lens && lens . unlockable_id && lens . lens_name && lens . user_display_name ) {
97+ const lens = await getUnlockByHash ( webResults [ i ] . uuid ) ;
98+ if ( lens && lens . unlockable_id && lens . lens_name ) {
9499 await DB . insertLens ( lens ) ;
95100 } else {
96101 await DB . insertLens ( webResults [ i ] ) ;
0 commit comments