title = community.title;
link = `/c/${community.name}`;
} else {
- name_ = `${community.name}@${hostname(community.actor_id)}`;
- title = `${community.title}@${hostname(community.actor_id)}`;
- link = !this.props.realLink
- ? `/community/${community.id}`
- : community.actor_id;
+ let domain = hostname(community.actor_id);
+ name_ = `${community.name}@${domain}`;
+ title = `${community.title}@${domain}`;
+ link = !this.props.realLink ? `/c/${name_}` : community.actor_id;
}
let apubName = `!${name_}`;
interface State {
communityRes: GetCommunityResponse;
siteRes: GetSiteResponse;
- communityId: number;
communityName: string;
communityLoading: boolean;
postsLoading: boolean;
private subscription: Subscription;
private emptyState: State = {
communityRes: undefined,
- communityId: Number(this.props.match.params.id),
communityName: this.props.match.params.name,
communityLoading: true,
postsLoading: true,
fetchCommunity() {
let form: GetCommunity = {
- id: this.state.communityId ? this.state.communityId : null,
name: this.state.communityName ? this.state.communityName : null,
auth: authField(false),
};
saved_only: false,
};
setOptionalAuth(getPostsForm, req.auth);
- this.setIdOrName(getPostsForm, id, name_);
+ this.setName(getPostsForm, name_);
promises.push(req.client.getPosts(getPostsForm));
} else {
let getCommentsForm: GetComments = {
saved_only: false,
};
setOptionalAuth(getCommentsForm, req.auth);
- this.setIdOrName(getCommentsForm, id, name_);
promises.push(req.client.getComments(getCommentsForm));
}
return promises;
}
- static setIdOrName(obj: any, id: number, name_: string) {
- if (id) {
- obj.community_id = id;
- } else {
- obj.community_name = name_;
- }
+ static setName(obj: any, name_: string) {
+ obj.community_name = name_;
}
componentDidUpdate(_: any, lastState: State) {
const sortStr = paramUpdates.sort || this.state.sort;
const page = paramUpdates.page || this.state.page;
- let typeView = this.state.communityName
- ? `/c/${this.state.communityName}`
- : `/community/${this.state.communityId}`;
+ let typeView = `/c/${this.state.communityName}`;
this.props.history.push(
`${typeView}/data_type/${dataTypeStr}/sort/${sortStr}/page/${page}`
limit: fetchLimit,
sort: this.state.sort,
type_: ListingType.Community,
- community_id: this.state.communityId,
community_name: this.state.communityName,
saved_only: false,
auth: authField(false),
limit: fetchLimit,
sort: this.state.sort,
type_: ListingType.Community,
- community_id: this.state.communityId,
community_name: this.state.communityName,
saved_only: false,
auth: authField(false),
apubName = `@${person.name}`;
link = `/u/${person.name}`;
} else {
- apubName = `@${person.name}@${hostname(person.actor_id)}`;
- link = !this.props.realLink ? `/user/${person.id}` : person.actor_id;
+ let domain = hostname(person.actor_id);
+ apubName = `@${person.name}@${domain}`;
+ link = !this.props.realLink
+ ? `/u/${person.name}@${domain}`
+ : person.actor_id;
}
let displayName = this.props.useApubName
editPostFindRes,
elementUrl,
fetchLimit,
- getIdFromProps,
getLanguage,
getUsernameFromProps,
languages,
interface PersonState {
personRes: GetPersonDetailsResponse;
- personId: number;
userName: string;
view: PersonDetailsView;
sort: SortType;
private subscription: Subscription;
private emptyState: PersonState = {
personRes: undefined,
- personId: getIdFromProps(this.props),
userName: getUsernameFromProps(this.props),
loading: true,
view: Person.getViewFromProps(this.props.match.view),
fetchUserData() {
let form: GetPersonDetails = {
- person_id: this.state.personId,
username: this.state.userName,
sort: this.state.sort,
saved_only: this.state.view === PersonDetailsView.Saved,
const viewStr = paramUpdates.view || PersonDetailsView[this.state.view];
const sortStr = paramUpdates.sort || this.state.sort;
- let typeView = this.state.userName
- ? `/u/${this.state.userName}`
- : `/user/${this.state.personId}`;
+ let typeView = `/u/${this.state.userName}`;
this.props.history.push(
`${typeView}/view/${viewStr}/sort/${sortStr}/page/${page}`
get prevCommunityId(): number {
if (this.props.match.params.id) {
return this.props.match.params.id;
- } else if (this.props.location.state) {
- let lastLocation = this.props.location.state.prevPath;
- if (lastLocation.includes("/community/")) {
- return Number(lastLocation.split("/community/")[1]);
- }
}
return null;
}
component: Post,
fetchInitialData: req => Post.fetchInitialData(req),
},
- {
- path: `/community/:id/data_type/:data_type/sort/:sort/page/:page`,
- component: Community,
- fetchInitialData: req => Community.fetchInitialData(req),
- },
- {
- path: `/community/:id`,
- component: Community,
- fetchInitialData: req => Community.fetchInitialData(req),
- },
{
path: `/c/:name/data_type/:data_type/sort/:sort/page/:page`,
component: Community,
component: Person,
fetchInitialData: req => Person.fetchInitialData(req),
},
- {
- path: `/user/:id/view/:view/sort/:sort/page/:page`,
- component: Person,
- fetchInitialData: req => Person.fetchInitialData(req),
- },
- {
- path: `/user/:id`,
- component: Person,
- fetchInitialData: req => Person.fetchInitialData(req),
- },
{
path: `/u/:username`,
component: Person,