From 041be2653329dee5db75ccb8d4b363f3890b6c51 Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 14:33:56 -0400 Subject: [PATCH 01/11] Create new edit profile page at /you --- src/App.tsx | 2 ++ src/pages/Settings.tsx | 9 ++++++++- src/pages/You.tsx | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/pages/You.tsx diff --git a/src/App.tsx b/src/App.tsx index 039d081..1457e20 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -19,6 +19,7 @@ import WelcomePage from './pages/Welcome'; import MessagesPage from './pages/Messages'; import RecommendationsPage from './pages/Recommendations'; import Missingno from './pages/Missingno'; +import You from './pages/You'; import {withSnackbar} from 'notistack'; import {PrivateRoute} from './interfaces/overrides'; import { userLoggedIn } from './utilities/accounts'; @@ -60,6 +61,7 @@ class App extends Component { + diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx index 76b7720..41111ee 100644 --- a/src/pages/Settings.tsx +++ b/src/pages/Settings.tsx @@ -30,6 +30,7 @@ import {themes, defaultTheme} from '../types/HyperspaceTheme'; import ThemePreview from '../components/ThemePreview'; import {setHyperspaceTheme, getHyperspaceTheme} from '../utilities/themes'; import { Visibility } from '../types/Visibility'; +import {LinkableButton} from '../interfaces/overrides'; interface ISettingsState { darkModeEnabled: boolean; @@ -310,9 +311,15 @@ class SettingsPage extends Component {
- Accounts + Your Account + + + + Edit + + diff --git a/src/pages/You.tsx b/src/pages/You.tsx new file mode 100644 index 0000000..f8db265 --- /dev/null +++ b/src/pages/You.tsx @@ -0,0 +1,21 @@ +import React, {Component} from 'react'; +import {withStyles, Typography, Paper, Avatar, Button, TextField} from '@material-ui/core'; +import {withSnackbar, withSnackbarProps} from 'notistack'; +import {styles} from './PageLayout.styles'; + +interface IYouProps extends withSnackbarProps { + classes: any; +} + +class You extends Component { + render() { + const {classes} = this.props; + return ( +
+ +
+ ); + } +} + +export default withStyles(styles)(withSnackbar(You)); \ No newline at end of file From aca4af53eafa2ed8206c06c945db162042a62eda Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 15:00:01 -0400 Subject: [PATCH 02/11] Create basic UI --- src/pages/PageLayout.styles.tsx | 9 ++++- src/pages/You.tsx | 70 +++++++++++++++++++++++++++++++-- 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/src/pages/PageLayout.styles.tsx b/src/pages/PageLayout.styles.tsx index 43d2731..3677b3b 100644 --- a/src/pages/PageLayout.styles.tsx +++ b/src/pages/PageLayout.styles.tsx @@ -174,5 +174,12 @@ export const styles = (theme: Theme) => createStyles({ '& a': { color: theme.palette.primary.light } - } + }, + youHeadingAvatar: { + height: 88, + width: 88 + }, + youPaper: { + padding: theme.spacing.unit * 2, + }, }); \ No newline at end of file diff --git a/src/pages/You.tsx b/src/pages/You.tsx index f8db265..bd99de4 100644 --- a/src/pages/You.tsx +++ b/src/pages/You.tsx @@ -1,18 +1,82 @@ import React, {Component} from 'react'; -import {withStyles, Typography, Paper, Avatar, Button, TextField} from '@material-ui/core'; +import {withStyles, Typography, Paper, Avatar, Button, TextField, ListItem, ListItemText, ListItemAvatar, List, Grid} from '@material-ui/core'; import {withSnackbar, withSnackbarProps} from 'notistack'; import {styles} from './PageLayout.styles'; +import { Account } from '../types/Account'; +import Mastodon from 'megalodon'; interface IYouProps extends withSnackbarProps { classes: any; } -class You extends Component { +interface IYouState { + currentAccount: Account; + newProfile?: any; + newHeader?: any; + newDisplayName?: string; + newBio?: string; +} + +class You extends Component { + + client: Mastodon; + + constructor(props: any) { + super(props); + + this.client = new Mastodon(localStorage.getItem('access_token') as string, localStorage.getItem('baseurl') as string + "/api/v1"); + + this.state = { + currentAccount: this.getAccount() + } + } + + getAccount() { + let acct = localStorage.getItem('account'); + if (acct) { + return JSON.parse(acct); + } + } + render() { const {classes} = this.props; return (
- +
+ + + + + + + {this.state.currentAccount.display_name || this.state.currentAccount.username} (you) + } secondary={{"@" + this.state.currentAccount.acct}}/> + + + +
+ + Update your profile images +
+ + + Wut + + + Wut + + +
+
+ + Change your display name + +
+ + Edit your bio + +
); } From b6c8448b0a8f6f63f20e411100b1d578cac6d242 Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 15:23:33 -0400 Subject: [PATCH 03/11] Update UI to resemble profile page --- src/pages/PageLayout.styles.tsx | 15 +++++++++++ src/pages/You.tsx | 48 +++++++++++++-------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/pages/PageLayout.styles.tsx b/src/pages/PageLayout.styles.tsx index 3677b3b..00c14e6 100644 --- a/src/pages/PageLayout.styles.tsx +++ b/src/pages/PageLayout.styles.tsx @@ -182,4 +182,19 @@ export const styles = (theme: Theme) => createStyles({ youPaper: { padding: theme.spacing.unit * 2, }, + youGrid: { + textAlign: "center", + '& *': { + marginLeft: "auto", + marginRight: "auto", + } + }, + youGridAvatar: { + height: 128, + width: 128 + }, + youGridImage: { + width: 'auto', + height: 128 + }, }); \ No newline at end of file diff --git a/src/pages/You.tsx b/src/pages/You.tsx index bd99de4..e3723a3 100644 --- a/src/pages/You.tsx +++ b/src/pages/You.tsx @@ -5,6 +5,8 @@ import {styles} from './PageLayout.styles'; import { Account } from '../types/Account'; import Mastodon from 'megalodon'; +import PersonIcon from '@material-ui/icons/Person'; + interface IYouProps extends withSnackbarProps { classes: any; } @@ -41,40 +43,26 @@ class You extends Component { render() { const {classes} = this.props; return ( -
-
- - - - - - - {this.state.currentAccount.display_name || this.state.currentAccount.username} (you) - } secondary={{"@" + this.state.currentAccount.acct}}/> - - - -
- - Update your profile images +
+
+
+
+ + Edit your profile
- - - Wut - - - Wut - - +
+ + +
+
+
+
+ + Display name
- Change your display name - -
- - Edit your bio + About you
From 13bcc99b0752439c93a4b4d366600657ce536642 Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 15:49:10 -0400 Subject: [PATCH 04/11] Add header/avatar image upload support --- src/pages/You.tsx | 68 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/src/pages/You.tsx b/src/pages/You.tsx index e3723a3..ff6d393 100644 --- a/src/pages/You.tsx +++ b/src/pages/You.tsx @@ -4,6 +4,7 @@ import {withSnackbar, withSnackbarProps} from 'notistack'; import {styles} from './PageLayout.styles'; import { Account } from '../types/Account'; import Mastodon from 'megalodon'; +import filedialog from 'file-dialog'; import PersonIcon from '@material-ui/icons/Person'; @@ -13,8 +14,6 @@ interface IYouProps extends withSnackbarProps { interface IYouState { currentAccount: Account; - newProfile?: any; - newHeader?: any; newDisplayName?: string; newBio?: string; } @@ -40,6 +39,66 @@ class You extends Component { } } + updateAvatar() { + filedialog({ + multiple: false, + accept: "image/*" + }).then((images: FileList) => { + if (images.length > 0) { + this.props.enqueueSnackbar("Updating avatar...", { persist: true, key: "persistAvatar" }); + let upload = new FormData(); + upload.append("avatar", images[0]); + this.client.patch("/accounts/update_credentials", upload).then((acct: any) => { + let currentAccount: Account = acct.data; + this.setState({ currentAccount }); + localStorage.setItem("account", JSON.stringify(currentAccount)); + this.props.closeSnackbar("persistAvatar"); + this.props.enqueueSnackbar("Avatar updated successfully."); + }).catch((err: Error) => { + this.props.closeSnackbar("persistAvatar"); + this.props.enqueueSnackbar("Couldn't update avatar: " + err.name, { variant: "error" }); + }) + } + }).catch((err: Error) => { + this.props.enqueueSnackbar("Couldn't update avatar: " + err.name); + }) + } + + updateHeader() { + filedialog({ + multiple: false, + accept: "image/*" + }).then((images: FileList) => { + if (images.length > 0) { + this.props.enqueueSnackbar("Updating header...", { persist: true, key: "persistHeader" }); + let upload = new FormData(); + upload.append("header", images[0]); + this.client.patch("/accounts/update_credentials", upload).then((acct: any) => { + let currentAccount: Account = acct.data; + this.setState({ currentAccount }); + localStorage.setItem("account", JSON.stringify(currentAccount)); + this.props.closeSnackbar("persistHeader"); + this.props.enqueueSnackbar("Header updated successfully."); + }).catch((err: Error) => { + this.props.closeSnackbar("persistHeader"); + this.props.enqueueSnackbar("Couldn't update header: " + err.name, { variant: "error" }); + }) + } + }).catch((err: Error) => { + this.props.enqueueSnackbar("Couldn't update header: " + err.name); + }) + } + + //TODO: Implement changeDisplayName + changeDisplayName() { + + } + + //TODO: Implement changeBio + changeBio() { + + } + render() { const {classes} = this.props; return ( @@ -51,9 +110,10 @@ class You extends Component { Edit your profile
- - + +
+
From 25c6b0483181b066d3a8e0610d3d434e53382c00 Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 16:12:26 -0400 Subject: [PATCH 05/11] Add 'Edit profile' button to profile page (selective) and change post icon --- src/components/AppLayout/AppLayout.tsx | 4 ++-- src/pages/PageLayout.styles.tsx | 6 ++++++ src/pages/ProfilePage.tsx | 22 ++++++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/components/AppLayout/AppLayout.tsx b/src/components/AppLayout/AppLayout.tsx index 87cec2f..89f9813 100644 --- a/src/components/AppLayout/AppLayout.tsx +++ b/src/components/AppLayout/AppLayout.tsx @@ -10,7 +10,7 @@ import PublicIcon from '@material-ui/icons/Public'; import GroupIcon from '@material-ui/icons/Group'; import SettingsIcon from '@material-ui/icons/Settings'; import InfoIcon from '@material-ui/icons/Info'; -import EditIcon from '@material-ui/icons/Edit'; +import AddCommentIcon from '@material-ui/icons/AddComment'; //import SupervisedUserCircleIcon from '@material-ui/icons/SupervisedUserCircle'; import ExitToAppIcon from '@material-ui/icons/ExitToApp'; import {styles} from './AppLayout.styles'; @@ -395,7 +395,7 @@ export class AppLayout extends Component { - +
diff --git a/src/pages/PageLayout.styles.tsx b/src/pages/PageLayout.styles.tsx index 00c14e6..6534865 100644 --- a/src/pages/PageLayout.styles.tsx +++ b/src/pages/PageLayout.styles.tsx @@ -82,8 +82,14 @@ export const styles = (theme: Theme) => createStyles({ paddingLeft: '25%', paddingRight: '25%', }, + position: "relative", zIndex: 1 }, + pageHeroToolbar: { + position: "absolute", + right: theme.spacing.unit * 2, + marginTop: -16, + }, pageListConstraints: { paddingLeft: theme.spacing.unit, paddingRight: theme.spacing.unit, diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 11c1272..e31dfe6 100644 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -1,5 +1,5 @@ import React, {Component} from 'react'; -import {withStyles, Typography, Avatar, Divider, Button, CircularProgress, Paper, Tooltip, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions} from '@material-ui/core'; +import {withStyles, Typography, Avatar, Divider, Button, CircularProgress, Paper, Tooltip, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, IconButton} from '@material-ui/core'; import {styles} from './PageLayout.styles'; import Mastodon from 'megalodon'; import { Account } from '../types/Account'; @@ -7,9 +7,11 @@ import { Status } from '../types/Status'; import { Relationship } from '../types/Relationship'; import Post from '../components/Post'; import {withSnackbar} from 'notistack'; -import { LinkableButton } from '../interfaces/overrides'; +import { LinkableButton, LinkableIconButton } from '../interfaces/overrides'; import { emojifyString } from '../utilities/emojis'; +import EditIcon from '@material-ui/icons/Edit'; + interface IProfilePageState { account?: Account; relationship?: Relationship; @@ -89,6 +91,14 @@ class ProfilePage extends Component { this.getAccountData(params.profileId); } + isItMe(): boolean { + if (this.state.account) { + return this.state.account.id === JSON.parse(localStorage.getItem('account') as string).id; + } else { + return false; + } + } + getRelationships() { this.client.get("/accounts/relationships", {id: this.props.match.params.profileId }).then((resp: any) => { let relationship: Relationship = resp.data[0]; @@ -216,6 +226,14 @@ class ProfilePage extends Component {
+ { + this.isItMe()? + + + + + : null + } {this.state.account ? '@' + this.state.account.acct: ""} From 0780ac256d8ca08f8e3a888f472df22d23b953bc Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 16:34:25 -0400 Subject: [PATCH 06/11] Use third-party icon for edit profile, revert AppLayout to Edit icon --- package-lock.json | 5 +++++ package.json | 1 + src/components/AppLayout/AppLayout.tsx | 4 ++-- src/pages/ProfilePage.tsx | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 260945a..f601b5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10953,6 +10953,11 @@ "safe-buffer": "^5.1.2" } }, + "mdi-material-ui": { + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/mdi-material-ui/-/mdi-material-ui-5.11.0.tgz", + "integrity": "sha512-9fIvdiKCKAfBoW11LqZsgaxZtu9WCQEd8FL9/8ceLHvStSf+fZM6sC7exwXaXZmzfwtJMfN1KiMGsPBPSTQFQg==" + }, "mdn-data": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz", diff --git a/package.json b/package.json index b62db8d..a918b30 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "emoji-mart": "^2.8.2", "file-dialog": "^0.0.7", "material-ui-pickers": "^2.2.4", + "mdi-material-ui": "^5.11.0", "megalodon": "^0.6.3", "moment": "^2.24.0", "notistack": "^0.5.1", diff --git a/src/components/AppLayout/AppLayout.tsx b/src/components/AppLayout/AppLayout.tsx index 89f9813..bf001aa 100644 --- a/src/components/AppLayout/AppLayout.tsx +++ b/src/components/AppLayout/AppLayout.tsx @@ -10,7 +10,7 @@ import PublicIcon from '@material-ui/icons/Public'; import GroupIcon from '@material-ui/icons/Group'; import SettingsIcon from '@material-ui/icons/Settings'; import InfoIcon from '@material-ui/icons/Info'; -import AddCommentIcon from '@material-ui/icons/AddComment'; +import CreateIcon from '@material-ui/icons/Create'; //import SupervisedUserCircleIcon from '@material-ui/icons/SupervisedUserCircle'; import ExitToAppIcon from '@material-ui/icons/ExitToApp'; import {styles} from './AppLayout.styles'; @@ -395,7 +395,7 @@ export class AppLayout extends Component { - +
diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index e31dfe6..99c1957 100644 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -10,7 +10,7 @@ import {withSnackbar} from 'notistack'; import { LinkableButton, LinkableIconButton } from '../interfaces/overrides'; import { emojifyString } from '../utilities/emojis'; -import EditIcon from '@material-ui/icons/Edit'; +import AccountEditIcon from 'mdi-material-ui/AccountEdit'; interface IProfilePageState { account?: Account; @@ -230,7 +230,7 @@ class ProfilePage extends Component { this.isItMe()? - + : null } From e5b873a7108006984e39336c8f347a1af73098ed Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 17:03:29 -0400 Subject: [PATCH 07/11] Remove unecessary IconButton import --- src/pages/ProfilePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 99c1957..ed25744 100644 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -1,5 +1,5 @@ import React, {Component} from 'react'; -import {withStyles, Typography, Avatar, Divider, Button, CircularProgress, Paper, Tooltip, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, IconButton} from '@material-ui/core'; +import {withStyles, Typography, Avatar, Divider, Button, CircularProgress, Paper, Tooltip, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions} from '@material-ui/core'; import {styles} from './PageLayout.styles'; import Mastodon from 'megalodon'; import { Account } from '../types/Account'; From bccca4d70f8382b6add61a418ee8a688c3c58b6c Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sat, 27 Apr 2019 17:11:24 -0400 Subject: [PATCH 08/11] Make titleBarRoot draggable in desktop (For something much later) --- src/components/AppLayout/AppLayout.styles.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/AppLayout/AppLayout.styles.tsx b/src/components/AppLayout/AppLayout.styles.tsx index b9674c8..5cf0c0f 100644 --- a/src/components/AppLayout/AppLayout.styles.tsx +++ b/src/components/AppLayout/AppLayout.styles.tsx @@ -22,7 +22,9 @@ export const styles = (theme: Theme) => createStyles({ backgroundColor: theme.palette.primary.dark, textAlign: 'center', zIndex: 1000, - verticalAlign: 'middle' + verticalAlign: 'middle', + WebkitUserSelect: 'none', + WebkitAppRegion: "drag" }, titleBarText: { color: theme.palette.common.white, @@ -148,5 +150,5 @@ export const styles = (theme: Theme) => createStyles({ bottom: theme.spacing.unit * 2, right: theme.spacing.unit * 2, zIndex: 50 - } + }, }); \ No newline at end of file From 0c3fc53db255f998acd7af1d226c73d25fa7d633 Mon Sep 17 00:00:00 2001 From: Nodar Sotkilava Date: Thu, 2 May 2019 14:39:21 -0400 Subject: [PATCH 09/11] Added functionality to update Bio and Display Name --- src/pages/You.tsx | 69 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/src/pages/You.tsx b/src/pages/You.tsx index ff6d393..2beb2f2 100644 --- a/src/pages/You.tsx +++ b/src/pages/You.tsx @@ -89,14 +89,55 @@ class You extends Component { }) } + removeHTMLContent(text: string) { + const div = document.createElement('div'); + div.innerHTML = text; + let innerContent = div.textContent || div.innerText || ""; + return innerContent; + } + //TODO: Implement changeDisplayName changeDisplayName() { - + this.client.patch('/accounts/update_credentials', { + display_name: this.state.newDisplayName? this.state.newDisplayName: this.state.currentAccount.display_name + }) + .then((acct: any) =>{ + let currentAccount: Account = acct.data + this.setState({currentAccount}); + localStorage.setItem('account', JSON.stringify(currentAccount)); + this.props.closeSnackbar("persistHeader"); + this.props.enqueueSnackbar("Display Name updated successfully."); + } ).catch((err:Error) => { + this.props.closeSnackbar("persistHeader"); + this.props.enqueueSnackbar("Couldn't update Display Name: " + err.name, { variant: "error" }) + }).catch((err: Error) => { + this.props.enqueueSnackbar("Couldn't update Display Name: " + err.name); + }) } + updateDisplayname(name: string) { + this.setState({ newDisplayName: name }); + }; + //TODO: Implement changeBio changeBio() { + this.client.patch('/accounts/update_credentials', {note: this.state.newBio? this.state.newBio: this.state.currentAccount.note}) + .then((acct:any) => { + let currentAccount: Account = acct.data + this.setState({currentAccount}); + localStorage.setItem('account', JSON.stringify(currentAccount)); + this.props.closeSnackbar("persistHeader"); + this.props.enqueueSnackbar("Bio updated successfully."); + }).catch((err: Error) => { + this.props.closeSnackbar("persistHeader"); + this.props.enqueueSnackbar("Couldn't update Bio: " + err.name, { variant: "error"}); + }).catch((err:Error) => { + this.props.enqueueSnackbar("Couldn't update Bio: " + err.name); + }) + } + updateBio(bio:string){ + this.setState({newBio:bio}) } render() { @@ -118,11 +159,35 @@ class You extends Component {
- Display name + Display Name +
+ this.updateDisplayname(event.target.value)}> + +
+ +

About you +
+ this.updateBio(event.target.value)}> + +
+ +
From 63775d6d916667b909d5ca7ab177ebcb5828f141 Mon Sep 17 00:00:00 2001 From: Nodar Sotkilava Date: Thu, 2 May 2019 15:06:43 -0400 Subject: [PATCH 10/11] Show new name on snackbar, updated mesasages --- src/pages/You.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/You.tsx b/src/pages/You.tsx index 2beb2f2..dcb42d8 100644 --- a/src/pages/You.tsx +++ b/src/pages/You.tsx @@ -106,12 +106,12 @@ class You extends Component { this.setState({currentAccount}); localStorage.setItem('account', JSON.stringify(currentAccount)); this.props.closeSnackbar("persistHeader"); - this.props.enqueueSnackbar("Display Name updated successfully."); + this.props.enqueueSnackbar("Display name updated successfully: " + this.state.newDisplayName); } ).catch((err:Error) => { this.props.closeSnackbar("persistHeader"); - this.props.enqueueSnackbar("Couldn't update Display Name: " + err.name, { variant: "error" }) + this.props.enqueueSnackbar("Couldn't update display name: " + err.name, { variant: "error" }) }).catch((err: Error) => { - this.props.enqueueSnackbar("Couldn't update Display Name: " + err.name); + this.props.enqueueSnackbar("Couldn't update display name: " + err.name); }) } @@ -130,9 +130,9 @@ class You extends Component { this.props.enqueueSnackbar("Bio updated successfully."); }).catch((err: Error) => { this.props.closeSnackbar("persistHeader"); - this.props.enqueueSnackbar("Couldn't update Bio: " + err.name, { variant: "error"}); + this.props.enqueueSnackbar("Couldn't update bio: " + err.name, { variant: "error"}); }).catch((err:Error) => { - this.props.enqueueSnackbar("Couldn't update Bio: " + err.name); + this.props.enqueueSnackbar("Couldn't update bio: " + err.name); }) } From 1536247af4eb960bd68f3f75d686b44834da4510 Mon Sep 17 00:00:00 2001 From: Nodar Sotkilava Date: Fri, 3 May 2019 11:52:22 -0400 Subject: [PATCH 11/11] deleted extra error function calls added console.error() --- src/pages/You.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/pages/You.tsx b/src/pages/You.tsx index dcb42d8..12bb6d7 100644 --- a/src/pages/You.tsx +++ b/src/pages/You.tsx @@ -95,8 +95,6 @@ class You extends Component { let innerContent = div.textContent || div.innerText || ""; return innerContent; } - - //TODO: Implement changeDisplayName changeDisplayName() { this.client.patch('/accounts/update_credentials', { display_name: this.state.newDisplayName? this.state.newDisplayName: this.state.currentAccount.display_name @@ -106,20 +104,17 @@ class You extends Component { this.setState({currentAccount}); localStorage.setItem('account', JSON.stringify(currentAccount)); this.props.closeSnackbar("persistHeader"); - this.props.enqueueSnackbar("Display name updated successfully: " + this.state.newDisplayName); + this.props.enqueueSnackbar("Display name updated to " + this.state.newDisplayName); } ).catch((err:Error) => { + console.error(err.name) this.props.closeSnackbar("persistHeader"); this.props.enqueueSnackbar("Couldn't update display name: " + err.name, { variant: "error" }) - }).catch((err: Error) => { - this.props.enqueueSnackbar("Couldn't update display name: " + err.name); }) } updateDisplayname(name: string) { this.setState({ newDisplayName: name }); }; - - //TODO: Implement changeBio changeBio() { this.client.patch('/accounts/update_credentials', {note: this.state.newBio? this.state.newBio: this.state.currentAccount.note}) .then((acct:any) => { @@ -129,11 +124,10 @@ class You extends Component { this.props.closeSnackbar("persistHeader"); this.props.enqueueSnackbar("Bio updated successfully."); }).catch((err: Error) => { + console.error(err.name) this.props.closeSnackbar("persistHeader"); this.props.enqueueSnackbar("Couldn't update bio: " + err.name, { variant: "error"}); - }).catch((err:Error) => { - this.props.enqueueSnackbar("Couldn't update bio: " + err.name); - }) + }) } updateBio(bio:string){ @@ -169,7 +163,7 @@ class You extends Component { onChange = {(event: any) => this.updateDisplayname(event.target.value)}>
- +

@@ -186,7 +180,7 @@ class You extends Component { onChange = {(event:any) =>this.updateBio(event.target.value)}>
- +