2019-09-18 19:52:39 +02:00
|
|
|
import React, { Component } from "react";
|
2019-08-22 16:56:39 +02:00
|
|
|
import {
|
|
|
|
withStyles,
|
|
|
|
Typography,
|
|
|
|
Avatar,
|
|
|
|
Button,
|
|
|
|
CircularProgress,
|
|
|
|
Paper,
|
|
|
|
Tooltip,
|
|
|
|
Dialog,
|
|
|
|
DialogTitle,
|
|
|
|
DialogContent,
|
|
|
|
DialogContentText,
|
|
|
|
DialogActions,
|
|
|
|
Toolbar,
|
|
|
|
IconButton
|
2019-09-18 19:52:39 +02:00
|
|
|
} from "@material-ui/core";
|
|
|
|
import { styles } from "./PageLayout.styles";
|
|
|
|
import Mastodon from "megalodon";
|
|
|
|
import { Account } from "../types/Account";
|
|
|
|
import { Status } from "../types/Status";
|
|
|
|
import { Relationship } from "../types/Relationship";
|
|
|
|
import Post from "../components/Post";
|
|
|
|
import { withSnackbar } from "notistack";
|
|
|
|
import { LinkableIconButton } from "../interfaces/overrides";
|
|
|
|
import { emojifyString } from "../utilities/emojis";
|
2020-01-23 16:21:58 +01:00
|
|
|
import Masonry from "react-masonry-css";
|
|
|
|
import { getUserDefaultBool } from "..//utilities/settings";
|
2019-08-22 16:56:39 +02:00
|
|
|
|
2019-09-18 19:52:39 +02:00
|
|
|
import AccountEditIcon from "mdi-material-ui/AccountEdit";
|
|
|
|
import PersonAddIcon from "@material-ui/icons/PersonAdd";
|
|
|
|
import PersonAddDisabledIcon from "@material-ui/icons/PersonAddDisabled";
|
|
|
|
import AccountMinusIcon from "mdi-material-ui/AccountMinus";
|
|
|
|
import ChatIcon from "@material-ui/icons/Chat";
|
|
|
|
import AccountRemoveIcon from "mdi-material-ui/AccountRemove";
|
|
|
|
import AccountHeartIcon from "mdi-material-ui/AccountHeart";
|
|
|
|
import OpenInNewIcon from "@material-ui/icons/OpenInNew";
|
2019-04-27 22:12:26 +02:00
|
|
|
|
2019-03-28 21:46:19 +01:00
|
|
|
interface IProfilePageState {
|
2019-03-30 22:13:49 +01:00
|
|
|
account?: Account;
|
2019-03-31 03:20:55 +02:00
|
|
|
relationship?: Relationship;
|
2019-03-30 22:13:49 +01:00
|
|
|
posts?: [Status];
|
|
|
|
viewIsLoading: boolean;
|
|
|
|
viewDidLoad?: boolean;
|
|
|
|
viewDidError?: boolean;
|
|
|
|
viewDidErrorCode?: string;
|
2019-03-31 23:53:17 +02:00
|
|
|
blockDialogOpen: boolean;
|
2020-01-23 16:21:58 +01:00
|
|
|
isMasonryLayout?: boolean;
|
2019-03-28 21:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class ProfilePage extends Component<any, IProfilePageState> {
|
2019-03-30 22:13:49 +01:00
|
|
|
client: Mastodon;
|
|
|
|
|
2019-03-28 21:46:19 +01:00
|
|
|
constructor(props: any) {
|
|
|
|
super(props);
|
|
|
|
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client = new Mastodon(
|
|
|
|
localStorage.getItem("access_token") as string,
|
|
|
|
localStorage.getItem("baseurl") + "/api/v1"
|
|
|
|
);
|
2019-03-30 22:13:49 +01:00
|
|
|
|
|
|
|
this.state = {
|
2019-03-31 23:53:17 +02:00
|
|
|
viewIsLoading: true,
|
2020-01-23 16:21:58 +01:00
|
|
|
blockDialogOpen: false,
|
2020-01-23 17:02:46 +01:00
|
|
|
isMasonryLayout: getUserDefaultBool("isMasonryLayout")
|
2019-09-18 19:52:39 +02:00
|
|
|
};
|
2019-03-30 22:13:49 +01:00
|
|
|
}
|
|
|
|
|
2019-03-31 23:53:17 +02:00
|
|
|
toggleBlockDialog() {
|
|
|
|
if (this.state.relationship && !this.state.relationship.blocking)
|
2019-09-18 19:52:39 +02:00
|
|
|
this.setState({ blockDialogOpen: !this.state.blockDialogOpen });
|
|
|
|
else this.toggleBlock();
|
2019-03-31 23:53:17 +02:00
|
|
|
}
|
|
|
|
|
2019-03-31 03:20:55 +02:00
|
|
|
getAccountData(id: string) {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.get(`/accounts/${id}`)
|
|
|
|
.then((resp: any) => {
|
|
|
|
let profile: Account = resp.data;
|
2019-03-28 21:46:19 +01:00
|
|
|
|
2019-09-18 19:52:39 +02:00
|
|
|
const div = document.createElement("div");
|
|
|
|
div.innerHTML = profile.note;
|
|
|
|
profile.note = div.textContent || div.innerText || "";
|
2019-03-28 21:46:19 +01:00
|
|
|
|
2019-09-18 19:52:39 +02:00
|
|
|
this.setState({
|
|
|
|
account: profile
|
|
|
|
});
|
2019-03-30 22:13:49 +01:00
|
|
|
})
|
2019-09-18 19:52:39 +02:00
|
|
|
.catch((error: Error) => {
|
|
|
|
this.setState({
|
|
|
|
viewIsLoading: false,
|
|
|
|
viewDidError: true,
|
|
|
|
viewDidErrorCode: error.message
|
|
|
|
});
|
|
|
|
});
|
2019-03-31 23:53:17 +02:00
|
|
|
this.getRelationships();
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.get(`/accounts/${id}/statuses`)
|
|
|
|
.then((resp: any) => {
|
|
|
|
this.setState({
|
|
|
|
posts: resp.data,
|
|
|
|
viewIsLoading: false,
|
|
|
|
viewDidLoad: true,
|
|
|
|
viewDidError: false
|
|
|
|
});
|
2019-03-30 22:13:49 +01:00
|
|
|
})
|
2019-09-18 19:52:39 +02:00
|
|
|
.catch((err: Error) => {
|
|
|
|
this.setState({
|
|
|
|
viewIsLoading: false,
|
|
|
|
viewDidError: true,
|
|
|
|
viewDidErrorCode: err.message
|
|
|
|
});
|
|
|
|
});
|
2019-03-31 03:20:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(props: any) {
|
|
|
|
this.getAccountData(props.match.params.profileId);
|
|
|
|
window.scrollTo(0, 0);
|
2019-03-30 22:13:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillMount() {
|
2019-09-18 19:52:39 +02:00
|
|
|
const {
|
|
|
|
match: { params }
|
|
|
|
} = this.props;
|
2019-03-31 03:20:55 +02:00
|
|
|
this.getAccountData(params.profileId);
|
|
|
|
}
|
2019-03-30 22:13:49 +01:00
|
|
|
|
2019-04-27 22:12:26 +02:00
|
|
|
isItMe(): boolean {
|
|
|
|
if (this.state.account) {
|
2019-09-18 19:52:39 +02:00
|
|
|
return (
|
|
|
|
this.state.account.id ===
|
|
|
|
JSON.parse(localStorage.getItem("account") as string).id
|
|
|
|
);
|
2019-04-27 22:12:26 +02:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-31 23:53:17 +02:00
|
|
|
getRelationships() {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.get("/accounts/relationships", {
|
|
|
|
id: this.props.match.params.profileId
|
2019-03-30 22:13:49 +01:00
|
|
|
})
|
2019-09-18 19:52:39 +02:00
|
|
|
.then((resp: any) => {
|
|
|
|
let relationship: Relationship = resp.data[0];
|
|
|
|
this.setState({ relationship });
|
|
|
|
})
|
|
|
|
.catch((error: Error) => {
|
|
|
|
this.setState({
|
|
|
|
viewIsLoading: false,
|
|
|
|
viewDidError: true,
|
|
|
|
viewDidErrorCode: error.message
|
|
|
|
});
|
|
|
|
});
|
2019-03-28 21:46:19 +01:00
|
|
|
}
|
|
|
|
|
2019-03-30 22:13:49 +01:00
|
|
|
loadMoreTimelinePieces() {
|
2019-09-18 19:52:39 +02:00
|
|
|
const {
|
|
|
|
match: { params }
|
|
|
|
} = this.props;
|
|
|
|
this.setState({ viewDidLoad: false, viewIsLoading: true });
|
2019-04-24 20:29:33 +02:00
|
|
|
if (this.state.posts && this.state.posts.length > 0) {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.get(`/accounts/${params.profileId}/statuses`, {
|
|
|
|
max_id: this.state.posts[this.state.posts.length - 1].id,
|
|
|
|
limit: 20
|
2019-03-30 22:13:49 +01:00
|
|
|
})
|
2019-09-18 19:52:39 +02:00
|
|
|
.then((resp: any) => {
|
|
|
|
let newPosts: [Status] = resp.data;
|
|
|
|
let posts = this.state.posts as [Status];
|
|
|
|
if (newPosts.length <= 0) {
|
|
|
|
this.props.enqueueSnackbar("Reached end of posts", {
|
|
|
|
variant: "error"
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
newPosts.forEach((post: Status) => {
|
|
|
|
posts.push(post);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
viewIsLoading: false,
|
|
|
|
viewDidLoad: true,
|
|
|
|
posts
|
|
|
|
});
|
2019-03-30 22:13:49 +01:00
|
|
|
})
|
2019-09-18 19:52:39 +02:00
|
|
|
.catch((err: Error) => {
|
|
|
|
this.setState({
|
|
|
|
viewIsLoading: false,
|
|
|
|
viewDidError: true,
|
|
|
|
viewDidErrorCode: err.message
|
|
|
|
});
|
|
|
|
this.props.enqueueSnackbar("Failed to get posts", {
|
|
|
|
variant: "error"
|
|
|
|
});
|
2019-03-30 22:13:49 +01:00
|
|
|
});
|
2019-04-24 20:29:33 +02:00
|
|
|
} else {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.props.enqueueSnackbar("Reached end of posts", {
|
|
|
|
variant: "error"
|
|
|
|
});
|
2019-04-26 00:28:30 +02:00
|
|
|
this.setState({
|
|
|
|
viewIsLoading: false,
|
|
|
|
viewDidLoad: true
|
2019-09-18 19:52:39 +02:00
|
|
|
});
|
2019-03-30 22:13:49 +01:00
|
|
|
}
|
2019-09-18 19:52:39 +02:00
|
|
|
}
|
|
|
|
|
2019-03-31 23:53:17 +02:00
|
|
|
toggleFollow() {
|
|
|
|
if (this.state.relationship) {
|
|
|
|
if (this.state.relationship.following) {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.post(
|
|
|
|
`/accounts/${
|
|
|
|
this.state.account
|
|
|
|
? this.state.account.id
|
|
|
|
: this.props.match.params.profileId
|
|
|
|
}/unfollow`
|
|
|
|
)
|
|
|
|
.then((resp: any) => {
|
|
|
|
let relationship: Relationship = resp.data;
|
|
|
|
this.setState({ relationship });
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"You are no longer following this account."
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.catch((err: Error) => {
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"Couldn't unfollow account: " + err.name,
|
|
|
|
{ variant: "error" }
|
|
|
|
);
|
|
|
|
console.error(err.message);
|
|
|
|
});
|
2019-03-31 23:53:17 +02:00
|
|
|
} else {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.post(
|
|
|
|
`/accounts/${
|
|
|
|
this.state.account
|
|
|
|
? this.state.account.id
|
|
|
|
: this.props.match.params.profileId
|
|
|
|
}/follow`
|
|
|
|
)
|
|
|
|
.then((resp: any) => {
|
|
|
|
let relationship: Relationship = resp.data;
|
|
|
|
this.setState({ relationship });
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"You are now following this account."
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.catch((err: Error) => {
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"Couldn't follow account: " + err.name,
|
|
|
|
{ variant: "error" }
|
|
|
|
);
|
|
|
|
console.error(err.message);
|
|
|
|
});
|
2019-03-31 23:53:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleBlock() {
|
|
|
|
if (this.state.relationship) {
|
|
|
|
if (this.state.relationship.blocking) {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.post(
|
|
|
|
`/accounts/${
|
|
|
|
this.state.account
|
|
|
|
? this.state.account.id
|
|
|
|
: this.props.match.params.profileId
|
|
|
|
}/unblock`
|
|
|
|
)
|
|
|
|
.then((resp: any) => {
|
|
|
|
let relationship: Relationship = resp.data;
|
|
|
|
this.setState({ relationship });
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"You are no longer blocking this account."
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.catch((err: Error) => {
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"Couldn't unblock account: " + err.name,
|
|
|
|
{ variant: "error" }
|
|
|
|
);
|
|
|
|
console.error(err.message);
|
|
|
|
});
|
2019-03-31 23:53:17 +02:00
|
|
|
} else {
|
2019-09-18 19:52:39 +02:00
|
|
|
this.client
|
|
|
|
.post(
|
|
|
|
`/accounts/${
|
|
|
|
this.state.account
|
|
|
|
? this.state.account.id
|
|
|
|
: this.props.match.params.profileId
|
|
|
|
}/block`
|
|
|
|
)
|
|
|
|
.then((resp: any) => {
|
|
|
|
let relationship: Relationship = resp.data;
|
|
|
|
this.setState({ relationship });
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"You are now blocking this account."
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.catch((err: Error) => {
|
|
|
|
this.props.enqueueSnackbar(
|
|
|
|
"Couldn't block account: " + err.name,
|
|
|
|
{ variant: "error" }
|
|
|
|
);
|
|
|
|
console.error(err.message);
|
|
|
|
});
|
2019-03-31 23:53:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-23 16:48:23 +01:00
|
|
|
renderPosts(posts: Status[]) {
|
2020-01-23 16:21:58 +01:00
|
|
|
const { classes } = this.props;
|
|
|
|
const postComponents = posts.map((post: Status) => {
|
2020-01-23 17:02:46 +01:00
|
|
|
return <Post key={post.id} post={post} client={this.client} />;
|
2020-01-23 16:48:23 +01:00
|
|
|
});
|
2020-01-23 16:21:58 +01:00
|
|
|
if (this.state.isMasonryLayout) {
|
|
|
|
return (
|
|
|
|
<Masonry
|
|
|
|
className={classes.masonryGrid}
|
|
|
|
columnClassName={classes["my-masonry-grid_column"]}
|
|
|
|
breakpointCols={{
|
|
|
|
default: 4,
|
|
|
|
2000: 3,
|
|
|
|
1400: 2,
|
2020-01-23 17:02:46 +01:00
|
|
|
1050: 1
|
2020-01-23 16:21:58 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{postComponents}
|
|
|
|
</Masonry>
|
2020-01-23 16:48:23 +01:00
|
|
|
);
|
2020-01-23 16:21:58 +01:00
|
|
|
} else {
|
2020-01-23 17:02:46 +01:00
|
|
|
return <div>{postComponents}</div>;
|
2020-01-23 16:21:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 21:46:19 +01:00
|
|
|
render() {
|
|
|
|
const { classes } = this.props;
|
2020-01-23 16:21:58 +01:00
|
|
|
const containerClasses = `${classes.pageContentLayoutConstraints} ${
|
|
|
|
this.state.isMasonryLayout ? classes.pageLayoutMasonry : ""
|
2020-01-23 17:02:46 +01:00
|
|
|
}`;
|
2019-09-18 19:52:39 +02:00
|
|
|
return (
|
2019-03-28 21:46:19 +01:00
|
|
|
<div className={classes.pageLayoutMinimalConstraints}>
|
|
|
|
<div className={classes.pageHeroBackground}>
|
2019-09-18 19:52:39 +02:00
|
|
|
<div
|
|
|
|
className={classes.pageHeroBackgroundImage}
|
|
|
|
style={{
|
|
|
|
backgroundImage: this.state.account
|
|
|
|
? `url("${this.state.account.header}")`
|
|
|
|
: `url("")`
|
|
|
|
}}
|
|
|
|
/>
|
2019-08-22 16:56:39 +02:00
|
|
|
<Toolbar className={classes.profileToolbar}>
|
2019-09-18 19:52:39 +02:00
|
|
|
<div className={classes.pageGrow} />
|
|
|
|
<Tooltip
|
|
|
|
title={
|
|
|
|
this.isItMe()
|
|
|
|
? "You can't follow yourself."
|
|
|
|
: this.state.relationship &&
|
|
|
|
this.state.relationship.following
|
|
|
|
? "Unfollow"
|
|
|
|
: "Follow"
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<IconButton
|
|
|
|
color={"inherit"}
|
|
|
|
disabled={this.isItMe()}
|
|
|
|
onClick={() => this.toggleFollow()}
|
|
|
|
>
|
|
|
|
{this.isItMe() ? (
|
|
|
|
<PersonAddDisabledIcon />
|
|
|
|
) : this.state.relationship &&
|
|
|
|
this.state.relationship.following ? (
|
|
|
|
<AccountMinusIcon />
|
|
|
|
) : (
|
|
|
|
<PersonAddIcon />
|
|
|
|
)}
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
2019-08-22 16:56:39 +02:00
|
|
|
<Tooltip title={"Send a message or post"}>
|
2019-09-18 19:52:39 +02:00
|
|
|
<LinkableIconButton
|
|
|
|
to={`/compose?acct=${
|
|
|
|
this.state.account
|
|
|
|
? this.state.account.acct
|
|
|
|
: ""
|
|
|
|
}`}
|
|
|
|
color={"inherit"}
|
|
|
|
>
|
|
|
|
<ChatIcon />
|
2019-08-22 16:56:39 +02:00
|
|
|
</LinkableIconButton>
|
|
|
|
</Tooltip>
|
2019-09-18 19:52:39 +02:00
|
|
|
<Tooltip
|
|
|
|
title={
|
|
|
|
this.state.relationship &&
|
|
|
|
this.state.relationship.blocking
|
|
|
|
? "Unblock this account"
|
|
|
|
: "Block this account"
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<IconButton
|
|
|
|
color={"inherit"}
|
|
|
|
disabled={this.isItMe()}
|
|
|
|
onClick={() => this.toggleBlockDialog()}
|
|
|
|
>
|
|
|
|
{this.state.relationship &&
|
|
|
|
this.state.relationship.blocking ? (
|
|
|
|
<AccountHeartIcon />
|
|
|
|
) : (
|
|
|
|
<AccountRemoveIcon />
|
|
|
|
)}
|
2019-09-15 23:12:15 +02:00
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip title="Open in web">
|
2019-09-18 19:52:39 +02:00
|
|
|
<IconButton
|
|
|
|
href={
|
|
|
|
this.state.account
|
|
|
|
? this.state.account.url
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
target="_blank"
|
|
|
|
rel={"nofollower noreferrer noopener"}
|
|
|
|
color={"inherit"}
|
|
|
|
>
|
|
|
|
<OpenInNewIcon />
|
2019-08-22 16:56:39 +02:00
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
2019-09-18 19:52:39 +02:00
|
|
|
{this.isItMe() ? (
|
|
|
|
<Tooltip title="Edit profile">
|
|
|
|
<LinkableIconButton to="/you" color="inherit">
|
|
|
|
<AccountEditIcon />
|
|
|
|
</LinkableIconButton>
|
|
|
|
</Tooltip>
|
|
|
|
) : null}
|
2019-08-22 16:56:39 +02:00
|
|
|
</Toolbar>
|
2019-08-23 00:07:33 +02:00
|
|
|
<div className={classes.profileContent}>
|
2019-09-18 19:52:39 +02:00
|
|
|
<Avatar
|
|
|
|
className={classes.profileAvatar}
|
|
|
|
src={
|
|
|
|
this.state.account
|
|
|
|
? this.state.account.avatar
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
/>
|
2019-08-23 00:07:33 +02:00
|
|
|
<div className={classes.profileUserBox}>
|
2019-09-18 19:52:39 +02:00
|
|
|
<Typography
|
|
|
|
variant="h4"
|
|
|
|
color="inherit"
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: this.state.account
|
|
|
|
? this.state.account.display_name
|
|
|
|
? emojifyString(
|
|
|
|
this.state.account
|
|
|
|
.display_name,
|
|
|
|
this.state.account.emojis,
|
|
|
|
classes.pageProfileNameEmoji
|
|
|
|
)
|
2019-09-15 23:12:15 +02:00
|
|
|
: this.state.account.username
|
2019-09-18 19:52:39 +02:00
|
|
|
: ""
|
|
|
|
}}
|
|
|
|
className={classes.pageProfileNameEmoji}
|
|
|
|
/>
|
|
|
|
<Typography variant="caption" color="inherit">
|
|
|
|
{this.state.account
|
|
|
|
? "@" + this.state.account.acct
|
|
|
|
: ""}
|
|
|
|
</Typography>
|
2019-10-05 19:05:50 +02:00
|
|
|
<Typography
|
|
|
|
paragraph
|
|
|
|
color="inherit"
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: this.state.account
|
|
|
|
? this.state.account.note
|
|
|
|
? emojifyString(
|
|
|
|
this.state.account.note,
|
|
|
|
this.state.account.emojis,
|
|
|
|
classes.pageProfileBioEmoji
|
|
|
|
)
|
|
|
|
: "No bio provided by user."
|
|
|
|
: "No bio available."
|
|
|
|
}}
|
|
|
|
></Typography>
|
2019-08-23 00:07:33 +02:00
|
|
|
<Typography color={"inherit"}>
|
2019-09-18 19:52:39 +02:00
|
|
|
{this.state.account
|
|
|
|
? this.state.account.followers_count
|
|
|
|
: 0}{" "}
|
|
|
|
followers |{" "}
|
|
|
|
{this.state.account
|
|
|
|
? this.state.account.following_count
|
|
|
|
: 0}{" "}
|
|
|
|
following |{" "}
|
|
|
|
{this.state.account
|
|
|
|
? this.state.account.statuses_count
|
|
|
|
: 0}{" "}
|
|
|
|
posts
|
2019-08-23 00:07:33 +02:00
|
|
|
</Typography>
|
2019-03-28 21:46:19 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-23 18:29:00 +01:00
|
|
|
<div className={containerClasses}>
|
2019-09-18 19:52:39 +02:00
|
|
|
{this.state.viewDidError ? (
|
|
|
|
<Paper className={classes.errorCard}>
|
|
|
|
<Typography variant="h4">Bummer.</Typography>
|
|
|
|
<Typography variant="h6">
|
|
|
|
Something went wrong when loading this profile.
|
|
|
|
</Typography>
|
|
|
|
<Typography>
|
|
|
|
{this.state.viewDidErrorCode
|
|
|
|
? this.state.viewDidErrorCode
|
|
|
|
: ""}
|
|
|
|
</Typography>
|
|
|
|
</Paper>
|
|
|
|
) : (
|
|
|
|
<span />
|
|
|
|
)}
|
|
|
|
{this.state.posts ? (
|
2019-03-30 22:13:49 +01:00
|
|
|
<div>
|
2020-01-23 16:21:58 +01:00
|
|
|
{this.renderPosts(this.state.posts)}
|
2019-09-18 19:52:39 +02:00
|
|
|
<br />
|
|
|
|
{this.state.viewDidLoad &&
|
|
|
|
!this.state.viewDidError ? (
|
|
|
|
<div
|
|
|
|
style={{ textAlign: "center" }}
|
|
|
|
onClick={() =>
|
|
|
|
this.loadMoreTimelinePieces()
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<Button variant="contained">
|
|
|
|
Load more
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<span />
|
|
|
|
)}
|
|
|
|
{this.state.viewIsLoading ? (
|
|
|
|
<div style={{ textAlign: "center" }}>
|
|
|
|
<CircularProgress
|
|
|
|
className={classes.progress}
|
|
|
|
color="primary"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<span />
|
|
|
|
)}
|
2019-03-31 23:53:17 +02:00
|
|
|
<Dialog
|
|
|
|
open={this.state.blockDialogOpen}
|
|
|
|
onClose={() => this.toggleBlockDialog()}
|
2019-09-18 19:52:39 +02:00
|
|
|
>
|
|
|
|
<DialogTitle id="alert-dialog-title">
|
|
|
|
Block this person?
|
|
|
|
</DialogTitle>
|
2019-03-31 23:53:17 +02:00
|
|
|
<DialogContent>
|
|
|
|
<DialogContentText id="alert-dialog-description">
|
2019-09-18 19:52:39 +02:00
|
|
|
Are you sure you want to block this person? You
|
|
|
|
won't see their posts on your home feed, local
|
|
|
|
timeline, or public timeline.
|
2019-03-31 23:53:17 +02:00
|
|
|
</DialogContentText>
|
|
|
|
</DialogContent>
|
|
|
|
<DialogActions>
|
2019-09-18 19:52:39 +02:00
|
|
|
<Button
|
|
|
|
onClick={() => this.toggleBlockDialog()}
|
|
|
|
color="primary"
|
|
|
|
autoFocus
|
|
|
|
>
|
|
|
|
Cancel
|
2019-03-31 23:53:17 +02:00
|
|
|
</Button>
|
2019-09-18 19:52:39 +02:00
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
this.toggleBlock();
|
|
|
|
this.toggleBlockDialog();
|
|
|
|
}}
|
|
|
|
color="primary"
|
|
|
|
>
|
|
|
|
Block
|
2019-03-31 23:53:17 +02:00
|
|
|
</Button>
|
|
|
|
</DialogActions>
|
|
|
|
</Dialog>
|
2019-03-28 21:46:19 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-18 19:52:39 +02:00
|
|
|
export default withStyles(styles)(withSnackbar(ProfilePage));
|