Skip to content

Commit

Permalink
[Embeds] Show error for users with PWI flag on landing (#3524)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Apr 13, 2024
1 parent 4c966e5 commit a845587
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions bskyembed/src/screens/landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ function LandingPage() {
if (!AppBskyFeedDefs.isThreadViewPost(data.thread)) {
throw new Error('Post not found')
}

const pwiOptOut = !!data.thread.post.author.labels?.find(
label => label.val === '!no-unauthenticated',
)
if (pwiOptOut) {
throw new Error(
'The author of this post has requested their posts not be displayed on external sites.',
)
}
setThread(data.thread)
} catch (err) {
console.error(err)
Expand All @@ -113,25 +120,15 @@ function LandingPage() {
className="border rounded-lg py-3 w-full max-w-[600px] px-4"
placeholder={DEFAULT_POST}
/>
<p className={`text-red-500 ${error ? '' : 'invisible'}`}>{error}</p>
</div>

<img src={arrowBottom as string} className="w-6" />

<div className="w-full max-w-[600px] gap-8 flex flex-col">
{uri && !error && thread && <Snippet thread={thread} />}

{thread ? (
<Post thread={thread} key={thread.post.uri} />
) : (
<Container href="https://bsky.social/about">
<Link
href="https://bsky.social/about"
className="transition-transform hover:scale-110 absolute top-4 right-4">
<img src={logo as string} className="h-8" />
</Link>
<div className="h-32" />
</Container>
{!error && thread && <Post thread={thread} key={thread.post.uri} />}
{error && (
<p className={`text-red-500 ${error ? '' : 'invisible'}`}>{error}</p>
)}
</div>
</main>
Expand Down

0 comments on commit a845587

Please sign in to comment.