Skip to content

Commit

Permalink
if no links are found in daily digest, prompt user to reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerFisher committed Jan 12, 2025
1 parent da19ad1 commit 64c9d17
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 40 deletions.
52 changes: 36 additions & 16 deletions app/components/rss/RSSLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,42 @@ const RSSLinks = ({ links, name, digestUrl }: RSSLinksProps) => {

return (
<article>
<Heading as="h1">{today}</Heading>
<Text as="p">{intro(name)}</Text>
<Text as="p">{linkPlug(digestUrl)}</Text>
<Text as="p">
<hr />
</Text>
{links.map((linkPost, i) => (
<RSSLinkPost
key={linkPost.link?.url}
linkPost={linkPost}
digestUrl={digestUrl}
/>
))}
<Text as="p">
<Link href="https://sill.social/links">See all links on Sill</Link>
</Text>
{links.length === 0 ? (
<>
<Heading as="h1">Oops, no links!</Heading>
<Text as="p">
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,{" "}
<Link href="https://sill.social">log back into Sill</Link>. You may
be redirected to Bluesky or Mastodon to reauthorize Sill.
</Text>
<Text as="p">
If this doesn't work for you, please email{" "}
<Link href="mailto:[email protected]">[email protected]</Link>.
</Text>
</>
) : (
<>
<Heading as="h1">{today}</Heading>
<Text as="p">{intro(name)}</Text>
<Text as="p">{linkPlug(digestUrl)}</Text>
<Text as="p">
<hr />
</Text>
{links.map((linkPost, i) => (
<RSSLinkPost
key={linkPost.link?.url}
linkPost={linkPost}
digestUrl={digestUrl}
/>
))}
<Text as="p">
<Link href="https://sill.social/links">See all links on Sill</Link>
</Text>
</>
)}

<Text as="p">{digestOutro("https://sill.social/email")}</Text>
</article>
);
Expand Down
57 changes: 38 additions & 19 deletions app/emails/topLinks.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -27,26 +27,45 @@ const TopLinks = ({ links, name, digestUrl, layout }: TopLinksProps) => {

return (
<EmailLayout preview={preview(links)}>
<Heading as="h1">{title}</Heading>
<Heading as="h3" style={date}>
{today}
</Heading>
<Text>{intro(name)}</Text>
<Text>{linkPlug(digestUrl)}</Text>
{links.map((linkPost, i) => (
{links.length === 0 ? (
<>
<LinkPost
key={linkPost.link?.url}
linkPost={linkPost}
digestUrl={digestUrl}
layout={layout}
/>
{i < links.length - 1 && <Hr style={hr(layout)} />}
<Heading as="h1">Oops, no links!</Heading>
<Text>
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,{" "}
<Link href="https://sill.social">log back into Sill</Link>. You may
be redirected to Bluesky or Mastodon to reauthorize Sill.
</Text>
<Text>
If this doesn't work for you, please email{" "}
<Link href="mailto:[email protected]">[email protected]</Link>.
</Text>
</>
))}
<Button href="https://sill.social/links" style={button}>
See all links on Sill
</Button>
) : (
<>
<Heading as="h1">{title}</Heading>
<Heading as="h3" style={date}>
{today}
</Heading>
<Text>{intro(name)}</Text>
<Text>{linkPlug(digestUrl)}</Text>
{links.map((linkPost, i) => (
<>
<LinkPost
key={linkPost.link?.url}
linkPost={linkPost}
digestUrl={digestUrl}
layout={layout}
/>
{i < links.length - 1 && <Hr style={hr(layout)} />}
</>
))}
<Button href="https://sill.social/links" style={button}>
See all links on Sill
</Button>
</>
)}
<Text>{digestOutro("https://sill.social/email")}</Text>
</EmailLayout>
);
Expand Down
2 changes: 1 addition & 1 deletion app/routes/api/send-newsletter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const loader = async ({ request }: Route.LoaderArgs) => {
const emailBody = {
from: "Sill <[email protected]>",
to: dbUser.email,
subject: subject,
subject: links.length === 0 ? "No links found" : subject,
"o:tag": "digest",
...(await renderReactEmail(
<TopLinks
Expand Down
15 changes: 11 additions & 4 deletions app/routes/links/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ export const loader = async ({ request }: Route.LoaderArgs) => {
}
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;
Expand Down
3 changes: 3 additions & 0 deletions app/utils/digestText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 64c9d17

Please sign in to comment.