From 4da37de55f07eca3b7731189fed8340d01c96a13 Mon Sep 17 00:00:00 2001 From: natjms Date: Sat, 5 Jun 2021 18:31:10 -0300 Subject: [PATCH] Enable transferring lists of users to UserList page --- src/components/pages/profile.js | 14 ++++++++---- src/components/pages/user-list.js | 38 ++----------------------------- 2 files changed, 11 insertions(+), 41 deletions(-) diff --git a/src/components/pages/profile.js b/src/components/pages/profile.js index 13e9c12..c62ca9f 100644 --- a/src/components/pages/profile.js +++ b/src/components/pages/profile.js @@ -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 }/> @@ -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 }/> : <> @@ -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" ) diff --git a/src/components/pages/user-list.js b/src/components/pages/user-list.js index ace6640..d935fbb 100644 --- a/src/components/pages/user-list.js +++ b/src/components/pages/user-list.js @@ -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: "https://njms.ca", - verified_at: "some time" - }, - { - name: "Github", - value: "https://github.com/natjms", - 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 }); } }>