Skip to content

Commit c73892e

Browse files
committed
Merge branch 'preview'
2 parents a7a8f90 + 0019538 commit c73892e

File tree

13 files changed

+354
-199
lines changed

13 files changed

+354
-199
lines changed

package-lock.json

Lines changed: 237 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@atproto/api": "^0.13.5",
13-
"@radix-ui/react-dialog": "^1.1.1",
14-
"@radix-ui/react-dropdown-menu": "^2.1.1",
15-
"@radix-ui/react-hover-card": "^1.1.1",
16-
"@radix-ui/react-popover": "^1.1.1",
17-
"@radix-ui/react-radio-group": "^1.2.0",
18-
"@radix-ui/react-scroll-area": "^1.1.0",
19-
"@radix-ui/react-switch": "^1.1.0",
12+
"@atproto/api": "^0.13.11",
13+
"@radix-ui/react-dialog": "^1.1.2",
14+
"@radix-ui/react-dropdown-menu": "^2.1.2",
15+
"@radix-ui/react-hover-card": "^1.1.2",
16+
"@radix-ui/react-popover": "^1.1.2",
17+
"@radix-ui/react-radio-group": "^1.2.1",
18+
"@radix-ui/react-scroll-area": "^1.2.0",
19+
"@radix-ui/react-switch": "^1.1.1",
2020
"@radix-ui/react-toggle-group": "^1.1.0",
21-
"@radix-ui/react-tooltip": "^1.1.2",
21+
"@radix-ui/react-tooltip": "^1.1.3",
2222
"@tanstack/react-query": "^5.55.4",
2323
"@tiptap/extension-character-count": "2.1.16",
2424
"@tiptap/extension-link": "2.1.16",

src/components/contentDisplay/profileHeader/ProfileHeader.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import FollowInfo from "@/components/dataDisplay/followInfo/FollowInfo";
3+
import UserStats from "@/components/dataDisplay/userStats/UserStats";
44
import FallbackAvatar from "@/assets/images/fallbackAvatar.png";
55
import FallbackBanner from "@/assets/images/fallbackBanner.png";
66
import Image from "next/image";
@@ -20,6 +20,7 @@ import usePreferences from "@/lib/hooks/bsky/actor/usePreferences";
2020
import EditProfile from "@/components/actions/editProfile/EditProfile";
2121
import { isInvalidHandle } from "@/lib/utils/text";
2222
import KnownFollowers from "@/components/dataDisplay/knownFollowers/KnownFollowers";
23+
import JoinedDate from "@/components/dataDisplay/joinedDate/JoinedDate";
2324

2425
interface Props {
2526
handle: string;
@@ -30,6 +31,7 @@ export default function ProfileHeader(props: Props) {
3031
const [showAvatar, setShowAvatar] = useState(false);
3132
const [showBanner, setShowBanner] = useState(false);
3233
const { data: session } = useSession();
34+
3335
const {
3436
data: profile,
3537
isLoading,
@@ -157,12 +159,20 @@ export default function ProfileHeader(props: Props) {
157159
{profile?.description && (
158160
<ProfileBio description={profile.description} />
159161
)}
162+
163+
{profile.createdAt && (
164+
<div className="my-2">
165+
<JoinedDate date={new Date(profile.createdAt)} />
166+
</div>
167+
)}
168+
160169
{profile?.handle && (
161170
<div className="mt-2">
162-
<FollowInfo
171+
<UserStats
163172
handle={profile?.handle}
164-
followersCount={profile?.followersCount ?? 0}
165-
followsCount={profile?.followsCount ?? 0}
173+
followerCount={profile?.followersCount ?? 0}
174+
followCount={profile?.followsCount ?? 0}
175+
postsCount={profile.postsCount ?? 0}
166176
/>
167177
</div>
168178
)}

src/components/contentDisplay/profileHoverCard/PorileHoverContent.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Avatar from "@/components/dataDisplay/avatar/Avatar";
2-
import FollowInfo from "@/components/dataDisplay/followInfo/FollowInfo";
2+
import UserStats from "@/components/dataDisplay/userStats/UserStats";
33
import ProfileBio from "@/components/dataDisplay/profileBio/ProfileBio";
44
import ViewerInfo from "@/components/dataDisplay/viewerInfo/ViewerInfo";
55
import useProfile from "@/lib/hooks/bsky/actor/useProfile";
@@ -77,10 +77,11 @@ export default function ProfileHoverContent(props: Props) {
7777
</div>
7878
</div>
7979
{profile?.handle && (
80-
<FollowInfo
80+
<UserStats
8181
handle={profile?.handle}
82-
followersCount={profile?.followersCount ?? 0}
83-
followsCount={profile?.followsCount ?? 0}
82+
followerCount={profile?.followersCount ?? 0}
83+
followCount={profile?.followsCount ?? 0}
84+
postsCount={profile.postsCount ?? 0}
8485
/>
8586
)}
8687
{profile?.description && (

src/components/dataDisplay/reason/Reason.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
import { AppBskyFeedDefs } from "@atproto/api";
2-
import { BiRepost } from "react-icons/bi";
2+
import { BiPin, BiRepost } from "react-icons/bi";
33
import Link from "next/link";
4+
import {
5+
ReasonPin,
6+
ReasonRepost,
7+
} from "@atproto/api/dist/client/types/app/bsky/feed/defs";
48

59
interface Props {
610
reason:
7-
| AppBskyFeedDefs.ReasonRepost
8-
| {
9-
[k: string]: unknown;
10-
$type: string;
11-
}
11+
| ReasonRepost
12+
| ReasonPin
13+
| { [k: string]: unknown; $type: string }
1214
| undefined;
1315
}
1416

1517
export default function Reason(props: Props) {
1618
const { reason } = props;
1719
const isRepost = AppBskyFeedDefs.isReasonRepost(reason);
20+
const isPin = AppBskyFeedDefs.isReasonPin(reason);
1821

1922
return (
2023
<>
@@ -29,6 +32,12 @@ export default function Reason(props: Props) {
2932
</div>
3033
</Link>
3134
)}
35+
{isPin && (
36+
<div className="max-w-fit text-skin-secondary inline-flex flex-wrap items-center gap-1 text-lg font-semibold">
37+
<BiPin />
38+
<small>Pinned</small>
39+
</div>
40+
)}
3241
</>
3342
);
3443
}

src/components/dataDisplay/followInfo/FollowInfo.tsx renamed to src/components/dataDisplay/userStats/UserStats.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,37 @@ import Link from "next/link";
33

44
interface Props {
55
handle: string;
6-
followsCount: number;
7-
followersCount: number;
6+
followCount: number;
7+
followerCount: number;
8+
postsCount: number;
89
}
910

10-
export default function FollowInfo(props: Props) {
11-
const { handle, followsCount, followersCount } = props;
11+
export default function UserStats(props: Props) {
12+
const { handle, followCount, followerCount, postsCount } = props;
1213

1314
return (
14-
<div className="flex-gap flex items-center gap-3">
15+
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
1516
<Link
1617
href={`/dashboard/user/${handle}/following`}
1718
className="text-skin-base flex gap-1 font-semibold hover:brightness-110"
1819
>
19-
{abbreviateNumber(followsCount)}
20+
{abbreviateNumber(followCount)}
2021
<span className="text-skin-tertiary font-medium">Following</span>
2122
</Link>
2223

2324
<Link
2425
href={`/dashboard/user/${handle}/followers`}
2526
className="text-skin-base flex gap-1 font-semibold hover:brightness-110"
2627
>
27-
{abbreviateNumber(followersCount)}
28+
{abbreviateNumber(followerCount)}
2829
<span className="text-skin-tertiary font-medium">Followers</span>
2930
</Link>
31+
<div className=" flex gap-1">
32+
<span className="text-skin-base font-semibold">
33+
{abbreviateNumber(postsCount)}
34+
</span>
35+
<span className="text-skin-tertiary font-medium">Posts</span>
36+
</div>
3037
</div>
3138
);
3239
}

src/containers/posts/UserPostsContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function UserPostsConatiner(props: Props) {
4646

4747
const dataLength = userPostsData?.pages.reduce(
4848
(acc, page) => acc + (page?.data.feed.length ?? 0),
49-
0,
49+
0
5050
);
5151

5252
const isEmpty =

src/lib/api/bsky/actor/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
AtpAgent,
2+
Agent,
33
BskyFeedViewPreference,
44
LabelPreference,
55
BskyThreadViewPreference,
@@ -9,7 +9,7 @@ import { ContentFilterLabel } from "../../../../../types/feed";
99

1010
export const getProfile = async (
1111
handle: string | undefined,
12-
agent?: AtpAgent,
12+
agent?: Agent,
1313
) => {
1414
if (!handle) return;
1515
if (!agent) agent = await getAgent();
@@ -27,7 +27,7 @@ export const getSuggestions = async () => {
2727
};
2828

2929
export const searchProfiles = async (
30-
agent: AtpAgent,
30+
agent: Agent,
3131
term: string,
3232
cursor: string,
3333
) => {
@@ -42,7 +42,7 @@ export const searchProfiles = async (
4242
};
4343

4444
export const searchProfilesTypehead = async (
45-
agent: AtpAgent,
45+
agent: Agent,
4646
term: string,
4747
) => {
4848
try {
@@ -59,7 +59,7 @@ export const searchPosts = async (
5959
term: string,
6060
cursor: string,
6161
sort: "latest" | "top",
62-
agent?: AtpAgent,
62+
agent?: Agent,
6363
) => {
6464
if (!agent) agent = await getAgent();
6565
try {
@@ -78,7 +78,7 @@ export const searchPosts = async (
7878
}
7979
};
8080

81-
export const getPreferences = async (agent?: AtpAgent) => {
81+
export const getPreferences = async (agent?: Agent) => {
8282
if (!agent) agent = await getAgent();
8383
const prefs = await agent.app.bsky.actor.getPreferences();
8484
if (!prefs.success) throw new Error("Could not get preferences");
@@ -87,15 +87,15 @@ export const getPreferences = async (agent?: AtpAgent) => {
8787

8888
export const updateThreadViewPreferences = async (
8989
pref: Partial<BskyThreadViewPreference>,
90-
agent?: AtpAgent,
90+
agent?: Agent,
9191
) => {
9292
if (!agent) agent = await getAgent();
9393
const prefs = await agent.setThreadViewPrefs(pref);
9494
return prefs;
9595
};
9696
export const updateHomeFeedPreferences = async (
9797
pref: Partial<BskyFeedViewPreference>,
98-
agent?: AtpAgent,
98+
agent?: Agent,
9999
) => {
100100
if (!agent) agent = await getAgent();
101101
const prefs = await agent.setFeedViewPrefs("home", pref);
@@ -104,7 +104,7 @@ export const updateHomeFeedPreferences = async (
104104

105105
export const updateIsAdultContentEnabled = async (
106106
value: boolean,
107-
agent?: AtpAgent,
107+
agent?: Agent,
108108
) => {
109109
if (!agent) agent = await getAgent();
110110
const prefs = await agent.setAdultContentEnabled(value);
@@ -114,21 +114,21 @@ export const updateIsAdultContentEnabled = async (
114114
export const updateContentFilterPreferences = async (
115115
pref: ContentFilterLabel,
116116
value: LabelPreference,
117-
agent?: AtpAgent,
117+
agent?: Agent,
118118
) => {
119119
if (!agent) agent = await getAgent();
120120
const prefs = await agent.setContentLabelPref(pref, value);
121121
return prefs;
122122
};
123123

124-
export const muteUser = async (did: string, agent?: AtpAgent) => {
124+
export const muteUser = async (did: string, agent?: Agent) => {
125125
if (!agent) agent = await getAgent();
126126
const mute = await agent.mute(did);
127127
if (!mute.success) throw new Error("Could not mute user");
128128
return mute.success;
129129
};
130130

131-
export const unMuteUser = async (did: string, agent?: AtpAgent) => {
131+
export const unMuteUser = async (did: string, agent?: Agent) => {
132132
if (!agent) agent = await getAgent();
133133
const mute = await agent.unmute(did);
134134
if (!mute.success) throw new Error("Could not unmute user");
@@ -138,7 +138,7 @@ export const unMuteUser = async (did: string, agent?: AtpAgent) => {
138138
export const blockUser = async (
139139
viewerDid: string,
140140
did: string,
141-
agent?: AtpAgent,
141+
agent?: Agent,
142142
) => {
143143
if (!agent) agent = await getAgent();
144144
const res = await agent.app.bsky.graph.block.create(
@@ -152,7 +152,7 @@ export const blockUser = async (
152152
export const unBlockUser = async (
153153
viewerDid: string,
154154
rkey: string,
155-
agent?: AtpAgent,
155+
agent?: Agent,
156156
) => {
157157
if (!agent) agent = await getAgent();
158158
await agent.app.bsky.graph.block.delete({ rkey: rkey, repo: viewerDid });

src/lib/api/bsky/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ export const getBskySession = async () => {
2929
};
3030

3131
export const getAgent = async () => {
32-
const atpAgent = await getBskySession();
33-
return atpAgent;
32+
const agent = await getBskySession();
33+
return agent;
3434
};

0 commit comments

Comments
 (0)