Skip to content

Commit

Permalink
client-web: drop usage of followingUserIds
Browse files Browse the repository at this point in the history
  • Loading branch information
franzos committed Sep 26, 2023
1 parent a6ab1d8 commit afe2a89
Show file tree
Hide file tree
Showing 19 changed files with 178 additions and 212 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const event = NewContactList({
{
key: "5276ac499c9c6a353634d3d2cb6f4ada5167c3b886108ab4ddeb8ddf7b0fff70",
relayUrl: "wss://nostr.rocks",
petname: "nostros",
petname: "nostrop",
},
],
});
Expand Down
2 changes: 1 addition & 1 deletion client-web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NostrOS</title>
<title>NostrOP</title>
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180">
<meta name="theme-color" content="#ffffff">
</head>
Expand Down
2 changes: 1 addition & 1 deletion client-web/src/components/event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export function Event({ data, level }: EventProps) {
/>
)}
<Box p={2}>
<User user={user} options={userOptions} />
<User user={user} opts={userOptions} />
</Box>
</CardHeader>
{/* BODY */}
Expand Down
4 changes: 2 additions & 2 deletions client-web/src/components/event/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function EventUser({ data }: EventUserProps) {
{data.user && data.user.pubkey ? (
<User
user={data.user}
options={{
opts={{
showFollowing: true,
relayUrls: data.eventRelayUrls,
showBlock: true,
Expand All @@ -22,7 +22,7 @@ export function EventUser({ data }: EventUserProps) {
user={{
pubkey: data.event.pubkey,
}}
options={{
opts={{
showFollowing: true,
relayUrls: data.eventRelayUrls,
showBlock: true,
Expand Down
22 changes: 12 additions & 10 deletions client-web/src/components/feeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ import {
} from "../lib/default-filters";

export function EventsFeeds() {
const [status, followingUserIds, keypairIsLoaded, keypair] = useNClient(
(state) => [
state.status,
state.followingUserIds,
state.keypairIsLoaded,
state.keypair,
]
);
const [status, keypairIsLoaded, keypair] = useNClient((state) => [
state.status,
state.keypairIsLoaded,
state.keypair,
]);

const isInitDone = useRef<boolean>(false);

Expand Down Expand Up @@ -76,7 +73,12 @@ export function EventsFeeds() {
if (feedName === "global") {
activeFilters.current = filterDefault();
} else if (feedName === "following") {
activeFilters.current = filterByAuthor(followingUserIds);
const following = await useNClient.getState().getAllUsersFollowing();
if (following) {
activeFilters.current = filterByAuthor(
following?.map((f) => f.user.pubkey)
);
}
} else if (feedName === "mentions") {
activeFilters.current = filterByMentions([keypair.publicKey]);
} else {
Expand Down Expand Up @@ -105,7 +107,7 @@ export function EventsFeeds() {
<Box>
<Box p={2}>
<ListSelection
showFollowing={followingUserIds.length > 0}
showFollowing={true}
showMentions={keypairIsLoaded}
changeFeed={changeFeed}
/>
Expand Down
7 changes: 3 additions & 4 deletions client-web/src/components/popular-users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
} from "@chakra-ui/react";
import { UserRecord } from "@nostr-ts/common";
import { useEffect, useRef, useState } from "react";
import { UserInfo } from "./user-info";
import { useNClient } from "../state/client";
import { User } from "./user";

export function PopularUsersList() {
const [users, setUsers] = useState<UserRecord[]>([]);
Expand Down Expand Up @@ -102,14 +102,13 @@ export function PopularUsersList() {

{users.length > 0
? users.map((user, index) => (
<UserInfo
<User
key={index}
user={user.user}
opts={{
showAbout: false,
showBanner: false,
following: false,
showFollowing: false,
showFollowing: true,
showBlock: false,
relayUrls: [],
isBlocked: false,
Expand Down
14 changes: 4 additions & 10 deletions client-web/src/components/user-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ import {
PopoverTrigger,
} from "@chakra-ui/react";
import { UserBase } from "@nostr-ts/common";
import { useNClient } from "../state/client";
import { UserInfo } from "./user-info";
import { UserOptions } from "../lib/user-properties";
import { User } from "./user";

export function UserIcon({
user,
options: {
opts: {
showAbout,
showBanner,
showFollowing,
Expand All @@ -28,12 +27,8 @@ export function UserIcon({
},
}: {
user: UserBase;
options: UserOptions;
opts: UserOptions;
}) {
const [following] = useNClient((state) => [
state.followingUserIds.find((f) => f === user.pubkey),
]);

const picture = user.data && user.data.picture ? user.data.picture : "";

return (
Expand Down Expand Up @@ -75,12 +70,11 @@ export function UserIcon({
<PopoverCloseButton />
<PopoverHeader>{title}</PopoverHeader>
<PopoverBody>
<UserInfo
<User
user={user}
opts={{
showAbout,
showBanner,
following: !!following,
showFollowing,
relayUrls,
title,
Expand Down
128 changes: 0 additions & 128 deletions client-web/src/components/user-info.tsx

This file was deleted.

Loading

0 comments on commit afe2a89

Please sign in to comment.