diff --git a/src/components/Composer.tsx b/src/components/Composer.tsx index 9432989..abbcb96 100644 --- a/src/components/Composer.tsx +++ b/src/components/Composer.tsx @@ -111,7 +111,7 @@ export function Composer() { c: pollData.c || undefined, d: pollData.d || undefined, expiry: pollData.expiry, - multiple: false, + multiple: true, }); if (dataUrl) { @@ -204,8 +204,7 @@ export function Composer() { b: pollData.b, c: pollData.c || undefined, d: pollData.d || undefined, - expiry: pollData.expiry.toISOString(), - multiple: false, + multiple: true, createdAt: new Date().toISOString(), }; @@ -452,14 +451,14 @@ function PollCreator({ onChange((prev: any) => ({ ...prev, [field]: val })); }; - const handleDuration = (val: string) => { - const hours = parseInt(val, 10); - onChange((prev: any) => ({ - ...prev, - duration: val, - expiry: addHours(new Date(), hours), - })); - }; + // const handleDuration = (val: string) => { + // const hours = parseInt(val, 10); + // onChange((prev: any) => ({ + // ...prev, + // duration: val, + // expiry: addHours(new Date(), hours), + // })); + // }; return (
@@ -523,7 +522,7 @@ function PollCreator({
-
+ {/*
@@ -551,7 +550,7 @@ function PollCreator({
- + */} ); } diff --git a/src/components/OGPoll.tsx b/src/components/OGPoll.tsx index 4f12b2f..ef15dbc 100644 --- a/src/components/OGPoll.tsx +++ b/src/components/OGPoll.tsx @@ -10,7 +10,7 @@ interface RawOGCProps { b: string; c?: string; d?: string; - expiry: Date; + expiry?: Date; } export function RawOGC({ @@ -24,7 +24,7 @@ export function RawOGC({ }: RawOGCProps) { const options = [a, b, c, d].filter((opt): opt is string => !!opt); - const formattedDate = expiry.toLocaleDateString('en-US', { + const formattedDate = expiry?.toLocaleDateString('en-US', { month: 'short', day: 'numeric', hour: 'numeric', @@ -46,7 +46,7 @@ export function RawOGC({ {/* Multiplicity */} - {multiple ? 'Select multiple options' : 'Select one option'} + {multiple || !privateProviderHandle ? 'Select multiple options' : 'Select one option'} @@ -67,7 +67,7 @@ export function RawOGC({ {/* Expiry */}
- Expires {formattedDate} + {!formattedDate || !privateProviderHandle ? (Never expires) : (Expires {formattedDate})}
{/* Branding */} diff --git a/src/components/UniversalPostRenderer.tsx b/src/components/UniversalPostRenderer.tsx index a2b1fac..10bb9e0 100644 --- a/src/components/UniversalPostRenderer.tsx +++ b/src/components/UniversalPostRenderer.tsx @@ -411,7 +411,7 @@ export function UniversalPostRendererATURILoader({ setReplies( links ? links?.links?.["app.bsky.feed.post"]?.[".reply.parent.uri"] - ?.records || 0 + ?.records || 0 : null, ); }, [links]); @@ -459,13 +459,13 @@ export function UniversalPostRendererATURILoader({ const replyAturis = repliesData ? repliesData.pages.flatMap((page) => - page - ? page.linking_records.map((record) => { - const aturi = `at://${record.did}/${record.collection}/${record.rkey}`; - return aturi; - }) - : [], - ) + page + ? page.linking_records.map((record) => { + const aturi = `at://${record.did}/${record.collection}/${record.rkey}`; + return aturi; + }) + : [], + ) : []; //const [oldestOpsReply, setOldestOpsReply] = useState(undefined); @@ -625,7 +625,7 @@ function MoreReplies({ atUri }: { atUri: string }) { opacity: 0.5, }} className="dark:bg-[repeating-linear-gradient(to_bottom,var(--color-gray-500)_0,var(--color-gray-400)_4px,transparent_4px,transparent_8px)]" - //className="border-gray-400 dark:border-gray-500" + //className="border-gray-400 dark:border-gray-500" /> @@ -771,11 +771,11 @@ export function UniversalPostRendererRawRecordShim({ const isQuotewithImages = isquotewithmedia && (hasEmbed as ATPAPI.AppBskyEmbedRecordWithMedia.Main)?.media?.$type === - "app.bsky.embed.images"; + "app.bsky.embed.images"; const isQuotewithVideo = isquotewithmedia && (hasEmbed as ATPAPI.AppBskyEmbedRecordWithMedia.Main)?.media?.$type === - "app.bsky.embed.video"; + "app.bsky.embed.video"; const hasMedia = hasEmbed && @@ -1493,18 +1493,18 @@ function UniversalPostRenderer({ const tags = unfediwafrnTags ? unfediwafrnTags - .split("\n") - .map((t) => t.trim()) - .filter(Boolean) + .split("\n") + .map((t) => t.trim()) + .filter(Boolean) : undefined; const links = tags ? tags - .map((tag) => { - const encoded = encodeURIComponent(tag); - return `#${tag.replaceAll(" ", "-")}`; - }) - .join("
") + .map((tag) => { + const encoded = encodeURIComponent(tag); + return `#${tag.replaceAll(" ", "-")}`; + }) + .join("
") : ""; const unfediwafrn = unfediwafrnPartial @@ -1517,7 +1517,7 @@ function UniversalPostRenderer({ /* fuck you */ const isMainItem = false; - const setMainItem = (any: any) => {}; + const setMainItem = (any: any) => { }; // eslint-disable-next-line react-hooks/refs //console.log("Received ref in UniversalPostRenderer:", usedref); return ( @@ -1531,12 +1531,12 @@ function UniversalPostRenderer({ : setMainItem ? onPostClick ? (e) => { - setMainItem({ post: post }); - onPostClick(e); - } + setMainItem({ post: post }); + onPostClick(e); + } : () => { - setMainItem({ post: post }); - } + setMainItem({ post: post }); + } : undefined } style={{ @@ -2019,10 +2019,10 @@ function UniversalPostRenderer({ try { await navigator.clipboard.writeText( "https://bsky.app" + - "/profile/" + - post.author.handle + - "/post/" + - post.uri.split("/").pop(), + "/profile/" + + post.author.handle + + "/post/" + + post.uri.split("/").pop(), ); renderSnack({ title: "Copied to clipboard!", @@ -2130,7 +2130,7 @@ type Embed = | AppBskyEmbedVideo.View | AppBskyEmbedExternal.View | AppBskyEmbedRecordWithMedia.View - | { $type: string; [k: string]: unknown }; + | { $type: string;[k: string]: unknown }; enum PostEmbedViewContext { ThreadHighlighted = "ThreadHighlighted", @@ -2226,44 +2226,44 @@ function PollEmbed({ did, rkey }: { did: string; rkey: string }) { const userVotesA = useGetOneToOneState( agent?.did ? { - target: pollUri, - user: agent?.did, - collection: "app.reddwarf.poll.vote.a", - path: ".subject.uri", - } + target: pollUri, + user: agent?.did, + collection: "app.reddwarf.poll.vote.a", + path: ".subject.uri", + } : undefined, ); const userVotesB = useGetOneToOneState( agent?.did ? { - target: pollUri, - user: agent?.did, - collection: "app.reddwarf.poll.vote.b", - path: ".subject.uri", - } + target: pollUri, + user: agent?.did, + collection: "app.reddwarf.poll.vote.b", + path: ".subject.uri", + } : undefined, ); const userVotesC = useGetOneToOneState( agent?.did ? { - target: pollUri, - user: agent?.did, - collection: "app.reddwarf.poll.vote.c", - path: ".subject.uri", - } + target: pollUri, + user: agent?.did, + collection: "app.reddwarf.poll.vote.c", + path: ".subject.uri", + } : undefined, ); const userVotesD = useGetOneToOneState( agent?.did ? { - target: pollUri, - user: agent?.did, - collection: "app.reddwarf.poll.vote.d", - path: ".subject.uri", - } + target: pollUri, + user: agent?.did, + collection: "app.reddwarf.poll.vote.d", + path: ".subject.uri", + } : undefined, ); @@ -2297,16 +2297,19 @@ function PollEmbed({ did, rkey }: { did: string; rkey: string }) { }; const options = [poll.a, poll.b, poll.c, poll.d].filter(Boolean); - const isExpired = poll.expiry ? new Date(poll.expiry) < new Date() : false; - - const formattedDate = poll.expiry - ? new Date(poll.expiry).toLocaleDateString("en-US", { - month: "short", - day: "numeric", - hour: "numeric", - minute: "2-digit", - }) - : null; + const isExpired = false //poll.expiry ? new Date(poll.expiry) < new Date() : false; + + // todo unused waiting for private polls + // undefined for public polls which equals never expires + const formattedDate = undefined; + // const formattedDate = poll.expiry + // ? new Date(poll.expiry).toLocaleDateString("en-US", { + // month: "short", + // day: "numeric", + // hour: "numeric", + // minute: "2-digit", + // }) + // : null; // Calculate vote counts const voteData = [ @@ -2467,13 +2470,12 @@ function PollEmbed({ did, rkey }: { did: string; rkey: string }) { return (
!isExpired && handleVote(optionKey)} > {/* Vote percentage bar - always show */} @@ -2504,12 +2506,13 @@ function PollEmbed({ did, rkey }: { did: string; rkey: string }) { {/* Footer */}
{/* Expiry */} - {formattedDate && !isExpired && ( -
- +
+ + {/* Expires {formattedDate} */} + {formattedDate ? !isExpired ? ( Expires {formattedDate} -
- )} + ) : (Expired at {formattedDate}) : Never expires} +
{/* Status */}
@@ -2846,10 +2849,10 @@ function PostEmbeds({ width: "100%", aspectRatio: image.aspectRatio ? (() => { - const { width, height } = image.aspectRatio; - const ratio = width / height; - return ratio < 0.5 ? "1 / 2" : `${width} / ${height}`; - })() + const { width, height } = image.aspectRatio; + const ratio = width / height; + return ratio < 0.5 ? "1 / 2" : `${width} / ${height}`; + })() : "1 / 1", // fallback to square //backgroundColor: theme.background, // fallback letterboxing color borderRadius: 12, @@ -3547,9 +3550,8 @@ const SmartHLSPlayer = ({ borderRadius: 12, overflow: "hidden", //border: `1px solid ${theme.border}`, - paddingTop: `${ - 100 / (aspect ? aspect.width / aspect.height : 16 / 9) - }%`, // 16:9 = 56.25%, 4:3 = 75% + paddingTop: `${100 / (aspect ? aspect.width / aspect.height : 16 / 9) + }%`, // 16:9 = 56.25%, 4:3 = 75% }} className="border border-gray-200 dark:border-gray-800 was7" >