Adding /f/ and /u/ in links now.

- Fixes #102
This commit is contained in:
Dessalines 2019-04-25 14:52:18 -07:00
parent b776912697
commit 4b76cccce4
18 changed files with 87 additions and 43 deletions

View file

@ -59,6 +59,14 @@ impl Crud<CommunityForm> for Community {
} }
} }
impl Community {
pub fn read_from_name(conn: &PgConnection, community_name: String) -> Result<Self, Error> {
use schema::community::dsl::*;
community.filter(name.eq(community_name))
.first::<Self>(conn)
}
}
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)] #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Community)] #[belongs_to(Community)]
#[table_name = "community_moderator"] #[table_name = "community_moderator"]

View file

@ -67,6 +67,10 @@ impl User_ {
Self::create(&conn, &edited_user) Self::create(&conn, &edited_user)
} }
pub fn read_from_name(conn: &PgConnection, from_user_name: String) -> Result<Self, Error> {
user_.filter(name.eq(from_user_name))
.first::<Self>(conn)
}
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]

View file

@ -188,7 +188,8 @@ pub struct GetPostsResponse {
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct GetCommunity { pub struct GetCommunity {
id: i32, id: Option<i32>,
name: Option<String>,
auth: Option<String> auth: Option<String>
} }
@ -311,7 +312,8 @@ pub struct GetFollowedCommunitiesResponse {
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct GetUserDetails { pub struct GetUserDetails {
user_id: i32, user_id: Option<i32>,
username: Option<String>,
sort: String, sort: String,
page: Option<i64>, page: Option<i64>,
limit: Option<i64>, limit: Option<i64>,
@ -1176,14 +1178,19 @@ impl Perform for GetCommunity {
None => None None => None
}; };
let community_view = match CommunityView::read(&conn, self.id, user_id) { let community_id = match self.id {
Some(id) => id,
None => Community::read_from_name(&conn, self.name.to_owned().unwrap_or("main".to_string()))?.id
};
let community_view = match CommunityView::read(&conn, community_id, user_id) {
Ok(community) => community, Ok(community) => community,
Err(_e) => { Err(_e) => {
return Err(self.error("Couldn't find Community"))? return Err(self.error("Couldn't find Community"))?
} }
}; };
let moderators = match CommunityModeratorView::for_community(&conn, self.id) { let moderators = match CommunityModeratorView::for_community(&conn, community_id) {
Ok(moderators) => moderators, Ok(moderators) => moderators,
Err(_e) => { Err(_e) => {
return Err(self.error("Couldn't find Community"))? return Err(self.error("Couldn't find Community"))?
@ -2042,7 +2049,13 @@ impl Perform for GetUserDetails {
//TODO add save //TODO add save
let sort = SortType::from_str(&self.sort)?; let sort = SortType::from_str(&self.sort)?;
let user_view = UserView::read(&conn, self.user_id)?; let user_details_id = match self.user_id {
Some(id) => id,
None => User_::read_from_name(&conn, self.username.to_owned().unwrap_or("admin".to_string()))?.id
};
let user_view = UserView::read(&conn, user_details_id)?;
// If its saved only, you don't care what creator it was // If its saved only, you don't care what creator it was
let posts = if self.saved_only { let posts = if self.saved_only {
PostView::list(&conn, PostView::list(&conn,
@ -2051,7 +2064,7 @@ impl Perform for GetUserDetails {
self.community_id, self.community_id,
None, None,
None, None,
Some(self.user_id), Some(user_details_id),
self.saved_only, self.saved_only,
false, false,
self.page, self.page,
@ -2061,7 +2074,7 @@ impl Perform for GetUserDetails {
PostListingType::All, PostListingType::All,
&sort, &sort,
self.community_id, self.community_id,
Some(self.user_id), Some(user_details_id),
None, None,
None, None,
self.saved_only, self.saved_only,
@ -2075,7 +2088,7 @@ impl Perform for GetUserDetails {
None, None,
None, None,
None, None,
Some(self.user_id), Some(user_details_id),
self.saved_only, self.saved_only,
self.page, self.page,
self.limit)? self.limit)?
@ -2083,7 +2096,7 @@ impl Perform for GetUserDetails {
CommentView::list(&conn, CommentView::list(&conn,
&sort, &sort,
None, None,
Some(self.user_id), Some(user_details_id),
None, None,
None, None,
self.saved_only, self.saved_only,
@ -2091,8 +2104,8 @@ impl Perform for GetUserDetails {
self.limit)? self.limit)?
}; };
let follows = CommunityFollowerView::for_user(&conn, self.user_id)?; let follows = CommunityFollowerView::for_user(&conn, user_details_id)?;
let moderates = CommunityModeratorView::for_user(&conn, self.user_id)?; let moderates = CommunityModeratorView::for_user(&conn, user_details_id)?;
// Return the jwt // Return the jwt
Ok( Ok(

View file

@ -69,7 +69,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
<div id={`comment-${node.comment.id}`} className={`details ml-4 ${this.isCommentNew ? 'mark' : ''}`}> <div id={`comment-${node.comment.id}`} className={`details ml-4 ${this.isCommentNew ? 'mark' : ''}`}>
<ul class="list-inline mb-0 text-muted small"> <ul class="list-inline mb-0 text-muted small">
<li className="list-inline-item"> <li className="list-inline-item">
<Link className="text-info" to={`/user/${node.comment.creator_id}`}>{node.comment.creator_name}</Link> <Link className="text-info" to={`/u/${node.comment.creator_name}`}>{node.comment.creator_name}</Link>
</li> </li>
{this.isMod && {this.isMod &&
<li className="list-inline-item badge badge-secondary">mod</li> <li className="list-inline-item badge badge-secondary">mod</li>

View file

@ -73,7 +73,7 @@ export class Communities extends Component<any, CommunitiesState> {
<tbody> <tbody>
{this.state.communities.map(community => {this.state.communities.map(community =>
<tr> <tr>
<td><Link to={`/community/${community.id}`}>{community.name}</Link></td> <td><Link to={`/f/${community.name}`}>{community.name}</Link></td>
<td>{community.title}</td> <td>{community.title}</td>
<td>{community.category_name}</td> <td>{community.category_name}</td>
<td class="text-right d-none d-md-table-cell">{community.number_of_subscribers}</td> <td class="text-right d-none d-md-table-cell">{community.number_of_subscribers}</td>

View file

@ -11,7 +11,7 @@ import { Community } from '../interfaces';
interface CommunityFormProps { interface CommunityFormProps {
community?: Community; // If a community is given, that means this is an edit community?: Community; // If a community is given, that means this is an edit
onCancel?(): any; onCancel?(): any;
onCreate?(id: number): any; onCreate?(community: Community): any;
onEdit?(community: Community): any; onEdit?(community: Community): any;
} }
@ -167,7 +167,7 @@ export class CommunityForm extends Component<CommunityFormProps, CommunityFormSt
} else if (op == UserOperation.CreateCommunity) { } else if (op == UserOperation.CreateCommunity) {
let res: CommunityResponse = msg; let res: CommunityResponse = msg;
this.state.loading = false; this.state.loading = false;
this.props.onCreate(res.community.id); this.props.onCreate(res.community);
} }
// TODO is this necessary? // TODO is this necessary?

View file

@ -10,6 +10,7 @@ import { msgOp } from '../utils';
interface State { interface State {
community: CommunityI; community: CommunityI;
communityId: number; communityId: number;
communityName: string;
moderators: Array<CommunityUser>; moderators: Array<CommunityUser>;
admins: Array<UserView>; admins: Array<UserView>;
loading: boolean; loading: boolean;
@ -36,6 +37,7 @@ export class Community extends Component<any, State> {
moderators: [], moderators: [],
admins: [], admins: [],
communityId: Number(this.props.match.params.id), communityId: Number(this.props.match.params.id),
communityName: this.props.match.params.name,
loading: true loading: true
} }
@ -52,7 +54,12 @@ export class Community extends Component<any, State> {
() => console.log('complete') () => console.log('complete')
); );
if (this.state.communityId) {
WebSocketService.Instance.getCommunity(this.state.communityId); WebSocketService.Instance.getCommunity(this.state.communityId);
} else if (this.state.communityName) {
WebSocketService.Instance.getCommunityByName(this.state.communityName);
}
} }
componentWillUnmount() { componentWillUnmount() {
@ -71,7 +78,7 @@ export class Community extends Component<any, State> {
<small className="ml-2 text-muted font-italic">removed</small> <small className="ml-2 text-muted font-italic">removed</small>
} }
</h5> </h5>
<PostListings communityId={this.state.communityId} /> {this.state.community && <PostListings communityId={this.state.community.id} />}
</div> </div>
<div class="col-12 col-md-3"> <div class="col-12 col-md-3">
<Sidebar <Sidebar

View file

@ -1,5 +1,6 @@
import { Component } from 'inferno'; import { Component } from 'inferno';
import { CommunityForm } from './community-form'; import { CommunityForm } from './community-form';
import { Community } from '../interfaces';
export class CreateCommunity extends Component<any, any> { export class CreateCommunity extends Component<any, any> {
@ -25,8 +26,8 @@ export class CreateCommunity extends Component<any, any> {
) )
} }
handleCommunityCreate(id: number) { handleCommunityCreate(community: Community) {
this.props.history.push(`/community/${id}`); this.props.history.push(`/f/${community.name}`);
} }
} }

View file

@ -58,7 +58,7 @@ export class Inbox extends Component<any, InboxState> {
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h5>Inbox for <Link to={`/user/${user.id}`}>{user.username}</Link></h5> <h5>Inbox for <Link to={`/u/${user.username}`}>{user.username}</Link></h5>
{this.selects()} {this.selects()}
{this.replies()} {this.replies()}
{this.paginator()} {this.paginator()}

View file

@ -96,7 +96,7 @@ export class Main extends Component<MainProps, MainState> {
<h5>Subscribed forums</h5> <h5>Subscribed forums</h5>
<ul class="list-inline"> <ul class="list-inline">
{this.state.subscribedCommunities.map(community => {this.state.subscribedCommunities.map(community =>
<li class="list-inline-item"><Link to={`/community/${community.community_id}`}>{community.community_name}</Link></li> <li class="list-inline-item"><Link to={`/f/${community.community_name}`}>{community.community_name}</Link></li>
)} )}
</ul> </ul>
</div> </div>
@ -116,7 +116,7 @@ export class Main extends Component<MainProps, MainState> {
<h5>Trending <Link class="text-white" to="/communities">forums</Link></h5> <h5>Trending <Link class="text-white" to="/communities">forums</Link></h5>
<ul class="list-inline"> <ul class="list-inline">
{this.state.trendingCommunities.map(community => {this.state.trendingCommunities.map(community =>
<li class="list-inline-item"><Link to={`/community/${community.id}`}>{community.name}</Link></li> <li class="list-inline-item"><Link to={`/f/${community.name}`}>{community.name}</Link></li>
)} )}
</ul> </ul>
</div> </div>
@ -158,7 +158,7 @@ export class Main extends Component<MainProps, MainState> {
<ul class="my-1 list-inline small"> <ul class="my-1 list-inline small">
<li class="list-inline-item">admins: </li> <li class="list-inline-item">admins: </li>
{this.state.site.admins.map(admin => {this.state.site.admins.map(admin =>
<li class="list-inline-item"><Link class="text-info" to={`/user/${admin.id}`}>{admin.name}</Link></li> <li class="list-inline-item"><Link class="text-info" to={`/u/${admin.name}`}>{admin.name}</Link></li>
)} )}
</ul> </ul>
{this.state.site.site.description && {this.state.site.site.description &&

View file

@ -84,7 +84,7 @@ export class Modlog extends Component<any, ModlogState> {
{this.state.combined.map(i => {this.state.combined.map(i =>
<tr> <tr>
<td><MomentTime data={i.data} /></td> <td><MomentTime data={i.data} /></td>
<td><Link to={`/user/${i.data.mod_user_id}`}>{i.data.mod_user_name}</Link></td> <td><Link to={`/u/${i.data.mod_user_name}`}>{i.data.mod_user_name}</Link></td>
<td> <td>
{i.type_ == 'removed_posts' && {i.type_ == 'removed_posts' &&
<> <>
@ -103,14 +103,14 @@ export class Modlog extends Component<any, ModlogState> {
<> <>
{(i.data as ModRemoveComment).removed? 'Removed' : 'Restored'} {(i.data as ModRemoveComment).removed? 'Removed' : 'Restored'}
<span> Comment <Link to={`/post/${(i.data as ModRemoveComment).post_id}/comment/${(i.data as ModRemoveComment).comment_id}`}>{(i.data as ModRemoveComment).comment_content}</Link></span> <span> Comment <Link to={`/post/${(i.data as ModRemoveComment).post_id}/comment/${(i.data as ModRemoveComment).comment_id}`}>{(i.data as ModRemoveComment).comment_content}</Link></span>
<span> by <Link to={`/user/${(i.data as ModRemoveComment).comment_user_id}`}>{(i.data as ModRemoveComment).comment_user_name}</Link></span> <span> by <Link to={`/u/${(i.data as ModRemoveComment).comment_user_name}`}>{(i.data as ModRemoveComment).comment_user_name}</Link></span>
<div>{(i.data as ModRemoveComment).reason && ` reason: ${(i.data as ModRemoveComment).reason}`}</div> <div>{(i.data as ModRemoveComment).reason && ` reason: ${(i.data as ModRemoveComment).reason}`}</div>
</> </>
} }
{i.type_ == 'removed_communities' && {i.type_ == 'removed_communities' &&
<> <>
{(i.data as ModRemoveCommunity).removed ? 'Removed' : 'Restored'} {(i.data as ModRemoveCommunity).removed ? 'Removed' : 'Restored'}
<span> Community <Link to={`/community/${(i.data as ModRemoveCommunity).community_id}`}>{(i.data as ModRemoveCommunity).community_name}</Link></span> <span> Community <Link to={`/f/${(i.data as ModRemoveCommunity).community_name}`}>{(i.data as ModRemoveCommunity).community_name}</Link></span>
<div>{(i.data as ModRemoveCommunity).reason && ` reason: ${(i.data as ModRemoveCommunity).reason}`}</div> <div>{(i.data as ModRemoveCommunity).reason && ` reason: ${(i.data as ModRemoveCommunity).reason}`}</div>
<div>{(i.data as ModRemoveCommunity).expires && ` expires: ${moment.utc((i.data as ModRemoveCommunity).expires).fromNow()}`}</div> <div>{(i.data as ModRemoveCommunity).expires && ` expires: ${moment.utc((i.data as ModRemoveCommunity).expires).fromNow()}`}</div>
</> </>
@ -118,9 +118,9 @@ export class Modlog extends Component<any, ModlogState> {
{i.type_ == 'banned_from_community' && {i.type_ == 'banned_from_community' &&
<> <>
<span>{(i.data as ModBanFromCommunity).banned ? 'Banned ' : 'Unbanned '} </span> <span>{(i.data as ModBanFromCommunity).banned ? 'Banned ' : 'Unbanned '} </span>
<span><Link to={`/user/${(i.data as ModBanFromCommunity).other_user_id}`}>{(i.data as ModBanFromCommunity).other_user_name}</Link></span> <span><Link to={`/u/${(i.data as ModBanFromCommunity).other_user_name}`}>{(i.data as ModBanFromCommunity).other_user_name}</Link></span>
<span> from the community </span> <span> from the community </span>
<span><Link to={`/community/${(i.data as ModBanFromCommunity).community_id}`}>{(i.data as ModBanFromCommunity).community_name}</Link></span> <span><Link to={`/f/${(i.data as ModBanFromCommunity).community_name}`}>{(i.data as ModBanFromCommunity).community_name}</Link></span>
<div>{(i.data as ModBanFromCommunity).reason && ` reason: ${(i.data as ModBanFromCommunity).reason}`}</div> <div>{(i.data as ModBanFromCommunity).reason && ` reason: ${(i.data as ModBanFromCommunity).reason}`}</div>
<div>{(i.data as ModBanFromCommunity).expires && ` expires: ${moment.utc((i.data as ModBanFromCommunity).expires).fromNow()}`}</div> <div>{(i.data as ModBanFromCommunity).expires && ` expires: ${moment.utc((i.data as ModBanFromCommunity).expires).fromNow()}`}</div>
</> </>
@ -128,15 +128,15 @@ export class Modlog extends Component<any, ModlogState> {
{i.type_ == 'added_to_community' && {i.type_ == 'added_to_community' &&
<> <>
<span>{(i.data as ModAddCommunity).removed ? 'Removed ' : 'Appointed '} </span> <span>{(i.data as ModAddCommunity).removed ? 'Removed ' : 'Appointed '} </span>
<span><Link to={`/user/${(i.data as ModAddCommunity).other_user_id}`}>{(i.data as ModAddCommunity).other_user_name}</Link></span> <span><Link to={`/u/${(i.data as ModAddCommunity).other_user_name}`}>{(i.data as ModAddCommunity).other_user_name}</Link></span>
<span> as a mod to the community </span> <span> as a mod to the community </span>
<span><Link to={`/community/${(i.data as ModAddCommunity).community_id}`}>{(i.data as ModAddCommunity).community_name}</Link></span> <span><Link to={`/f/${(i.data as ModAddCommunity).community_name}`}>{(i.data as ModAddCommunity).community_name}</Link></span>
</> </>
} }
{i.type_ == 'banned' && {i.type_ == 'banned' &&
<> <>
<span>{(i.data as ModBan).banned ? 'Banned ' : 'Unbanned '} </span> <span>{(i.data as ModBan).banned ? 'Banned ' : 'Unbanned '} </span>
<span><Link to={`/user/${(i.data as ModBan).other_user_id}`}>{(i.data as ModBan).other_user_name}</Link></span> <span><Link to={`/u/${(i.data as ModBan).other_user_name}`}>{(i.data as ModBan).other_user_name}</Link></span>
<div>{(i.data as ModBan).reason && ` reason: ${(i.data as ModBan).reason}`}</div> <div>{(i.data as ModBan).reason && ` reason: ${(i.data as ModBan).reason}`}</div>
<div>{(i.data as ModBan).expires && ` expires: ${moment.utc((i.data as ModBan).expires).fromNow()}`}</div> <div>{(i.data as ModBan).expires && ` expires: ${moment.utc((i.data as ModBan).expires).fromNow()}`}</div>
</> </>
@ -144,7 +144,7 @@ export class Modlog extends Component<any, ModlogState> {
{i.type_ == 'added' && {i.type_ == 'added' &&
<> <>
<span>{(i.data as ModAdd).removed ? 'Removed ' : 'Appointed '} </span> <span>{(i.data as ModAdd).removed ? 'Removed ' : 'Appointed '} </span>
<span><Link to={`/user/${(i.data as ModAdd).other_user_id}`}>{(i.data as ModAdd).other_user_name}</Link></span> <span><Link to={`/u/${(i.data as ModAdd).other_user_name}`}>{(i.data as ModAdd).other_user_name}</Link></span>
<span> as an admin </span> <span> as an admin </span>
</> </>
} }
@ -165,7 +165,7 @@ export class Modlog extends Component<any, ModlogState> {
<h5 class=""><svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg></h5> : <h5 class=""><svg class="icon icon-spinner spin"><use xlinkHref="#icon-spinner"></use></svg></h5> :
<div> <div>
<h5> <h5>
{this.state.communityName && <Link className="text-white" to={`/community/${this.state.communityId}`}>/f/{this.state.communityName} </Link>} {this.state.communityName && <Link className="text-white" to={`/f/${this.state.communityName}`}>/f/{this.state.communityName} </Link>}
<span>Modlog</span> <span>Modlog</span>
</h5> </h5>
<div class="table-responsive"> <div class="table-responsive">

View file

@ -129,7 +129,7 @@ export class Navbar extends Component<any, NavbarState> {
handleOverviewClick(i: Navbar) { handleOverviewClick(i: Navbar) {
i.state.expandUserDropdown = false; i.state.expandUserDropdown = false;
i.setState(i.state); i.setState(i.state);
let userPage = `/user/${UserService.Instance.user.id}`; let userPage = `/u/${UserService.Instance.user.username}`;
i.context.router.history.push(userPage); i.context.router.history.push(userPage);
} }

View file

@ -103,7 +103,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
<ul class="list-inline mb-0 text-muted small"> <ul class="list-inline mb-0 text-muted small">
<li className="list-inline-item"> <li className="list-inline-item">
<span>by </span> <span>by </span>
<Link className="text-info" to={`/user/${post.creator_id}`}>{post.creator_name}</Link> <Link className="text-info" to={`/u/${post.creator_name}`}>{post.creator_name}</Link>
{this.isMod && {this.isMod &&
<span className="mx-1 badge badge-secondary">mod</span> <span className="mx-1 badge badge-secondary">mod</span>
} }
@ -113,7 +113,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
{this.props.showCommunity && {this.props.showCommunity &&
<span> <span>
<span> to </span> <span> to </span>
<Link to={`/community/${post.community_id}`}>{post.community_name}</Link> <Link to={`/f/${post.community_name}`}>{post.community_name}</Link>
</span> </span>
} }
</li> </li>

View file

@ -57,7 +57,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
<small className="ml-2 text-muted font-italic">removed</small> <small className="ml-2 text-muted font-italic">removed</small>
} }
</h5> </h5>
<Link className="text-muted" to={`/community/${community.id}`}>/f/{community.name}</Link> <Link className="text-muted" to={`/f/${community.name}`}>/f/{community.name}</Link>
<ul class="list-inline mb-1 text-muted small font-weight-bold"> <ul class="list-inline mb-1 text-muted small font-weight-bold">
{this.canMod && {this.canMod &&
<> <>
@ -107,7 +107,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
<ul class="list-inline small"> <ul class="list-inline small">
<li class="list-inline-item">mods: </li> <li class="list-inline-item">mods: </li>
{this.props.moderators.map(mod => {this.props.moderators.map(mod =>
<li class="list-inline-item"><Link class="text-info" to={`/user/${mod.user_id}`}>{mod.user_name}</Link></li> <li class="list-inline-item"><Link class="text-info" to={`/u/${mod.user_name}`}>{mod.user_name}</Link></li>
)} )}
</ul> </ul>
<div> <div>

View file

@ -16,6 +16,7 @@ enum View {
interface UserState { interface UserState {
user: UserView; user: UserView;
user_id: number; user_id: number;
username: string;
follows: Array<CommunityUser>; follows: Array<CommunityUser>;
moderates: Array<CommunityUser>; moderates: Array<CommunityUser>;
comments: Array<Comment>; comments: Array<Comment>;
@ -41,6 +42,7 @@ export class User extends Component<any, UserState> {
comment_score: null, comment_score: null,
}, },
user_id: null, user_id: null,
username: null,
follows: [], follows: [],
moderates: [], moderates: [],
comments: [], comments: [],
@ -56,6 +58,7 @@ export class User extends Component<any, UserState> {
this.state = this.emptyState; this.state = this.emptyState;
this.state.user_id = Number(this.props.match.params.id); this.state.user_id = Number(this.props.match.params.id);
this.state.username = this.props.match.params.username;
this.subscription = WebSocketService.Instance.subject this.subscription = WebSocketService.Instance.subject
.pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
@ -206,7 +209,7 @@ export class User extends Component<any, UserState> {
<h5>Moderates</h5> <h5>Moderates</h5>
<ul class="list-unstyled"> <ul class="list-unstyled">
{this.state.moderates.map(community => {this.state.moderates.map(community =>
<li><Link to={`/community/${community.community_id}`}>{community.community_name}</Link></li> <li><Link to={`/f/${community.community_name}`}>{community.community_name}</Link></li>
)} )}
</ul> </ul>
</div> </div>
@ -224,7 +227,7 @@ export class User extends Component<any, UserState> {
<h5>Subscribed</h5> <h5>Subscribed</h5>
<ul class="list-unstyled"> <ul class="list-unstyled">
{this.state.follows.map(community => {this.state.follows.map(community =>
<li><Link to={`/community/${community.community_id}`}>{community.community_name}</Link></li> <li><Link to={`/f/${community.community_name}`}>{community.community_name}</Link></li>
)} )}
</ul> </ul>
</div> </div>
@ -259,6 +262,7 @@ export class User extends Component<any, UserState> {
refetch() { refetch() {
let form: GetUserDetailsForm = { let form: GetUserDetailsForm = {
user_id: this.state.user_id, user_id: this.state.user_id,
username: this.state.username,
sort: SortType[this.state.sort], sort: SortType[this.state.sort],
saved_only: this.state.view == View.Saved, saved_only: this.state.view == View.Saved,
page: this.state.page, page: this.state.page,

View file

@ -48,8 +48,9 @@ class Index extends Component<any, any> {
<Route path={`/post/:id/comment/:comment_id`} component={Post} /> <Route path={`/post/:id/comment/:comment_id`} component={Post} />
<Route path={`/post/:id`} component={Post} /> <Route path={`/post/:id`} component={Post} />
<Route path={`/community/:id`} component={Community} /> <Route path={`/community/:id`} component={Community} />
<Route path={`/user/:id/:heading`} component={User} /> <Route path={`/f/:name`} component={Community} />
<Route path={`/user/:id`} component={User} /> <Route path={`/user/:id`} component={User} />
<Route path={`/u/:username`} component={User} />
<Route path={`/inbox`} component={Inbox} /> <Route path={`/inbox`} component={Inbox} />
<Route path={`/modlog/community/:community_id`} component={Modlog} /> <Route path={`/modlog/community/:community_id`} component={Modlog} />
<Route path={`/modlog`} component={Modlog} /> <Route path={`/modlog`} component={Modlog} />

View file

@ -141,8 +141,9 @@ export interface GetFollowedCommunitiesResponse {
} }
export interface GetUserDetailsForm { export interface GetUserDetailsForm {
user_id: number; user_id?: number;
sort: string; // TODO figure this one out username?: string;
sort: string;
page?: number; page?: number;
limit?: number; limit?: number;
community_id?: number; community_id?: number;

View file

@ -81,6 +81,11 @@ export class WebSocketService {
this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, data)); this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, data));
} }
public getCommunityByName(name: string) {
let data = {name: name, auth: UserService.Instance.auth };
this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, data));
}
public createComment(commentForm: CommentForm) { public createComment(commentForm: CommentForm) {
this.setAuth(commentForm); this.setAuth(commentForm);
this.subject.next(this.wsSendWrapper(UserOperation.CreateComment, commentForm)); this.subject.next(this.wsSendWrapper(UserOperation.CreateComment, commentForm));