From 64c9d17cf0f09d1e44c2f7820e8718b04de22b7b Mon Sep 17 00:00:00 2001 From: Tyler Fisher Date: Sun, 12 Jan 2025 18:18:36 -0500 Subject: [PATCH] if no links are found in daily digest, prompt user to reconnect --- app/components/rss/RSSLinks.tsx | 52 ++++++++++++++++++--------- app/emails/topLinks.tsx | 57 ++++++++++++++++++++---------- app/routes/api/send-newsletter.tsx | 2 +- app/routes/links/index.tsx | 15 +++++--- app/utils/digestText.tsx | 3 ++ 5 files changed, 89 insertions(+), 40 deletions(-) diff --git a/app/components/rss/RSSLinks.tsx b/app/components/rss/RSSLinks.tsx index 8c9c736..711de1d 100644 --- a/app/components/rss/RSSLinks.tsx +++ b/app/components/rss/RSSLinks.tsx @@ -19,22 +19,42 @@ const RSSLinks = ({ links, name, digestUrl }: RSSLinksProps) => { return (
- {today} - {intro(name)} - {linkPlug(digestUrl)} - -
-
- {links.map((linkPost, i) => ( - - ))} - - See all links on Sill - + {links.length === 0 ? ( + <> + Oops, no links! + + It looks like Sill doesn't have any links for you. This is likely + because Sill got out of sync with your Bluesky and/or Mastodon + accounts. To address this,{" "} + log back into Sill. You may + be redirected to Bluesky or Mastodon to reauthorize Sill. + + + If this doesn't work for you, please email{" "} + tyler@sill.social. + + + ) : ( + <> + {today} + {intro(name)} + {linkPlug(digestUrl)} + +
+
+ {links.map((linkPost, i) => ( + + ))} + + See all links on Sill + + + )} + {digestOutro("https://sill.social/email")}
); diff --git a/app/emails/topLinks.tsx b/app/emails/topLinks.tsx index ff5a3c5..a93e426 100644 --- a/app/emails/topLinks.tsx +++ b/app/emails/topLinks.tsx @@ -1,4 +1,4 @@ -import { Button, Heading, Hr, Text } from "@react-email/components"; +import { Button, Heading, Hr, Link, Text } from "@react-email/components"; import EmailLayout from "~/components/emails/Layout"; import LinkPost from "~/components/emails/LinkPost"; import { @@ -27,26 +27,45 @@ const TopLinks = ({ links, name, digestUrl, layout }: TopLinksProps) => { return ( - {title} - - {today} - - {intro(name)} - {linkPlug(digestUrl)} - {links.map((linkPost, i) => ( + {links.length === 0 ? ( <> - - {i < links.length - 1 &&
} + Oops, no links! + + It looks like Sill doesn't have any links for you. This is likely + because Sill got out of sync with your Bluesky and/or Mastodon + accounts. To address this,{" "} + log back into Sill. You may + be redirected to Bluesky or Mastodon to reauthorize Sill. + + + If this doesn't work for you, please email{" "} + tyler@sill.social. + - ))} - + ) : ( + <> + {title} + + {today} + + {intro(name)} + {linkPlug(digestUrl)} + {links.map((linkPost, i) => ( + <> + + {i < links.length - 1 &&
} + + ))} + + + )} {digestOutro("https://sill.social/email")}
); diff --git a/app/routes/api/send-newsletter.tsx b/app/routes/api/send-newsletter.tsx index fe96d57..3174645 100644 --- a/app/routes/api/send-newsletter.tsx +++ b/app/routes/api/send-newsletter.tsx @@ -88,7 +88,7 @@ export const loader = async ({ request }: Route.LoaderArgs) => { const emailBody = { from: "Sill ", to: dbUser.email, - subject: subject, + subject: links.length === 0 ? "No links found" : subject, "o:tag": "digest", ...(await renderReactEmail( { } if (error instanceof TokenRefreshError) { const client = await createOAuthClient(); - const url = await client.authorize(bsky.did, { - scope: "atproto transition:generic", - }); - return redirect(url.toString()) as never; + try { + const url = await client.authorize(bsky.handle, { + scope: "atproto transition:generic", + }); + return redirect(url.toString()) as never; + } catch (error) { + const url = await client.authorize(bsky.did, { + scope: "atproto transition:generic", + }); + return redirect(url.toString()) as never; + } } if (error instanceof OAuthResolverError) { return redirect("/connect?error=resolver") as never; diff --git a/app/utils/digestText.tsx b/app/utils/digestText.tsx index b17b0d6..0b45aa0 100644 --- a/app/utils/digestText.tsx +++ b/app/utils/digestText.tsx @@ -2,6 +2,9 @@ import type { MostRecentLinkPosts } from "./links.server"; export const subject = "Your Sill Daily Digest"; export const preview = (linkPosts: MostRecentLinkPosts[]) => { + if (linkPosts.length === 0) { + return "Sill is having trouble syncing with your Bluesky and/or Mastodon accounts"; + } const hosts = linkPosts .map((linkPost) => new URL(linkPost.link?.url || "").hostname) .slice(0, 3);