Skip to content

Commit

Permalink
fix: posts throwing error for author.viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLunaHey committed Jan 9, 2025
1 parent 249ca19 commit 711a5b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/PostEmbed/app-bsky-embed-record-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export const AppBskyEmbedRecordView = ({ embed }: { embed: BSkyPostEmbed }) => {
? embed.record.author
: embed.record.creator;
if (!author) return <Debug value={embed.record} />;
if (author.viewer.blockedBy) {
if (author.viewer?.blockedBy) {
return (
<div className={cn('bg-white dark:bg-neutral-900 p-4 rounded-lg shadow')}>
<div className="text-gray-800 dark:text-gray-200 mb-3">{t('blockedByAuthor')}</div>
</div>
);
}
if (author.viewer.blocking) {
if (author.viewer?.blocking) {
return (
<div className={cn('bg-white dark:bg-neutral-900 p-4 rounded-lg shadow')}>
<div className="text-gray-800 dark:text-gray-200 mb-3">{t('blockedAuthor')}</div>
Expand Down
16 changes: 9 additions & 7 deletions src/lib/bluesky/types/Author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export const Author = Type.Object({
handle: Type.String(),
displayName: Type.String(),
avatar: Type.String(),
viewer: Type.Object({
muted: Type.Boolean(),
blockedBy: Type.Boolean(),
blocking: Type.Optional(Type.String()),
following: Type.Optional(Type.Union([Type.String(), Type.Undefined()])),
followedBy: Type.Optional(Type.Union([Type.String(), Type.Undefined()])),
}),
viewer: Type.Optional(
Type.Object({
muted: Type.Boolean(),
blockedBy: Type.Boolean(),
blocking: Type.Optional(Type.String()),
following: Type.Optional(Type.Union([Type.String(), Type.Undefined()])),
followedBy: Type.Optional(Type.Union([Type.String(), Type.Undefined()])),
}),
),
labels: Type.Array(BSkyPostLabel),
createdAt: Type.String(),
indexedAt: Type.Optional(Type.String()),
Expand Down

0 comments on commit 711a5b5

Please sign in to comment.