a tool for shared writing and social publishing
0
fork

Configure Feed

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

handle sign in in comments page

+26 -13
+8 -5
app/api/oauth/[route]/route.ts
··· 36 36 const handle = searchParams.get("handle") as string; 37 37 // Put originating page here! 38 38 let redirect = searchParams.get("redirect_url"); 39 + if (redirect) redirect = decodeURIComponent(redirect); 39 40 let action = parseActionFromSearchParam(searchParams.get("action")); 40 41 let state: OauthRequestClientState = { redirect, action }; 41 42 ··· 58 59 try { 59 60 const { session, state } = await client.callback(params); 60 61 let s: OauthRequestClientState = JSON.parse(state || "{}"); 61 - redirectPath = s.redirect || "/"; 62 + redirectPath = decodeURIComponent(s.redirect || "/"); 62 63 let { data: identity } = await supabaseServerClient 63 64 .from("identities") 64 65 .select() ··· 116 117 action: ActionAfterSignIn | null, 117 118 redirectPath: string, 118 119 ) => { 119 - let [base, pathparams] = redirectPath.split("?"); 120 - let searchParams = new URLSearchParams(pathparams); 120 + let url = new URL(decodeURIComponent(redirectPath), "https://example.com"); 121 121 if (action?.action === "subscribe") { 122 122 let result = await subscribeToPublication(action.publication); 123 123 console.log(result); 124 124 if (result.hasFeed === false) 125 - searchParams.set("showSubscribeSuccess", "true"); 125 + url.searchParams.set("showSubscribeSuccess", "true"); 126 126 } 127 127 128 - return redirect(base + "?" + searchParams.toString()); 128 + let path = url.pathname; 129 + if (url.search) path += url.search; 130 + if (url.hash) path += url.hash; 131 + return redirect(path); 129 132 };
+10 -5
app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx
··· 14 14 import { Popover } from "components/Popover"; 15 15 import { AppBskyActorProfile, AtUri } from "@atproto/api"; 16 16 import { timeAgo } from "app/discover/PubListing"; 17 + import { BlueskyLogin } from "app/login/LoginForm"; 18 + import { usePathname } from "next/navigation"; 17 19 18 20 export type Comment = { 19 21 record: Json; ··· 26 28 let comments = useMemo(() => { 27 29 return [...localComments, ...props.comments]; 28 30 }, [props.comments, localComments]); 31 + let pathname = usePathname(); 29 32 30 33 return ( 31 - <div className="flex flex-col gap-2 relative"> 34 + <div id={"commentsDrawer"} className="flex flex-col gap-2 relative"> 32 35 <div className="w-full flex justify-between text-secondary font-bold"> 33 36 Comments 34 37 <button ··· 41 44 {identity?.atp_did ? ( 42 45 <CommentBox doc_uri={props.document_uri} /> 43 46 ) : ( 44 - <div className="w-full accent-container text-tertiary text-center italic p-3"> 47 + <div className="w-full accent-container text-tertiary text-center italic p-3 flex flex-col gap-2"> 45 48 Connect a Bluesky account to comment 46 - <ButtonPrimary compact className="mx-auto mt-1"> 47 - <BlueskyTiny /> Connect to Bluesky 48 - </ButtonPrimary> 49 + <BlueskyLogin 50 + redirectRoute={ 51 + pathname + "?interactionDrawer=comments#commentsDrawer" 52 + } 53 + /> 49 54 </div> 50 55 )} 51 56 <hr className="border-border-light" />
+7 -2
app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx
··· 4 4 import { useInteractionState } from "./Interactions"; 5 5 import { Json } from "supabase/database.types"; 6 6 import { Comment, Comments } from "./Comments"; 7 + import { useSearchParams } from "next/navigation"; 7 8 8 9 export const InteractionDrawer = (props: { 9 10 document_uri: string; ··· 11 12 comments: Comment[]; 12 13 did: string; 13 14 }) => { 15 + let params = useSearchParams(); 16 + let interactionDrawerSearchParam = params.get("interactionDrawer"); 14 17 let { drawerOpen: open, drawer } = useInteractionState(); 15 - if (!open) return null; 18 + if (open === false || (open === undefined && !interactionDrawerSearchParam)) 19 + return null; 20 + let currentDrawer = drawer || interactionDrawerSearchParam; 16 21 return ( 17 22 <> 18 23 <div className="sm:pr-4 pr-[6px] snap-center"> ··· 21 26 id="interaction-drawer" 22 27 className="opaque-container !rounded-lg h-full w-full px-3 sm:px-4 pt-2 sm:pt-3 pb-6 overflow-scroll " 23 28 > 24 - {drawer === "quotes" ? ( 29 + {currentDrawer === "quotes" ? ( 25 30 <Quotes {...props} /> 26 31 ) : ( 27 32 <Comments
+1 -1
app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx
··· 7 7 import type { Comment } from "./Comments"; 8 8 9 9 export let useInteractionState = create(() => ({ 10 - drawerOpen: false, 10 + drawerOpen: undefined as boolean | undefined, 11 11 drawer: undefined as undefined | "comments" | "quotes", 12 12 localComments: [] as Comment[], 13 13 }));