Display only mutual followers on profiles
This commit is contained in:
parent
93415948c2
commit
59cf1ff451
|
@ -69,10 +69,34 @@ const TEST_PROFILE = {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const TEST_YOUR_FOLLOWERS = [
|
||||||
|
{ id: 1 },
|
||||||
|
{ id: 2 },
|
||||||
|
{ id: 3 },
|
||||||
|
{ id: 4 },
|
||||||
|
{ id: 5 },
|
||||||
|
];
|
||||||
|
|
||||||
|
const TEST_THEIR_FOLLOWERS = [
|
||||||
|
{ id: 2 },
|
||||||
|
{ id: 3 },
|
||||||
|
{ id: 4 },
|
||||||
|
{ id: 6 },
|
||||||
|
];
|
||||||
|
|
||||||
function withoutHTML(string) {
|
function withoutHTML(string) {
|
||||||
return string.replaceAll(/<[^>]*>/ig, "");
|
return string.replaceAll(/<[^>]*>/ig, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMutuals(yours, theirs) {
|
||||||
|
// Where yours and theirs are arrays of followers, as returned by the oAPI
|
||||||
|
|
||||||
|
const idify = ({id}) => id;
|
||||||
|
const asIDs = new Set(theirs.map(idify));
|
||||||
|
|
||||||
|
return yours.filter(x => asIDs.has(idify(x)));
|
||||||
|
}
|
||||||
|
|
||||||
const HTMLLink = ({link}) => {
|
const HTMLLink = ({link}) => {
|
||||||
let url = link.match(/https?:\/\/\w+\.\w+/);
|
let url = link.match(/https?:\/\/\w+\.\w+/);
|
||||||
|
|
||||||
|
@ -129,6 +153,7 @@ const ProfileDisplayJsx = ({navigation}) => {
|
||||||
// do something to get the profile based on given account name
|
// do something to get the profile based on given account name
|
||||||
setState({
|
setState({
|
||||||
profile: TEST_PROFILE,
|
profile: TEST_PROFILE,
|
||||||
|
mutuals: getMutuals(TEST_YOUR_FOLLOWERS, TEST_THEIR_FOLLOWERS),
|
||||||
loaded: true
|
loaded: true
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -178,8 +203,7 @@ const ProfileDisplayJsx = ({navigation}) => {
|
||||||
</View>
|
</View>
|
||||||
<Text style = { styles.accountStats }>
|
<Text style = { styles.accountStats }>
|
||||||
{ state.profile.statuses_count } posts •
|
{ state.profile.statuses_count } posts •
|
||||||
{ state.profile.followers_count } followers •
|
{ state.mutuals.length } mutuals
|
||||||
{ state.profile.following_count } following
|
|
||||||
</Text>
|
</Text>
|
||||||
<Text style = { styles.note }>
|
<Text style = { styles.note }>
|
||||||
{state.profile.note}
|
{state.profile.note}
|
||||||
|
|
Loading…
Reference in New Issue