mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-11 09:10:48 +01:00
Merge pull request #204 from hyperspacedev/HD-61-update-avatar
Update header avatar when user changes avatar
This commit is contained in:
commit
8897035fe5
16
src/App.tsx
16
src/App.tsx
@ -30,6 +30,7 @@ let theme = setHyperspaceTheme(getUserDefaultTheme());
|
|||||||
interface IAppState {
|
interface IAppState {
|
||||||
theme: any;
|
theme: any;
|
||||||
showLayout: boolean;
|
showLayout: boolean;
|
||||||
|
avatarURL?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class App extends Component<any, IAppState> {
|
class App extends Component<any, IAppState> {
|
||||||
@ -44,6 +45,7 @@ class App extends Component<any, IAppState> {
|
|||||||
showLayout:
|
showLayout:
|
||||||
userLoggedIn() && !window.location.hash.includes("#/welcome")
|
userLoggedIn() && !window.location.hash.includes("#/welcome")
|
||||||
};
|
};
|
||||||
|
this.setAvatarURL = this.setAvatarURL.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@ -85,6 +87,12 @@ class App extends Component<any, IAppState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAvatarURL(avatarURL: string) {
|
||||||
|
this.setState({
|
||||||
|
avatarURL
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
this.removeBodyBackground();
|
this.removeBodyBackground();
|
||||||
|
|
||||||
@ -93,7 +101,9 @@ class App extends Component<any, IAppState> {
|
|||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
<Route path="/welcome" component={WelcomePage} />
|
<Route path="/welcome" component={WelcomePage} />
|
||||||
<div>
|
<div>
|
||||||
{this.state.showLayout ? <AppLayout /> : null}
|
{this.state.showLayout ? (
|
||||||
|
<AppLayout avatarURL={this.state.avatarURL} />
|
||||||
|
) : null}
|
||||||
<PrivateRoute
|
<PrivateRoute
|
||||||
exact
|
exact
|
||||||
path="/"
|
path="/"
|
||||||
@ -155,7 +165,9 @@ class App extends Component<any, IAppState> {
|
|||||||
<PrivateRoute path="/search" component={SearchPage} />
|
<PrivateRoute path="/search" component={SearchPage} />
|
||||||
<PrivateRoute path="/settings" component={Settings} />
|
<PrivateRoute path="/settings" component={Settings} />
|
||||||
<PrivateRoute path="/blocked" component={Blocked} />
|
<PrivateRoute path="/blocked" component={Blocked} />
|
||||||
<PrivateRoute path="/you" component={You} />
|
<PrivateRoute path="/you">
|
||||||
|
<You onAvatarUpdate={this.setAvatarURL} />
|
||||||
|
</PrivateRoute>
|
||||||
<PrivateRoute path="/about" component={AboutPage} />
|
<PrivateRoute path="/about" component={AboutPage} />
|
||||||
<PrivateRoute path="/compose" component={Composer} />
|
<PrivateRoute path="/compose" component={Composer} />
|
||||||
<PrivateRoute
|
<PrivateRoute
|
||||||
|
@ -698,7 +698,9 @@ export class AppLayout extends Component<any, IAppLayoutState> {
|
|||||||
}
|
}
|
||||||
alt="You"
|
alt="You"
|
||||||
src={
|
src={
|
||||||
this.state.currentUser
|
this.props.avatarURL
|
||||||
|
? this.props.avatarURL
|
||||||
|
: this.state.currentUser
|
||||||
? this.state.currentUser
|
? this.state.currentUser
|
||||||
.avatar_static
|
.avatar_static
|
||||||
: ""
|
: ""
|
||||||
@ -733,8 +735,11 @@ export class AppLayout extends Component<any, IAppLayoutState> {
|
|||||||
<Avatar
|
<Avatar
|
||||||
alt="You"
|
alt="You"
|
||||||
src={
|
src={
|
||||||
this.state
|
this.props.avatarURL
|
||||||
.currentUser
|
? this.props
|
||||||
|
.avatarURL
|
||||||
|
: this.state
|
||||||
|
.currentUser
|
||||||
? this.state
|
? this.state
|
||||||
.currentUser
|
.currentUser
|
||||||
.avatar_static
|
.avatar_static
|
||||||
|
@ -16,6 +16,7 @@ import filedialog from "file-dialog";
|
|||||||
|
|
||||||
interface IYouProps extends withSnackbarProps {
|
interface IYouProps extends withSnackbarProps {
|
||||||
classes: any;
|
classes: any;
|
||||||
|
onAvatarUpdate: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IYouState {
|
interface IYouState {
|
||||||
@ -106,6 +107,9 @@ class You extends Component<IYouProps, IYouState> {
|
|||||||
this.props.enqueueSnackbar(
|
this.props.enqueueSnackbar(
|
||||||
"Avatar updated successfully."
|
"Avatar updated successfully."
|
||||||
);
|
);
|
||||||
|
this.props.onAvatarUpdate(
|
||||||
|
currentAccount.avatar_static
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch((err: Error) => {
|
.catch((err: Error) => {
|
||||||
this.props.closeSnackbar("persistAvatar");
|
this.props.closeSnackbar("persistAvatar");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user