Remember when you made an A+ post last year and everyone clapped bailey.tngl.io/remember-when
2
fork

Configure Feed

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

working without oauth

+55 -10
+1 -1
README.md
··· 10 10 11 11 - [x] input for the users handle or did 12 12 - [x] that input will look up the users posts for that day a year ago 13 - - [ ] show the posts using bluesky's embed (keep it nice and simple) 13 + - [x] show the posts using bluesky's embed (keep it nice and simple) 14 14 - [ ] add in oauth login to repost the post 15 15 - [ ] publish on tangled 16 16 - [ ] and then we might css.
+54 -9
index.html
··· 9 9 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bluesky-post-embed/themes/dim.css" 10 10 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bluesky-post-embed/themes/dark.css" 11 11 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bluesky-post-embed/themes/light.css" 12 - 13 - <script 14 - async 15 - src="https://embed.bsky.app/static/embed.js" 16 - charset="utf-8" 17 - ></script> 18 12 </head> 19 13 20 14 <body> ··· 68 62 }, 69 63 }); 70 64 65 + const constellationClient = new Client({ 66 + handler: simpleFetchHandler({ 67 + service: "https://constellation.microcosm.blue/", 68 + }), 69 + }); 70 + 71 71 async function lookupIdentifier(event) { 72 72 try { 73 73 event.preventDefault(); ··· 105 105 service: pds, 106 106 }), 107 107 }); 108 - // https://selfhosted.social/xrpc/com.atproto.repo.listRecords?repo=did%3Aplc%3Arnpkyqnmsw4ipey6eotbdnnf&collection=app.bsky.feed.post&limit=100&reverse=false&cursor=3lnmguhip222r 108 + 109 109 const response = await rpc.get( 110 110 "com.atproto.repo.listRecords", 111 111 { ··· 140 140 post.value.reply == null 141 141 ); 142 142 }); 143 - if (postsFromThatDay.length > 0) { 144 - const post = postsFromThatDay[0]; 143 + 144 + const postsWithReactions = await Promise.all(postsFromThatDay.map(async (post) => { 145 + const reactions = await getReactionCounts(post.uri); 146 + console.log(reactions) 147 + return { 148 + ...post, 149 + totalReactions: reactions.likes , 150 + }; 151 + })); 152 + 153 + if (postsWithReactions.length > 0) { 154 + const post = postsWithReactions.sort((a, b) => b.totalReactions - a.totalReactions).slice(0, 1)[0]; 145 155 let bskyPost = document.createElement("bluesky-post"); 146 156 bskyPost.setAttribute("src", post.uri); 147 157 document 148 158 .getElementById("postView") 149 159 .appendChild(bskyPost); 160 + }else{ 161 + alert("No posts found from that day :("); 150 162 } 151 163 } catch (e) { 152 164 console.error(e); 153 165 alert("Failed to find posts from that day: " + e.message); 154 166 } 155 167 } 168 + 169 + async function getReactionCounts(atUri){ 170 + const getLikes = await constellationClient.get( 171 + "blue.microcosm.links.getBacklinkDids", 172 + { 173 + params: { 174 + subject: atUri, 175 + source: "app.bsky.feed.like:subject.uri", 176 + }, 177 + }, 178 + ) 179 + 180 + const likes = getLikes.data.total; 181 + 182 + const getReposts = await constellationClient.get( 183 + "blue.microcosm.links.getBacklinkDids", 184 + { 185 + params: { 186 + subject: atUri, 187 + source: "app.bsky.feed.repost:subject.uri", 188 + }, 189 + }, 190 + ) 191 + 192 + const reposts = getReposts.data.total; 193 + 194 + return { 195 + likes, 196 + reposts, 197 + total: likes + reposts, 198 + }; 199 + } 200 + 156 201 157 202 //Start up code on dom loaded 158 203 document.addEventListener("DOMContentLoaded", function () {