Enable transferring lists of users to UserList page

This commit is contained in:
Nat 2021-06-05 18:31:10 -03:00
parent 9b712e595d
commit 4da37de55f
2 changed files with 11 additions and 41 deletions

View File

@ -95,7 +95,7 @@ const ViewProfileJsx = ({navigation}) => {
}) })
.then(([ ownFollowing, theirFollowers, posts ]) => { .then(([ ownFollowing, theirFollowers, posts ]) => {
setState({...state, setState({...state,
mutuals: getMutuals(ownFollowing, theirFollowers), listedUsers: getMutuals(ownFollowing, theirFollowers),
posts: posts, posts: posts,
instance, instance,
ownProfile, ownProfile,
@ -172,7 +172,7 @@ const ViewProfileJsx = ({navigation}) => {
onMute = { _handleMute } onMute = { _handleMute }
onBlock = { _handleBlock } onBlock = { _handleBlock }
profile = { state.profile } profile = { state.profile }
mutuals = { state.mutuals } listedUsers = { state.listedUsers }
followed = { state.followed } followed = { state.followed }
posts = { state.posts }/> posts = { state.posts }/>
</ScreenWithBackBarJsx> </ScreenWithBackBarJsx>
@ -209,9 +209,10 @@ const ProfileJsx = ({ navigation }) => {
return Promise.all([ return Promise.all([
requests.fetchProfile(domain, profile.id), requests.fetchProfile(domain, profile.id),
requests.fetchAccountStatuses(domain, profile.id, accessToken), requests.fetchAccountStatuses(domain, profile.id, accessToken),
requests.fetchFollowers(domain, profile.id, accessToken),
]); ]);
}) })
.then(([latestProfile, posts]) => { .then(([latestProfile, posts, followers]) => {
if(JSON.stringify(latestProfile) != JSON.stringify(profile)) { if(JSON.stringify(latestProfile) != JSON.stringify(profile)) {
profile = latestProfile profile = latestProfile
} }
@ -220,6 +221,7 @@ const ProfileJsx = ({ navigation }) => {
profile: profile, profile: profile,
notifs: notifs, notifs: notifs,
posts: posts, posts: posts,
listedUsers: followers,
loaded: true, loaded: true,
}); });
}); });
@ -236,6 +238,7 @@ const ProfileJsx = ({ navigation }) => {
own = { true } own = { true }
profile = { state.profile } profile = { state.profile }
posts = { state.posts } posts = { state.posts }
listedUsers = { state.listedUsers }
notifs = { state.notifs }/> notifs = { state.notifs }/>
</ScreenWithTrayJsx> </ScreenWithTrayJsx>
: <></> : <></>
@ -347,6 +350,7 @@ const RawProfileJsx = (props) => {
: "Your mutual followers with " + props.profile.display_name; : "Your mutual followers with " + props.profile.display_name;
props.navigation.navigate("UserList", { props.navigation.navigate("UserList", {
context: context, context: context,
data: props.listedUsers,
}); });
} }
}> }>
@ -355,9 +359,9 @@ const RawProfileJsx = (props) => {
<>View followers</> <>View followers</>
: <> : <>
{ {
props.mutuals.length props.listedUsers.length
+ pluralize( + pluralize(
props.mutuals.length, props.listedUsers.length,
" mutual", " mutual",
" mutuals" " mutuals"
) )

View File

@ -11,42 +11,8 @@ import {
import { ScreenWithBackBarJsx } from "src/components/navigation/navigators.js"; import { ScreenWithBackBarJsx } from "src/components/navigation/navigators.js";
import ModerateMenuJsx from "src/components/moderate-menu.js"; import ModerateMenuJsx from "src/components/moderate-menu.js";
const TEST_PROFILE = {
username: "njms",
acct: "njms",
display_name: "Nat🔆",
locked: false,
bot: false,
note: "Yeah heart emoji.",
avatar: "https://cache.desktopnexus.com/thumbseg/2255/2255124-bigthumbnail.jpg",
followers_count: "1 jillion",
statuses_count: 334,
fields: [
{
name: "Blog",
value: "<a href=\"https://njms.ca\">https://njms.ca</a>",
verified_at: "some time"
},
{
name: "Github",
value: "<a href=\"https://github.com/natjms\">https://github.com/natjms</a>",
verified_at: null
}
]
};
const TEST_DATA = [
{...TEST_PROFILE, id: 1},
{...TEST_PROFILE, id: 2},
{...TEST_PROFILE, id: 3},
{...TEST_PROFILE, id: 4},
{...TEST_PROFILE, id: 5},
{...TEST_PROFILE, id: 6},
]
const UserListJsx = ({navigation}) => { const UserListJsx = ({navigation}) => {
// const data = navigation.getParam("data", []) const data = navigation.getParam("data", [])
const data = TEST_DATA;
const context = navigation.getParam("context", ""); const context = navigation.getParam("context", "");
return ( return (
@ -67,7 +33,7 @@ const UserListJsx = ({navigation}) => {
style = { styles.accountButton } style = { styles.accountButton }
onPress = { onPress = {
() => { () => {
navigation.navigate("Profile", { acct: item.acct }); navigation.push("ViewProfile", { profile: item });
} }
}> }>
<View style = { styles.flexContainer }> <View style = { styles.flexContainer }>