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.

ITS WORKING

+88 -1
+4 -1
README.md
··· 1 1 # Remember When 2 2 3 + I'll write one later. But this project shows your most popular post from a year ago on this day and lets you repost it 4 + 5 + 3 6 ## Notes for streaming 4 7 5 8 - DO NOT DOX YOURSELF ··· 11 14 - [x] input for the users handle or did 12 15 - [x] that input will look up the users posts for that day a year ago 13 16 - [x] show the posts using bluesky's embed (keep it nice and simple) 14 - - [ ] add in oauth login to repost the post 17 + - [x] add in oauth login to repost the post 15 18 - [ ] publish on tangled 16 19 - [ ] and then we might css.
+84
index.html
··· 33 33 </form> 34 34 <br /> 35 35 <button id="signInButton" type="button">Check yours</button> 36 + <button id="signOutButton" style="display: none" type="button"> 37 + Sign out 38 + </button> 36 39 37 40 <div id="postView"></div> 41 + <br /> 42 + 43 + <button id="remindOthers" style="display: none" type="button"> 44 + Remind others (reposts) 45 + </button> 38 46 </div> 39 47 40 48 <script type="module"> ··· 43 51 let atClient = null; 44 52 let loggedInDid = null; 45 53 let loggedInHandle = null; 54 + let rememberWhenPost = null; 46 55 47 56 import { 48 57 configureOAuth, ··· 139 148 const { session } = await finalizeAuthorization(params); 140 149 setAuthSession(session); 141 150 console.log(`Signed in as ${loggedInDid}`, "success"); 151 + updateAuthUI(); 152 + doWork(loggedInDid); 142 153 return; 143 154 } catch (err) { 144 155 // Hash might not be OAuth params, ignore ··· 159 170 "success", 160 171 ); 161 172 //todo load in page here 173 + updateAuthUI(); 174 + doWork(loggedInDid); 162 175 } catch (err) { 163 176 localStorage.removeItem("atproto_did"); 164 177 console.warn("Session resume failed:", err); ··· 222 235 } 223 236 } 224 237 238 + async function signOut() { 239 + try { 240 + if (agent) await agent.signOut(); 241 + } catch { 242 + if (loggedInDid) deleteStoredSession(loggedInDid); 243 + } 244 + localStorage.removeItem("atproto_did"); 245 + atClient = null; 246 + agent = null; 247 + loggedInDid = null; 248 + loggedInHandle = null; 249 + updateAuthUI(); 250 + console.log("Signed out"); 251 + } 252 + 253 + function updateAuthUI() { 254 + const signInButton = document.getElementById("signInButton"); 255 + const signOutButton = document.getElementById("signOutButton"); 256 + const remindOthersButton = 257 + document.getElementById("remindOthers"); 258 + if (loggedInDid) { 259 + signInButton.style.display = "none"; 260 + signOutButton.style.display = "block"; 261 + remindOthersButton.style.display = "block"; 262 + } else { 263 + signInButton.style.display = "block"; 264 + signOutButton.style.display = "none"; 265 + remindOthersButton.style.display = "none"; 266 + } 267 + } 268 + 225 269 async function findPostsFromThatDay(did, pds) { 226 270 try { 227 271 const thisDayLastYear = new Date(); ··· 290 334 const post = postsWithReactions 291 335 .sort((a, b) => b.totalReactions - a.totalReactions) 292 336 .slice(0, 1)[0]; 337 + rememberWhenPost = post; 293 338 let bskyPost = document.createElement("bluesky-post"); 294 339 bskyPost.setAttribute("src", post.uri); 295 340 document ··· 336 381 }; 337 382 } 338 383 384 + async function remindOthers() { 385 + try { 386 + console.log(rememberWhenPost); 387 + await atClient.post("com.atproto.repo.createRecord", { 388 + input: { 389 + repo: loggedInDid, 390 + collection: "app.bsky.feed.post", 391 + record: { 392 + $type: "app.bsky.feed.post", 393 + text: "Remember when?", 394 + embed: { 395 + $type: "app.bsky.embed.record", 396 + 397 + record: { 398 + cid: rememberWhenPost.cid, 399 + uri: rememberWhenPost.uri, 400 + }, 401 + }, 402 + langs: ["en"], 403 + createdAt: new Date().toISOString(), 404 + }, 405 + }, 406 + }); 407 + 408 + alert("Remember when post sent!"); 409 + } catch (err) { 410 + console.log(`Send failed: ${err.message}`, "error"); 411 + alert(`Send failed: ${err.message}`); 412 + console.error(err); 413 + } 414 + } 415 + 339 416 //Start up code on dom loaded 340 417 document.addEventListener("DOMContentLoaded", function () { 341 418 const lookUpForm = document.getElementById("lookupForm"); ··· 343 420 344 421 const signInButton = document.getElementById("signInButton"); 345 422 signInButton.addEventListener("click", signIn); 423 + 424 + const signOutButton = document.getElementById("signOutButton"); 425 + signOutButton.addEventListener("click", signOut); 426 + 427 + const remindOthersButton = 428 + document.getElementById("remindOthers"); 429 + remindOthersButton.addEventListener("click", remindOthers); 346 430 347 431 initAuth(); 348 432 });