Browse Source

Fix deprecated this.context usage

unoptim
GreatBearShark 2 years ago
parent
commit
233bae546d
  1. 13
      package.json
  2. 2
      public/index.html
  3. 9
      src/components/admin-settings.tsx
  4. 12
      src/components/community.tsx
  5. 7
      src/components/create-community.tsx
  6. 7
      src/components/create-post.tsx
  7. 7
      src/components/create-private-message.tsx
  8. 7
      src/components/main.tsx
  9. 344
      src/components/navbar.tsx
  10. 10
      src/components/post-listing.tsx
  11. 16
      src/components/reports.tsx
  12. 13
      src/components/user-details.tsx
  13. 18
      src/components/user.tsx
  14. 22
      yarn.lock

13
package.json

@ -14,7 +14,6 @@
"start": "node generate_translations.js && EXTEND_ESLINT=true TSC_COMPILE_ON_ERROR=true react-scripts start",
"start_old": "node fuse dev"
},
"extends": "@parcel/config-default",
"keywords": [],
"dependencies": {
"@joeattardi/emoji-button": "^3.1.1",
@ -27,6 +26,7 @@
"@types/qs": "^6.9.4",
"@types/react": "^16.9.44",
"@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.1.5",
"autosize": "^4.0.2",
"body-scroll-lock": "^3.0.3",
"bootswatch": "^4.3.1",
@ -81,6 +81,7 @@
"ts-transform-inferno": "^4.0.3",
"typescript": "^3.9.7"
},
"extends": "@parcel/config-default",
"engines": {
"node": ">=8.9.0"
},
@ -103,15 +104,15 @@
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
],
"production": [
">0.2%",
"not dead",
"not op_mini all"
]
}
}

2
public/index.html

@ -53,7 +53,7 @@
integrity="sha384-ibWewy8LWP0FdvEBD3iLjNmbFkkh/FKtOz8GR9C8ZBWjDTbjbdIDpa4nc/AasWns" crossorigin="anonymous">
</script>
<script src="https://hcaptcha.com/1/api.js"></script>
<!-- <script async src="%PUBLIC_URL%/libs/sortable/sortable.min.js"></script> -->
<script async src="%PUBLIC_URL%/libs/sortable/sortable.min.js"></script>
</head>
<body>

9
src/components/admin-settings.tsx

@ -1,4 +1,5 @@
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import {
@ -25,7 +26,7 @@ interface AdminSettingsState {
siteConfigLoading: boolean;
}
export class AdminSettings extends Component<any, AdminSettingsState> {
class BaseAdminSettings extends Component<any, AdminSettingsState> {
private siteConfigTextAreaId = `site-config-${randomStr()}`;
private subscription: Subscription;
private emptyState: AdminSettingsState = {
@ -208,7 +209,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
let res = wsJsonToRes(msg);
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
this.context.router.history.push('/');
this.props.history.push('/');
this.state.siteLoading = false;
this.state.siteConfigLoading = false;
this.setState(this.state);
@ -219,7 +220,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
// This means it hasn't been set up yet
if (!data.site) {
this.context.router.history.push('/setup');
this.props.history.push('/setup');
}
this.state.siteRes = data;
this.state.siteLoading = false;
@ -250,3 +251,5 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
}
}
}
export const AdminSettings = withRouter(BaseAdminSettings);

12
src/components/community.tsx

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Link, withRouter } from 'react-router-dom';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import {
@ -81,7 +81,7 @@ interface UrlParams {
page?: number;
}
export class Community extends Component<any, State> {
export class BaseCommunity extends Component<any, State> {
private subscription: Subscription;
private emptyState: State = {
community: {
@ -346,12 +346,12 @@ export class Community extends Component<any, State> {
}
nextPage(i: Community) {
i.updateUrl({ page: i.state.page + 1 });
i.updateUrl({ page: (i.state.page as number) + 1 });
window.scrollTo(0, 0);
}
prevPage(i: Community) {
i.updateUrl({ page: i.state.page - 1 });
i.updateUrl({ page: (i.state.page as number) - 1 });
window.scrollTo(0, 0);
}
@ -419,7 +419,7 @@ export class Community extends Component<any, State> {
let res = wsJsonToRes(msg);
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
this.context.router.history.push('/');
this.props.history.push('/');
return;
} else if (msg.reconnect) {
this.fetchData();
@ -504,3 +504,5 @@ export class Community extends Component<any, State> {
}
}
}
export const Community = withRouter(BaseCommunity);

7
src/components/create-community.tsx

@ -1,6 +1,7 @@
import React, { Component } from 'react';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import { withRouter } from 'react-router-dom';
import { CommunityForm } from './community-form';
import {
Community,
@ -16,7 +17,7 @@ interface CreateCommunityState {
enableNsfw: boolean;
}
export class CreateCommunity extends Component<any, CreateCommunityState> {
export class BaseCreateCommunity extends Component<any, CreateCommunityState> {
private subscription: Subscription;
private emptyState: CreateCommunityState = {
enableNsfw: null,
@ -28,7 +29,7 @@ export class CreateCommunity extends Component<any, CreateCommunityState> {
if (!UserService.Instance.user) {
toast(i18n.t('not_logged_in'), 'danger');
this.context.router.history.push(`/login`);
this.props.history.push(`/login`);
}
this.subscription = WebSocketService.Instance.subject
@ -80,3 +81,5 @@ export class CreateCommunity extends Component<any, CreateCommunityState> {
}
}
}
export const CreateCommunity = withRouter(BaseCreateCommunity);

7
src/components/create-post.tsx

@ -1,5 +1,6 @@
import React, { Component } from 'react';
import { Subscription } from 'rxjs';
import { withRouter } from 'react-router-dom';
import { retryWhen, delay, take } from 'rxjs/operators';
import { PostForm } from './post-form';
import { toast, wsJsonToRes } from '../utils';
@ -17,7 +18,7 @@ interface CreatePostState {
site: Site;
}
export class CreatePost extends Component<any, CreatePostState> {
export class BaseCreatePost extends Component<any, CreatePostState> {
private subscription: Subscription;
private emptyState: CreatePostState = {
site: {
@ -43,7 +44,7 @@ export class CreatePost extends Component<any, CreatePostState> {
if (!UserService.Instance.user) {
toast(i18n.t('not_logged_in'), 'danger');
this.context.router.history.push(`/login`);
this.props.history.push(`/login`);
}
this.subscription = WebSocketService.Instance.subject
@ -121,3 +122,5 @@ export class CreatePost extends Component<any, CreatePostState> {
}
}
}
export const CreatePost = withRouter(BaseCreatePost);

7
src/components/create-private-message.tsx

@ -11,8 +11,9 @@ import {
} from '../interfaces';
import { toast, wsJsonToRes } from '../utils';
import { i18n } from '../i18next';
import { withRouter } from 'react-router-dom';
export class CreatePrivateMessage extends Component<any, any> {
export class BaseCreatePrivateMessage extends Component<any, any> {
private subscription: Subscription;
constructor(props: any, context: any) {
super(props, context);
@ -22,7 +23,7 @@ export class CreatePrivateMessage extends Component<any, any> {
if (!UserService.Instance.user) {
toast(i18n.t('not_logged_in'), 'danger');
this.context.router.history.push(`/login`);
this.props.history.push(`/login`);
}
this.subscription = WebSocketService.Instance.subject
@ -86,3 +87,5 @@ export class CreatePrivateMessage extends Component<any, any> {
}
}
}
export const CreatePrivateMessage = withRouter(BaseCreatePrivateMessage);

7
src/components/main.tsx

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Link, withRouter } from 'react-router-dom';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import {
@ -194,6 +194,7 @@ class Main extends Component<any, MainState> {
}
render() {
console.log(this.props);
return (
<div className="container" style={{ maxWidth: '100%' }}>
<div className="row">
@ -688,7 +689,7 @@ class Main extends Component<any, MainState> {
// This means it hasn't been set up yet
if (!data.site) {
this.context.router.history.push('/setup');
this.props.history.push('/setup');
}
this.state.siteRes.admins = data.admins;
this.state.siteRes.site = data.site;
@ -805,4 +806,4 @@ class Main extends Component<any, MainState> {
}
}
export default withTranslation()(Main);
export default withTranslation()(withRouter(Main));

344
src/components/navbar.tsx

@ -38,7 +38,6 @@ import { Icon } from './icon';
import { CommunityDropdown } from './community-dropdown';
import { linkEvent } from '../linkEvent';
interface NavbarState {
isLoggedIn: boolean;
expanded: boolean;
@ -172,199 +171,200 @@ class UnwrappedNavbar extends Component<any, NavbarState> {
// TODO class active corresponding to current page
navbar() {
return <>
<nav className="container-fluid navbar navbar-expand-md navbar-light main-navbar shadow p-0 px-3">
<a className="navbar-brand" href="/">
<img
src="/hexbear_head.svg"
className="icon icon-navbar"
alt="vaporwave hammer and sickle logo, courtesy of ancestral potato"
/>
</a>
<Link title={version} className="navbar-brand" to="/">
{this.state.siteName}
</Link>
{this.state.isLoggedIn && (
<Link
className="ml-auto p-0 navbar-toggler nav-link"
to="/inbox"
title={i18n.t('inbox')}
>
<Icon name="notification" />
{this.state.unreadCount > 0 && (
<span className="ml-1 badge badge-light badge-pink">
{this.state.unreadCount}
</span>
)}
return (
<>
<nav className="container-fluid navbar navbar-expand-md navbar-light main-navbar shadow p-0 px-3">
<a className="navbar-brand" href="/">
<img
src="/hexbear_head.svg"
className="icon icon-navbar"
alt="vaporwave hammer and sickle logo, courtesy of ancestral potato"
/>
</a>
<Link title={version} className="navbar-brand" to="/">
{this.state.siteName}
</Link>
)}
<button
className="navbar-toggler"
type="button"
aria-label="menu"
onClick={linkEvent(this, this.expandNavbar)}
data-tippy-content={i18n.t('expand_here')}
>
<span className="navbar-toggler-icon"></span>
</button>
<div
className={`${!this.state.expanded && 'collapse'} navbar-collapse`}
>
<ul className="navbar-nav my-2 mr-auto">
<li className="nav-item">
<button
className="nav-link btn btn-inline "
//to="/communities"
title={i18n.t('communities')}
id="community-button"
onClick={linkEvent(this, this.showCommunityDropdown)}
>
{i18n.t('communities')}
</button>
</li>
<li className="nav-item">
<Link
className="nav-link"
to={{
pathname: '/create_post',
state: { prevPath: this.currentLocation },
}}
title={i18n.t('create_post')}
>
{i18n.t('create_post')}
</Link>
</li>
{this.showCreateCommunityNav() && (
{this.state.isLoggedIn && (
<Link
className="ml-auto p-0 navbar-toggler nav-link"
to="/inbox"
title={i18n.t('inbox')}
>
<Icon name="notification" />
{this.state.unreadCount > 0 && (
<span className="ml-1 badge badge-light badge-pink">
{this.state.unreadCount}
</span>
)}
</Link>
)}
<button
className="navbar-toggler"
type="button"
aria-label="menu"
onClick={linkEvent(this, this.expandNavbar)}
data-tippy-content={i18n.t('expand_here')}
>
<span className="navbar-toggler-icon"></span>
</button>
<div
className={`${!this.state.expanded && 'collapse'} navbar-collapse`}
>
<ul className="navbar-nav my-2 mr-auto">
<li className="nav-item">
<button
className="nav-link btn btn-inline "
//to="/communities"
title={i18n.t('communities')}
id="community-button"
onClick={linkEvent(this, this.showCommunityDropdown)}
>
{i18n.t('communities')}
</button>
</li>
<li className="nav-item">
<Link
className="nav-link"
to="/create_community"
title={i18n.t('create_community')}
to={{
pathname: '/create_post',
state: { prevPath: this.currentLocation },
}}
title={i18n.t('create_post')}
>
{i18n.t('create_community')}
{i18n.t('create_post')}
</Link>
</li>
)}
<li className="nav-item">
<Link
className="nav-link"
to="/contributing"
title={i18n.t('donate_to_lemmy')}
>
<Icon name="contribute" /> {i18n.t('donate')}
</Link>
</li>
</ul>
{!this.props.history.location.pathname.match(
/^\/search/
) && (
<form
className="form-inline"
onSubmit={linkEvent(this, this.handleSearchSubmit)}
>
<input
className={`form-control mr-0 search-input ${
this.state.toggleSearch ? 'show-input' : 'hide-input'
}`}
onInput={linkEvent(this, this.handleSearchParam)}
value={this.state.searchParam}
ref={this.searchTextField}
type="text"
placeholder={i18n.t('search')}
onBlur={linkEvent(this, this.handleSearchBlur)}
></input>
<button
name="search-btn"
onClick={linkEvent(this, this.handleSearchBtn)}
className={`btn btn-link ${this.state.toggleSearch ? 'px-2' : 'px-0'
}`}
style={{ color: 'var(--gray)' }}
>
<Icon name="search" />
</button>
</form>
)}
<ul className="navbar-nav my-2 navbar-right">
{this.canAdmin && (
{this.showCreateCommunityNav() && (
<li className="nav-item">
<Link
className="nav-link"
to="/create_community"
title={i18n.t('create_community')}
>
{i18n.t('create_community')}
</Link>
</li>
)}
<li className="nav-item">
<Link
className="nav-link p-0 px-2 nav-icon"
to={`/admin`}
title={i18n.t('admin_settings')}
className="nav-link"
to="/contributing"
title={i18n.t('donate_to_lemmy')}
>
<svg className="icon">
<use xlinkHref="#icon-settings"></use>
</svg>
<Icon name="contribute" /> {i18n.t('donate')}
</Link>
</li>
</ul>
{!this.props.history.location.pathname.match(/^\/search/) && (
<form
className="form-inline"
onSubmit={linkEvent(this, this.handleSearchSubmit)}
>
<input
className={`form-control mr-0 search-input ${
this.state.toggleSearch ? 'show-input' : 'hide-input'
}`}
onInput={linkEvent(this, this.handleSearchParam)}
value={this.state.searchParam}
ref={this.searchTextField}
type="text"
placeholder={i18n.t('search')}
onBlur={linkEvent(this, this.handleSearchBlur)}
></input>
<button
name="search-btn"
onClick={linkEvent(this, this.handleSearchBtn)}
className={`btn btn-link ${
this.state.toggleSearch ? 'px-2' : 'px-0'
}`}
style={{ color: 'var(--gray)' }}
>
<Icon name="search" />
</button>
</form>
)}
</ul>
{this.state.isLoggedIn ? (
<>
<ul className="navbar-nav my-2">
<ul className="navbar-nav my-2 navbar-right">
{this.canAdmin && (
<li className="nav-item">
<Link
className="nav-link p-0 px-2 nav-icon"
to="/inbox"
title={i18n.t('inbox')}
to={`/admin`}
title={i18n.t('admin_settings')}
>
<Icon name="notification" />
{this.state.unreadCount > 0 && (
<span className="ml-1 badge badge-light badge-pink">
{this.state.unreadCount}
</span>
)}
<svg className="icon">
<use xlinkHref="#icon-settings"></use>
</svg>
</Link>
</li>
</ul>
<ul className="navbar-nav">
)}
</ul>
{this.state.isLoggedIn ? (
<>
<ul className="navbar-nav my-2">
<li className="nav-item">
<Link
className="nav-link p-0 px-2 nav-icon"
to="/inbox"
title={i18n.t('inbox')}
>
<Icon name="notification" />
{this.state.unreadCount > 0 && (
<span className="ml-1 badge badge-light badge-pink">
{this.state.unreadCount}
</span>
)}
</Link>
</li>
</ul>
<ul className="navbar-nav">
<li className="nav-item">
<Link
className="nav-link"
to={`/u/${UserService.Instance.user.username}`}
title={i18n.t('settings')}
>
<span>
{UserService.Instance.user.avatar && showAvatars() && (
<img
src={pictrsAvatarThumbnail(
UserService.Instance.user.avatar
)}
height="32"
width="32"
className="rounded-circle mr-2"
/>
)}
{UserService.Instance.user.username}
</span>
</Link>
</li>
</ul>
</>
) : (
<ul className="navbar-nav my-2">
<li className="nav-item">
<Link
className="nav-link"
to={`/u/${UserService.Instance.user.username}`}
title={i18n.t('settings')}
to="/login"
title={i18n.t('login_sign_up')}
>
<span>
{UserService.Instance.user.avatar && showAvatars() && (
<img
src={pictrsAvatarThumbnail(
UserService.Instance.user.avatar
)}
height="32"
width="32"
className="rounded-circle mr-2"
/>
)}
{UserService.Instance.user.username}
</span>
{i18n.t('login_sign_up')}
</Link>
</li>
</ul>
</>
) : (
<ul className="navbar-nav my-2">
<li className="nav-item">
<Link
className="nav-link"
to="/login"
title={i18n.t('login_sign_up')}
>
{i18n.t('login_sign_up')}
</Link>
</li>
</ul>
)}
</div>
{this.state.communityDropdownShown && (
<CommunityDropdown
posX={this.communityButtonLoc}
removeDropdown={() => this.showCommunityDropdown(this)}
></CommunityDropdown>
)}
</div>
{this.state.communityDropdownShown && (
<CommunityDropdown
posX={this.communityButtonLoc}
removeDropdown={() => this.showCommunityDropdown(this)}
></CommunityDropdown>
)}
</nav>
{/* empty space below navbar */}
<div className="navbar-spacer" />
</>;
</nav>
{/* empty space below navbar */}
<div className="navbar-spacer" />
</>
);
}
expandNavbar(i: Navbar) {
@ -534,13 +534,9 @@ class UnwrappedNavbar extends Component<any, NavbarState> {
let htmlBody = imagesDownsize(md.render(reply.content), true, false);
let body = reply.content; // Unfortunately the notifications API can't do html
messageToastify(
creator_name,
creator_avatar,
htmlBody,
link,
this.context.router
);
messageToastify(creator_name, creator_avatar, htmlBody, link, {
history: this.props.history,
});
if (Notification.permission !== 'granted') Notification.requestPermission();
else {

10
src/components/post-listing.tsx

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Link, withRouter } from 'react-router-dom';
import { WebSocketService, UserService } from '../services';
import {
Post,
@ -82,7 +82,7 @@ export function PostBody({ body }: { body: string }) {
);
}
export class PostListing extends Component<PostListingProps, PostListingState> {
class BasePostListing extends Component<PostListingProps, PostListingState> {
private emptyState: PostListingState = {
showEdit: false,
showRemoveDialog: false,
@ -1124,7 +1124,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
handlePostLike(i: PostListing) {
if (!UserService.Instance.user) {
this.context.router.history.push(`/login`);
this.props.history.push(`/login`);
}
let new_vote = i.state.my_vote == 1 ? 0 : 1;
@ -1155,7 +1155,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
handlePostDisLike(i: PostListing) {
if (!UserService.Instance.user) {
this.context.router.history.push(`/login`);
this.props.history.push(`/login`);
}
let new_vote = i.state.my_vote == -1 ? 0 : -1;
@ -1468,3 +1468,5 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
return `${points}${upvotes}${downvotes}`;
}
}
export const PostListing = withRouter(BasePostListing);

16
src/components/reports.tsx

@ -21,7 +21,7 @@ import { Subscription } from 'rxjs';
import { wsJsonToRes, toast } from '../utils';
import { i18n } from '../i18next';
import { MomentTime } from './moment-time';
import { Link } from 'react-router-dom';
import { Link, withRouter } from 'react-router-dom';
import { linkEvent } from '../linkEvent';
interface ReportsState {
@ -48,7 +48,7 @@ interface ReportsState {
};
}
export class Reports extends Component<{}, ReportsState> {
export class BaseReports extends Component<{}, ReportsState> {
private subscription: Subscription;
constructor(props: any, context: any) {
super(props);
@ -231,8 +231,12 @@ export class Reports extends Component<{}, ReportsState> {
</div>
<p className="my-0">{report.reason}</p>
<div className="card p-1">
<p className="mb-0">Post Title: {report.post_name}</p>
<p className="mb-0">Post Body: {report.post_body}</p>
<p className="mb-0">
Post Title: {report.post_name}
</p>
<p className="mb-0">
Post Body: {report.post_body}
</p>
<p className="mb-0">
Submitted by:{' '}
<Link to={`/u/${report.creator_name}`}>
@ -595,7 +599,7 @@ export class Reports extends Component<{}, ReportsState> {
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
if (msg.error === 'couldnt_find_that_username_or_email') {
this.context.router.history.push('/');
this.props.history.push('/');
}
return;
} else if (res.op === UserOperation.GetUserDetails) {
@ -663,3 +667,5 @@ export class Reports extends Component<{}, ReportsState> {
}
}
}
export const Reports = withRouter(BaseReports);

13
src/components/user-details.tsx

@ -1,4 +1,4 @@
import React, { Component, } from 'react';
import React, { Component } from 'react';
import { WebSocketService, UserService } from '../services';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take, last } from 'rxjs/operators';
@ -32,6 +32,7 @@ import {
import { PostListing } from './post-listing';
import { CommentNodes } from './comment-nodes';
import { linkEvent } from '../linkEvent';
import { withRouter } from 'react-router-dom';
interface UserDetailsProps {
username?: string;
@ -55,7 +56,7 @@ interface UserDetailsState {
admins: Array<UserView>;
}
export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
class BaseUserDetails extends Component<UserDetailsProps, UserDetailsState> {
private subscription: Subscription;
constructor(props: any, context: any) {
super(props, context);
@ -229,11 +230,11 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
}
nextPage(i: UserDetails) {
i.props.onPageChange(i.props.page + 1);
i.props.onPageChange((i.props.page as number) + 1);
}
prevPage(i: UserDetails) {
i.props.onPageChange(i.props.page - 1);
i.props.onPageChange((i.props.page as number) - 1);
}
parseMessage(msg: WebSocketJsonResponse) {
@ -243,7 +244,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
if (msg.error == 'couldnt_find_that_username_or_email') {
this.context.router.history.push('/');
this.props.history.push('/');
}
return;
} else if (msg.reconnect) {
@ -309,3 +310,5 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
}
}
}
export const UserDetails = withRouter(BaseUserDetails);

18
src/components/user.tsx

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Link, withRouter } from 'react-router-dom';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
import {
@ -97,7 +97,7 @@ function getPageFromProps(page: any): number {
return page ? Number(page) : 1;
}
export class User extends Component<any, UserState> {
class BaseUser extends Component<any, UserState> {
private subscription: Subscription;
private emptyState: UserState = {
user: {
@ -823,9 +823,11 @@ export class User extends Component<any, UserState> {
)}
{this.state.banUserShow && (
<form onSubmit={linkEvent(this, this.handleBan)}>
<div style={{
display: "flex"
}}>
<div
style={{
display: 'flex',
}}
>
<input
id="reason"
placeholder="reason"
@ -1154,7 +1156,7 @@ export class User extends Component<any, UserState> {
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
if (msg.error == 'couldnt_find_that_username_or_email') {
this.context.router.history.push('/');
this.props.history.push('/');
}
this.setState({
deleteAccountLoading: false,
@ -1204,7 +1206,7 @@ export class User extends Component<any, UserState> {
deleteAccountLoading: false,
deleteAccountShowConfirm: false,
});
this.context.router.history.push('/');
this.props.history.push('/');
} else if (res.op == UserOperation.GetSite) {
const data = res.data as GetSiteResponse;
this.setState({
@ -1220,3 +1222,5 @@ export class User extends Component<any, UserState> {
}
}
}
export const User = withRouter(BaseUser);

22
yarn.lock

@ -1833,6 +1833,11 @@
"@types/minimatch" "*"
"@types/node" "*"
"@types/[email protected]*":
version "4.7.7"
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.7.tgz#613957d900fab9ff84c8dfb24fa3eef0c2a40896"
integrity sha512-2xtoL22/3Mv6a70i4+4RB7VgbDDORoWwjcqeNysojZA0R7NK17RbY5Gof/2QiFfJgX+KkWghbwJ+d/2SB8Ndzg==
"@types/[email protected]*", "@types/[email protected]^2.0.0":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff"
@ -1962,6 +1967,23 @@
dependencies:
"@types/react" "*"
"@types/[email protected]^5.1.5":
version "5.1.5"
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.1.5.tgz#7c334a2ea785dbad2b2dcdd83d2cf3d9973da090"
integrity sha512-ArBM4B1g3BWLGbaGvwBGO75GNFbLDUthrDojV2vHLih/Tq8M+tgvY1DSwkuNrPSwdp/GUL93WSEpTZs8nVyJLw==
dependencies:
"@types/history" "*"
"@types/react" "*"
"@types/react-router" "*"
"@types/[email protected]*":
version "5.1.8"
resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.8.tgz#4614e5ba7559657438e17766bb95ef6ed6acc3fa"
integrity sha512-HzOyJb+wFmyEhyfp4D4NYrumi+LQgQL/68HvJO+q6XtuHSDvw6Aqov7sCAhjbNq3bUPgPqbdvjXC5HeB2oEAPg==
dependencies:
"@types/history" "*"
"@types/react" "*"
"@types/[email protected]*", "@types/[email protected]^16.9.44":
version "16.9.44"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.44.tgz#da84b179c031aef67dc92c33bd3401f1da2fa3bc"

Loading…
Cancel
Save