Skip to content

Commit

Permalink
Merge branch 'preview'
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelfan committed Nov 13, 2024
2 parents 2232c03 + 5d7c1ce commit 090cc71
Show file tree
Hide file tree
Showing 58 changed files with 455 additions and 240 deletions.
130 changes: 130 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@atproto/api": "^0.13.11",
"@atproto/identity": "^0.4.3",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-hover-card": "^1.1.2",
Expand Down
10 changes: 10 additions & 0 deletions src/app/api/auth/identity/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use server";

import { getDidFromHandle, getPDS } from "@/lib/api/bsky/identity";

export async function getService(handle: string) {
const userDID = await getDidFromHandle(handle);
const service = await getPDS(userDID);

return service;
}
9 changes: 4 additions & 5 deletions src/components/contentDisplay/feedHeader/FeedHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
togglePinFeed,
toggleSaveFeed,
} from "@/lib/api/bsky/feed";
import useAgent from "@/lib/hooks/bsky/useAgent";
import { useRouter } from "next/navigation";
import FeedHeaderSkeleton from "./FeedHeaderSkeleton";
import { useQueryClient } from "@tanstack/react-query";
Expand All @@ -21,6 +20,7 @@ import { BiSolidBookmarkAlt } from "react-icons/bi";
import { BiPlus } from "react-icons/bi";
import { BiSolidHeart } from "react-icons/bi";
import Link from "next/link";
import { getAgentFromClient } from "@/lib/api/bsky/agent";

interface Props {
feed: string;
Expand All @@ -29,7 +29,6 @@ interface Props {
export default function FeedHeader(props: Props) {
const { feed } = props;
const router = useRouter();
const agent = useAgent();
const [isSaved, setIsSaved] = useState<boolean | null>(null);
const [isPinned, setIsPinned] = useState<boolean | null>(null);
const [isLiked, setIsLiked] = useState<boolean | null>(null);
Expand All @@ -54,9 +53,9 @@ export default function FeedHeader(props: Props) {
}, [feedInfo]);

const toggleSave = async () => {
if (!agent) return;
setIsSaved((prev) => !prev);
try {
const agent = await getAgentFromClient();
const response = await toggleSaveFeed(agent, feed);
if (!response.success) {
setIsSaved((prev) => !prev);
Expand All @@ -70,9 +69,9 @@ export default function FeedHeader(props: Props) {
};

const togglePin = async () => {
if (!agent) return;
setIsPinned((prev) => !prev);
try {
const agent = await getAgentFromClient();
const response = await togglePinFeed(agent, feed);
if (!response.success) {
setIsPinned((prev) => !prev);
Expand All @@ -86,7 +85,7 @@ export default function FeedHeader(props: Props) {
};

const toggleLike = async () => {
if (!agent) return;
const agent = await getAgentFromClient();
setIsLiked((prev) => !prev);
if (!likeUri && feedInfo) {
try {
Expand Down
5 changes: 2 additions & 3 deletions src/components/contentDisplay/feedItem/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { BiPlus, BiSolidHeart, BiSolidTrash } from "react-icons/bi";
import Button from "@/components/actions/button/Button";
import { useState } from "react";
import { useRouter } from "next/navigation";
import useAgent from "@/lib/hooks/bsky/useAgent";
import { toggleSaveFeed } from "@/lib/api/bsky/feed";
import Link from "next/link";
import { useQueryClient } from "@tanstack/react-query";
import { savedFeedsQueryKey } from "@/containers/settings/myFeedsContainer/MyFeedsContainer";
import { getAgentFromClient } from "@/lib/api/bsky/agent";

interface Props {
feedItem: GeneratorView;
Expand All @@ -23,13 +23,12 @@ export default function FeedItem(props: Props) {
const { avatar, displayName, description, likeCount, creator } = feedItem;
const [isSaved, setIsSaved] = useState(saved);
const router = useRouter();
const agent = useAgent();
const queryClient = useQueryClient();

const handleSave = async () => {
if (!agent) return;
setIsSaved((prev) => !prev);
try {
const agent = await getAgentFromClient();
const response = await toggleSaveFeed(agent, feedItem.uri);
if (!response.success) {
setIsSaved((prev) => !prev);
Expand Down
6 changes: 3 additions & 3 deletions src/components/contentDisplay/lists/Lists.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { getLists } from "@/lib/api/bsky/list";
import useAgent from "@/lib/hooks/bsky/useAgent";
import { useInfiniteQuery } from "@tanstack/react-query";
import { useSession } from "next-auth/react";
import { Fragment } from "react";
Expand All @@ -10,9 +9,9 @@ import FeedAlert from "@/components/feedback/feedAlert/FeedAlert";
import LoadingSpinner from "@/components/status/loadingSpinner/LoadingSpinner";
import ListsSkeleton from "./ListsSkeleton";
import InfiniteScroll from "react-infinite-scroll-component";
import { getAgentFromClient } from "@/lib/api/bsky/agent";

export default function Lists() {
const agent = useAgent();
const { data: session } = useSession();

const {
Expand All @@ -26,8 +25,9 @@ export default function Lists() {
fetchNextPage,
} = useInfiniteQuery({
queryKey: ["lists"],
queryFn: ({ pageParam }) => {
queryFn: async ({ pageParam }) => {
if (!session?.user.id) return;
const agent = await getAgentFromClient();
return getLists(session.user.id, pageParam, agent);
},
initialPageParam: "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { ContentFilterResult } from "../../../../types/feed";
import useAgent from "@/lib/hooks/bsky/useAgent";
import { getPost } from "@/lib/api/bsky/feed";
import PostText from "@/components/dataDisplay/postText/postText";
import { AppBskyFeedDefs } from "@atproto/api";
Expand All @@ -12,6 +11,7 @@ import { useEffect, useState } from "react";
import PostHider from "@/components/dataDisplay/postHider/PostHider";
import FeedAlert from "@/components/feedback/feedAlert/FeedAlert";
import NotificationContentSkeleton from "./NotificationContentSkeleton";
import { getAgentFromClient } from "@/lib/api/bsky/agent";

interface Props {
uri: string;
Expand All @@ -20,12 +20,14 @@ interface Props {

export default function NotificationContnet(props: Props) {
const { uri, filter } = props;
const agent = useAgent();
const router = useRouter();

const { status, data, error, isLoading, isFetching } = useQuery({
queryKey: ["notificationContent", uri],
queryFn: () => getPost(agent, uri),
queryFn: async () => {
const agent = await getAgentFromClient();
return getPost(agent, uri);
},
});

const post =
Expand All @@ -35,8 +37,8 @@ export default function NotificationContnet(props: Props) {
const label = post?.post.labels?.map((l) => l.val)[0] ?? ""; // ex. "nsfw", "suggestive"
const embedLabel =
post?.post.embed && post?.post.embed.record
? (post.post.embed.record as ViewRecord)?.labels?.map((l) => l.val)[0] ??
""
? ((post.post.embed.record as ViewRecord)?.labels?.map((l) => l.val)[0] ??
"")
: "";
const message =
adultContentFilters.find((f) => f.values.includes(label || embedLabel))
Expand Down
Loading

0 comments on commit 090cc71

Please sign in to comment.