mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 10:52:16 +03:00
supporting deep link profile filters
This commit is contained in:
parent
58af000df8
commit
d2cc39b14b
@ -170,6 +170,7 @@ class ProfileView extends PureComponent {
|
||||
const { currencyRate, currencySymbol, selectedUser } = this.props;
|
||||
|
||||
const { isSummaryOpen, estimatedWalletValue } = this.state;
|
||||
|
||||
return (
|
||||
<View
|
||||
key="profile.wallet"
|
||||
@ -200,6 +201,7 @@ class ProfileView extends PureComponent {
|
||||
isOwnProfile,
|
||||
profileTabs,
|
||||
ownProfileTabs,
|
||||
deepLinkFilter,
|
||||
} = this.props;
|
||||
|
||||
const { isSummaryOpen } = this.state;
|
||||
@ -207,6 +209,17 @@ class ProfileView extends PureComponent {
|
||||
const pageType = isOwnProfile ? 'ownProfile' : 'profile';
|
||||
const tabs = (isOwnProfile ? ownProfileTabs : profileTabs) || getDefaultFilters(pageType);
|
||||
|
||||
//set initial tab based on deep link filter if available
|
||||
let selectedIndex = 0;
|
||||
if (deepLinkFilter) {
|
||||
selectedIndex = tabs.indexOf((val) => val === deepLinkFilter);
|
||||
if (selectedIndex < 0) {
|
||||
tabs.pop();
|
||||
tabs.push(deepLinkFilter);
|
||||
selectedIndex = 2;
|
||||
}
|
||||
}
|
||||
|
||||
const filterOptions = tabs.map((key) => getFilterMap(pageType)[key]);
|
||||
|
||||
//compile content overrides
|
||||
@ -222,7 +235,7 @@ class ProfileView extends PureComponent {
|
||||
key={username + JSON.stringify(filterOptions)}
|
||||
filterOptions={filterOptions}
|
||||
filterOptionsValue={tabs}
|
||||
selectedOptionIndex={0}
|
||||
selectedOptionIndex={selectedIndex}
|
||||
pageType={pageType}
|
||||
getFor="blog"
|
||||
feedUsername={username}
|
||||
|
@ -56,6 +56,7 @@ class ProfileContainer extends Component {
|
||||
name: get(props, 'navigation.state.params.username', ''),
|
||||
},
|
||||
reverseHeader: !!username,
|
||||
deepLinkFilter: get(props, 'navigation.state.params.deepLinkFilter'),
|
||||
};
|
||||
}
|
||||
|
||||
@ -68,6 +69,7 @@ class ProfileContainer extends Component {
|
||||
currentAccount: { name: currentAccountUsername },
|
||||
} = this.props;
|
||||
const username = get(navigation, 'state.params.username');
|
||||
|
||||
const { isOwnProfile } = this.state;
|
||||
let targetUsername = currentAccountUsername;
|
||||
|
||||
@ -436,6 +438,7 @@ class ProfileContainer extends Component {
|
||||
user,
|
||||
username,
|
||||
reverseHeader,
|
||||
deepLinkFilter,
|
||||
} = this.state;
|
||||
const { currency, isDarkTheme, isLoggedIn, navigation, children, isHideImage } = this.props;
|
||||
const activePage = get(navigation.state.params, 'state', 0);
|
||||
@ -486,6 +489,7 @@ class ProfileContainer extends Component {
|
||||
selectedUser: user,
|
||||
username,
|
||||
reverseHeader,
|
||||
deepLinkFilter,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class ApplicationContainer extends Component {
|
||||
// this._handleOpenURL({url:"https://ecency.com/@good-karma"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/hive-125125/@ecency/vision-landing-page-curators-leaderboard"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/tags/@ecency/vision-landing-page-curators-leaderboard"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/@ecency/vision-landing-page-curators-leaderboard"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/hot/book"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/trending/book"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/created/book"})
|
||||
@ -137,11 +137,11 @@ class ApplicationContainer extends Component {
|
||||
// this._handleOpenURL({url:"https://ecency.com/trending/"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/created/"})
|
||||
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com/points"}) //TOOD
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com/wallet"}) //TODO
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com/comments"}) //TODO
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com/posts"}) //TODO
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com/replies"}) //TODO
|
||||
// this._handleOpenURL({url:"https://ecency.com/@noumantahir/points"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com/wallet"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/@noumantahir/comments"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/@good-karma/posts"})
|
||||
// this._handleOpenURL({url:"https://ecency.com/@demo.com/replies"})
|
||||
|
||||
Linking.addEventListener('url', this._handleOpenURL);
|
||||
|
||||
@ -290,21 +290,34 @@ class ApplicationContainer extends Component {
|
||||
|
||||
try {
|
||||
if (author) {
|
||||
if (permlink) {
|
||||
if (
|
||||
!permlink ||
|
||||
permlink === 'wallet' ||
|
||||
permlink === 'points' ||
|
||||
permlink === 'comments' ||
|
||||
permlink === 'replies' ||
|
||||
permlink === 'posts'
|
||||
) {
|
||||
let deepLinkFilter;
|
||||
if (permlink) {
|
||||
deepLinkFilter = permlink === 'points' ? 'wallet' : permlink;
|
||||
}
|
||||
|
||||
profile = await getUser(author);
|
||||
routeName = ROUTES.SCREENS.PROFILE;
|
||||
params = {
|
||||
username: get(profile, 'name'),
|
||||
reputation: get(profile, 'reputation'),
|
||||
deepLinkFilter, //TODO: process this in profile screen
|
||||
};
|
||||
keey = get(profile, 'name');
|
||||
} else if (permlink) {
|
||||
content = await getPost(author, permlink, currentAccount.name);
|
||||
routeName = ROUTES.SCREENS.POST;
|
||||
params = {
|
||||
content,
|
||||
};
|
||||
keey = `${author}/${permlink}`;
|
||||
} else {
|
||||
profile = await getUser(author);
|
||||
routeName = ROUTES.SCREENS.PROFILE;
|
||||
params = {
|
||||
username: get(profile, 'name'),
|
||||
reputation: get(profile, 'reputation'),
|
||||
};
|
||||
keey = get(profile, 'name');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ const ProfileScreen = () => (
|
||||
username,
|
||||
votingPower,
|
||||
reverseHeader,
|
||||
deepLinkFilter,
|
||||
}) => (
|
||||
<Profile
|
||||
about={about}
|
||||
@ -76,6 +77,7 @@ const ProfileScreen = () => (
|
||||
votingPower={votingPower}
|
||||
isHideImage={isHideImage}
|
||||
reverseHeader={reverseHeader}
|
||||
deepLinkFilter={deepLinkFilter}
|
||||
/>
|
||||
)}
|
||||
</ProfileContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user