[Embeds] Show error for users with PWI flag on landing (#3524)
parent
4c966e5d6d
commit
a845587e1f
|
@ -86,7 +86,14 @@ function LandingPage() {
|
||||||
if (!AppBskyFeedDefs.isThreadViewPost(data.thread)) {
|
if (!AppBskyFeedDefs.isThreadViewPost(data.thread)) {
|
||||||
throw new Error('Post not found')
|
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)
|
setThread(data.thread)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
@ -113,25 +120,15 @@ function LandingPage() {
|
||||||
className="border rounded-lg py-3 w-full max-w-[600px] px-4"
|
className="border rounded-lg py-3 w-full max-w-[600px] px-4"
|
||||||
placeholder={DEFAULT_POST}
|
placeholder={DEFAULT_POST}
|
||||||
/>
|
/>
|
||||||
<p className={`text-red-500 ${error ? '' : 'invisible'}`}>{error}</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<img src={arrowBottom as string} className="w-6" />
|
<img src={arrowBottom as string} className="w-6" />
|
||||||
|
|
||||||
<div className="w-full max-w-[600px] gap-8 flex flex-col">
|
<div className="w-full max-w-[600px] gap-8 flex flex-col">
|
||||||
{uri && !error && thread && <Snippet thread={thread} />}
|
{uri && !error && thread && <Snippet thread={thread} />}
|
||||||
|
{!error && thread && <Post thread={thread} key={thread.post.uri} />}
|
||||||
{thread ? (
|
{error && (
|
||||||
<Post thread={thread} key={thread.post.uri} />
|
<p className={`text-red-500 ${error ? '' : 'invisible'}`}>{error}</p>
|
||||||
) : (
|
|
||||||
<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>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
Loading…
Reference in New Issue