Skip to content

Commit

Permalink
feat: adds previous unfollowed users list (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
agusmoles authored Jan 10, 2025
1 parent a22b8b2 commit cd4b62f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion public/index.html

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function App() {
"iu-old-results",
null
);
const [unfollowedUsers, setUnfollowedUsers] = useLocalStorage<Node[]>(
"iu-unfollowed-users",
[]
);

useEffect(() => {
const onBeforeUnload = (e: BeforeUnloadEvent) => {
Expand Down Expand Up @@ -154,6 +158,15 @@ function App() {
const alertMessage = `⚠ Going to unfollow ${usersToUnfollow.length} users, are you sure?`;
if (!confirm(alertMessage)) return;

const uniqueUnfollowedUsers = [
...unfollowedUsers,
...usersToUnfollow,
].filter(
(user, index, self) => index === self.findIndex((t) => t.id === user.id)
);

setUnfollowedUsers(uniqueUnfollowedUsers);

setState((prevState) => {
if (prevState.status !== "scanning") return prevState;
const oldResults = [...prevState.results];
Expand Down Expand Up @@ -374,6 +387,15 @@ function App() {
<button className="unfollow-btn" onClick={handleUnfollow}>
Unfollow {state.selectedResults.length} users
</button>

<section>
Previous unfollowed users:
<ul>
{unfollowedUsers?.map((user) => (
<li key={`unfollowed-${user.id}`}>{user.username}</li>
))}
</ul>
</section>
</article>

<article className="users-container">
Expand Down

0 comments on commit cd4b62f

Please sign in to comment.