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

View File

@ -11,42 +11,8 @@ import {
import { ScreenWithBackBarJsx } from "src/components/navigation/navigators.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 data = navigation.getParam("data", [])
const data = TEST_DATA;
const data = navigation.getParam("data", [])
const context = navigation.getParam("context", "");
return (
@ -67,7 +33,7 @@ const UserListJsx = ({navigation}) => {
style = { styles.accountButton }
onPress = {
() => {
navigation.navigate("Profile", { acct: item.acct });
navigation.push("ViewProfile", { profile: item });
}
}>
<View style = { styles.flexContainer }>