1
0
mirror of https://github.com/hyperspacedev/hyperspace synced 2025-02-09 16:28:43 +01:00

Store account ID in session storage for quicker access

Signed-off-by: Marquis Kurt <software@marquiskurt.net>
This commit is contained in:
Marquis Kurt 2019-10-03 16:48:11 -04:00
parent 0c785fd11a
commit 700fd10a58
No known key found for this signature in database
GPG Key ID: 725636D259F5402D
3 changed files with 5 additions and 3 deletions

View File

@ -120,6 +120,7 @@ export class AppLayout extends Component<any, IAppLayoutState> {
.then((resp: any) => { .then((resp: any) => {
let data: UAccount = resp.data; let data: UAccount = resp.data;
this.setState({ currentUser: data }); this.setState({ currentUser: data });
sessionStorage.setItem("id", data.id);
}) })
.catch((err: Error) => { .catch((err: Error) => {
this.props.enqueueSnackbar( this.props.enqueueSnackbar(

View File

@ -72,7 +72,7 @@ interface IPostState {
menuIsOpen: boolean; menuIsOpen: boolean;
myVote?: [number]; myVote?: [number];
deletePostDialog: boolean; deletePostDialog: boolean;
myAccount?: Account; myAccount?: string;
} }
export class Post extends React.Component<any, IPostState> { export class Post extends React.Component<any, IPostState> {
@ -96,7 +96,7 @@ export class Post extends React.Component<any, IPostState> {
componentWillMount() { componentWillMount() {
this.setState({ this.setState({
myAccount: JSON.parse(localStorage.getItem("account") as string) myAccount: sessionStorage.getItem("id") as string
}); });
} }
@ -831,7 +831,7 @@ export class Post extends React.Component<any, IPostState> {
</MenuItem> </MenuItem>
</div> </div>
{this.state.myAccount && {this.state.myAccount &&
post.account.id == this.state.myAccount.id ? ( post.account.id === this.state.myAccount ? (
<div> <div>
<Divider /> <Divider />
<MenuItem <MenuItem

View File

@ -18,6 +18,7 @@ export function refreshUserAccountData() {
.then((resp: any) => { .then((resp: any) => {
let account: Account = resp.data; let account: Account = resp.data;
localStorage.setItem("account", JSON.stringify(account)); localStorage.setItem("account", JSON.stringify(account));
sessionStorage.setItem("id", account.id);
addAccountToRegistry(host, token, account.acct); addAccountToRegistry(host, token, account.acct);
}) })