import { useBskyUserManager } from "~lib/hooks/useBskyUserManager";
import "./style.css";
import { ToastContainer, toast } from "react-toastify";
import useConfirm from "~lib/components/ConfirmDialog";
import Sidebar from "~lib/components/Sidebar";
import "react-toastify/dist/ReactToastify.css";
import type { ProfileView } from "@atproto/api/dist/client/types/app/bsky/actor/defs";
import React from "react";
import ReSearchModal from "~components/ReSearchModal";
import DetectedUserListItem from "~lib/components/DetectedUserListItem";
const Option = () => {
const {
users,
filteredUsers,
matchTypeFilter,
changeMatchTypeFilter,
handleClickAction,
actionMode,
matchTypeStats,
importList,
followAll,
blockAll,
reSearch,
reSearchResults,
changeDetectedUser,
clearReSearchResults,
} = useBskyUserManager();
const {
confirm: followAllConfirm,
ConfirmationDialog: FollowAllConfirmationDialog,
} = useConfirm({
title: "Proceed with Execution?",
message:
"User detection is not perfect and may include false positives. Do you still want to proceed?",
cancelText: "Cancel",
okText: "OK",
});
const {
confirm: importListConfirm,
ConfirmationDialog: ImportListConfirmationDialog,
} = useConfirm({
title: "Proceed with Execution?",
message:
"Importing a list will create a new list and add all detected users to it. This feature is experimental and may not work as expected. Do you still want to proceed?",
cancelText: "Cancel",
okText: "OK",
});
const handleFollowAll = async () => {
if (!(await followAllConfirm())) {
return;
}
toast.promise(followAll, {
pending: "Processing...",
success: {
render({ data }) {
return Followed {data} users🎉;
},
},
});
};
const handleBlockAll = async () => {
if (!(await followAllConfirm())) {
return;
}
toast.promise(blockAll, {
pending: "Processing...",
success: {
render({ data }) {
return Blocked {data} users🎉;
},
},
});
};
const handleImportList = async () => {
if (!(await importListConfirm())) {
return;
}
toast.promise(importList, {
pending: "Processing...",
success: {
render({ data }) {
return (
<>
List imported successfully🎉
View Imported List
>
);
},
},
error: {
render({ data }) {
console.log(data);
return `Failed to import list: ${data}`;
},
},
});
};
const [showReSearchModal, setShowReSearchModal] = React.useState(false);
const handleReSearch = async (user: {
sourceDid: string;
accountName: string;
displayName: string;
}) => {
reSearch({
sourceDid: user.sourceDid,
accountName: user.accountName,
displayName: user.displayName,
});
setShowReSearchModal(true);
};
const handleClickReSearchResult = ({
sourceDid,
user,
}: {
sourceDid: string;
user: ProfileView;
}) => {
changeDetectedUser(sourceDid, user);
setShowReSearchModal(false);
clearReSearchResults();
};
const handleCloseReSearchModal = () => {
setShowReSearchModal(false);
clearReSearchResults();
};
return (
<>