in src/amo/pages/UserProfile/index.js [93:147]
constructor(props: InternalProps) {
super(props);
const {
clientApp,
dispatch,
errorHandler,
isOwner,
lang,
location,
match: { params },
reviews,
shouldRedirect,
user,
} = props;
dispatch(setViewContext(VIEW_CONTEXT_HOME));
if (shouldRedirect && user) {
dispatch(
sendServerRedirect({
status: 301,
url: `/${lang}/${clientApp}/user/${user.id}/`,
}),
);
return;
}
if (errorHandler.hasError()) {
log.warn('Not loading data because of an error.');
return;
}
if (!user) {
dispatch(
fetchUserAccount({
errorHandlerId: errorHandler.id,
// We should use `Number()` here but we need to fetch users by
// username in order to send a server redirect (to support previous
// URLs with usernames). That is why we have to ignore the Flow error
// here.
// $FlowIgnore
userId: params.userId,
}),
);
} else if (isOwner && !reviews) {
dispatch(
fetchUserReviews({
errorHandlerId: errorHandler.id,
page: this.getReviewsPage(location),
userId: user.id,
}),
);
}
}