diff --git a/src/pages/Activity.tsx b/src/pages/Activity.tsx index 9e9663e..68d87c9 100644 --- a/src/pages/Activity.tsx +++ b/src/pages/Activity.tsx @@ -3,19 +3,35 @@ import { withStyles, Typography, CircularProgress, - ListSubheader + ListSubheader, + Link, + Paper, + List, + ListItem, + ListItemText, + ListItemAvatar, + ListItemSecondaryAction, + Tooltip, + IconButton } 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 { LinkableAvatar, LinkableIconButton } from "../interfaces/overrides"; +import moment from "moment"; import FireplaceIcon from "@material-ui/icons/Fireplace"; +import TrendingUpIcon from "@material-ui/icons/TrendingUp"; +import SearchIcon from "@material-ui/icons/Search"; +import OpenInNewIcon from "@material-ui/icons/OpenInNew"; +import AssignmentIndIcon from "@material-ui/icons/AssignmentInd"; interface IActivityPageState { user?: UAccount; trendingTags?: [Tag]; - profileDirectory?: [Account]; + activeProfileDirectory?: [Account]; + newProfileDirectory?: [Account]; viewLoading: boolean; viewLoaded?: boolean; viewErrored?: boolean; @@ -41,7 +57,7 @@ class ActivityPage extends Component { this.getAccountData(); this.client - .get("/trends") + .get("/trends", { limit: 3 }) .then((resp: any) => { let trendingTags: [Tag] = resp.data; this.setState({ trendingTags }); @@ -55,11 +71,27 @@ class ActivityPage extends Component { }); this.client - .get("/directory", { local: true, order: "active" }) + .get("/directory", { local: true, order: "active", limit: 5 }) .then((resp: any) => { let profileDirectory: [Account] = resp.data; this.setState({ - profileDirectory, + activeProfileDirectory: profileDirectory + }); + }) + .catch((err: Error) => { + this.setState({ + viewLoading: false, + viewErrored: true + }); + console.log(err.message); + }); + + this.client + .get("/directory", { local: true, order: "new", limit: 5 }) + .then((resp: any) => { + let profileDirectory: [Account] = resp.data; + this.setState({ + newProfileDirectory: profileDirectory, viewLoading: false, viewLoaded: true }); @@ -117,27 +149,174 @@ class ActivityPage extends Component { Trending hashtags {this.state.trendingTags && this.state.trendingTags.length > 0 ? ( -
+ + + {this.state.trendingTags.map((tag: Tag) => ( + + + + + + + + + + + + + + + + + + + ))} + + ) : ( 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 ? ( -
+
+ Who's been active + {this.state.activeProfileDirectory && + this.state.activeProfileDirectory.length > 0 ? ( + + + {this.state.activeProfileDirectory.map( + (account: Account) => ( + + + + + + + + + + + + + + ) + )} + + ) : ( - It looks like there aren't any people in the - profile directory yet. + It looks like there aren't any active people in + the profile directory yet. + + )} +
+ New arrivals + {this.state.newProfileDirectory && + this.state.newProfileDirectory.length > 0 ? ( + + + {this.state.newProfileDirectory.map( + (account: Account) => ( + + + + + + + + + + + + + + ) + )} + + + ) : ( + + It looks like there aren't any new arrivals + listed in the profile directory yet. )} ) : null} + {this.state.viewErrored ? ( + + Bummer. + + Something went wrong when loading instance activity. + + + ) : ( + + )} {this.state.viewLoading ? (
{ ) : ( )} +
+
+ + Trending hashtags and the profile directory may not + appear here if your instance isn't up to date. Check the{" "} + about page to see if your + instance is running the latest version. + +
); } diff --git a/src/types/Account.tsx b/src/types/Account.tsx index a6454a9..5fb1504 100644 --- a/src/types/Account.tsx +++ b/src/types/Account.tsx @@ -14,6 +14,7 @@ export type Account = { followers_count: number; following_count: number; statuses_count: number; + last_status_at: string; note: string; url: string; avatar: string; diff --git a/src/types/History.tsx b/src/types/History.tsx new file mode 100644 index 0000000..22176bd --- /dev/null +++ b/src/types/History.tsx @@ -0,0 +1,5 @@ +export type History = { + day: string; + uses: number; + accounts: number; +}; diff --git a/src/types/Tag.tsx b/src/types/Tag.tsx index f12ccf2..d03b269 100644 --- a/src/types/Tag.tsx +++ b/src/types/Tag.tsx @@ -1,4 +1,7 @@ +import { History } from "./History"; + export type Tag = { name: string; url: string; + history?: [History]; };