diff --git a/package-lock.json b/package-lock.json index adacf30..e4aa057 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hyperspace", - "version": "1.0.0", + "version": "1.1.0-beta1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1055,13 +1055,23 @@ } }, "@material-ui/icons": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@material-ui/icons/-/icons-3.0.2.tgz", - "integrity": "sha512-QY/3gJnObZQ3O/e6WjH+0ah2M3MOgLOzCy8HTUoUx9B6dDrS18vP7Ycw3qrDEKlB6q1KNxy6CZHm5FCauWGy2g==", + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/@material-ui/icons/-/icons-4.5.1.tgz", + "integrity": "sha512-YZ/BgJbXX4a0gOuKWb30mBaHaoXRqPanlePam83JQPZ/y4kl+3aW0Wv9tlR70hB5EGAkEJGW5m4ktJwMgxQAeA==", "dev": true, "requires": { - "@babel/runtime": "^7.2.0", - "recompose": "0.28.0 - 0.30.0" + "@babel/runtime": "^7.4.4" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.6.3.tgz", + "integrity": "sha512-kq6anf9JGjW8Nt5rYfEuGRaEAaH1mkv3Bbu6rYvLOpPh/RusSJXuKPEAoZ7L7gybZkchE8+NV5g9vKF4AGAtsA==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + } + } } }, "@material-ui/system": { diff --git a/package.json b/package.json index 0ddc897..0e2126d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "devDependencies": { "@date-io/moment": "^1.3.11", "@material-ui/core": "^3.9.3", - "@material-ui/icons": "^3.0.2", + "@material-ui/icons": "^4.5.1", "@types/emoji-mart": "^2.11.0", "@types/jest": "^24.0.18", "@types/node": "11.11.6", diff --git a/src/App.tsx b/src/App.tsx index 580a8c1..548e87d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,6 +22,7 @@ import Missingno from "./pages/Missingno"; import Blocked from "./pages/Blocked"; import You from "./pages/You"; import RequestsPage from "./pages/Requests"; +import ActivityPage from "./pages/Activity"; import { withSnackbar } from "notistack"; import { PrivateRoute } from "./interfaces/overrides"; import { userLoggedIn } from "./utilities/accounts"; @@ -125,6 +126,7 @@ class App extends Component { component={RecommendationsPage} /> + ); diff --git a/src/pages/Activity.tsx b/src/pages/Activity.tsx new file mode 100644 index 0000000..9e9663e --- /dev/null +++ b/src/pages/Activity.tsx @@ -0,0 +1,156 @@ +import React, { Component } from "react"; +import { + withStyles, + Typography, + CircularProgress, + ListSubheader +} from "@material-ui/core"; +import { styles } from "./PageLayout.styles"; +import { UAccount, Account } from "../types/Account"; +import { Tag } from "../types/Tag"; +import Mastodon from "megalodon"; + +import FireplaceIcon from "@material-ui/icons/Fireplace"; + +interface IActivityPageState { + user?: UAccount; + trendingTags?: [Tag]; + profileDirectory?: [Account]; + viewLoading: boolean; + viewLoaded?: boolean; + viewErrored?: boolean; +} + +class ActivityPage extends Component { + client: Mastodon; + + constructor(props: any) { + super(props); + + this.client = new Mastodon( + localStorage.getItem("access_token") as string, + localStorage.getItem("baseurl") + "/api/v1" + ); + + this.state = { + viewLoading: true + }; + } + + componentDidMount() { + this.getAccountData(); + + this.client + .get("/trends") + .then((resp: any) => { + let trendingTags: [Tag] = resp.data; + this.setState({ trendingTags }); + }) + .catch((err: Error) => { + this.setState({ + viewLoading: false, + viewErrored: true + }); + console.error(err.message); + }); + + this.client + .get("/directory", { local: true, order: "active" }) + .then((resp: any) => { + let profileDirectory: [Account] = resp.data; + this.setState({ + profileDirectory, + viewLoading: false, + viewLoaded: true + }); + }) + .catch((err: Error) => { + this.setState({ + viewLoading: false, + viewErrored: true + }); + console.log(err.message); + }); + } + + getAccountData() { + this.client + .get("/accounts/verify_credentials") + .then((resp: any) => { + let data: UAccount = resp.data; + this.setState({ user: data }); + }) + .catch((err: Error) => { + this.props.enqueueSnackbar( + "Couldn't find profile info: " + err.name + ); + console.error(err.message); + let acct = localStorage.getItem("account") as string; + this.setState({ user: JSON.parse(acct) }); + }); + } + + render() { + const { classes } = this.props; + return ( +
+
+ + + Hey there,{" "} + {this.state.user + ? this.state.user.display_name || + this.state.user.acct + : "user"} + ! + + + Take a look at what's been happening on your instance. + +
+ {this.state.viewLoaded ? ( +
+ Trending hashtags + {this.state.trendingTags && + this.state.trendingTags.length > 0 ? ( +
+ ) : ( + + It looks like there aren't any trending tags on + your instance as of right now. + + )} + + Active on profile directory + + {this.state.profileDirectory && + this.state.profileDirectory.length > 0 ? ( +
+ ) : ( + + It looks like there aren't any people in the + profile directory yet. + + )} +
+ ) : null} + {this.state.viewLoading ? ( +
+ +
+ ) : ( + + )} +
+ ); + } +} + +export default withStyles(styles)(ActivityPage); diff --git a/src/pages/Recommendations.tsx b/src/pages/Recommendations.tsx index 20344ae..a724db6 100644 --- a/src/pages/Recommendations.tsx +++ b/src/pages/Recommendations.tsx @@ -32,7 +32,6 @@ interface IRecommendationsPageState { viewDidError?: Boolean; viewDidErrorCode?: string; followSuggestions?: [Account]; - trendingTags?: [any]; } class RecommendationsPage extends Component< diff --git a/src/pages/Requests.tsx b/src/pages/Requests.tsx index 84086b2..58b2445 100644 --- a/src/pages/Requests.tsx +++ b/src/pages/Requests.tsx @@ -17,10 +17,11 @@ import { styles } from "./PageLayout.styles"; import { Account } from "../types/Account"; import Mastodon from "megalodon"; import { LinkableAvatar, LinkableIconButton } from "../interfaces/overrides"; -import CheckIcon from "@material-ui/core/SvgIcon/SvgIcon"; +import CheckIcon from "@material-ui/icons/Check"; import AccountCircleIcon from "@material-ui/icons/AccountCircle"; import CloseIcon from "@material-ui/icons/Close"; import CheckCircleIcon from "@material-ui/icons/CheckCircle"; +import { withSnackbar } from "notistack"; interface IRequestsPageState { viewLoading: boolean; @@ -211,4 +212,4 @@ class RequestsPage extends Component { } } -export default withStyles(styles)(RequestsPage); +export default withStyles(styles)(withSnackbar(RequestsPage));