File size: 1,353 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import { Context } from '@automattic/calypso-router';
import { ReactElement } from 'react';
import AsyncLoad from 'calypso/components/async-load';
import { trackPageLoad, trackScrollPage } from 'calypso/reader/controller-helper';
interface UserProfileContext extends Context {
params: {
user_login?: string;
user_id?: string;
view?: string;
};
primary: ReactElement;
}
const analyticsPageTitle = 'Reader';
export function userProfile( ctx: Context, next: () => void ): void {
const context = ctx as UserProfileContext;
const view = context.params.view || 'posts';
const userLogin = context.params.user_login;
const userId = context.params.user_id;
const basePath = context.pathname;
const fullAnalyticsPageTitle =
analyticsPageTitle +
' > User > ' +
userLogin +
// Keep the view sentance cased for backward consistency.
` > ${ view[ 0 ].toUpperCase() + view.slice( 1 ) }`;
const mcKey = `user_${ view }`;
trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey );
context.primary = (
<AsyncLoad
require="calypso/reader/user-profile"
key={ 'user-posts-' + userLogin }
userLogin={ userLogin }
userId={ userId }
trackScrollPage={ trackScrollPage.bind(
null,
basePath,
fullAnalyticsPageTitle,
analyticsPageTitle,
mcKey
) }
path={ context.path }
view={ view }
/>
);
next();
}
|