Browse Source

ui: Updating some setState and errors vscode is finding.

unoptim
Stalinist Apologist 2 years ago
parent
commit
db4e3056c7
  1. 15
      src/components/community-dropdown.tsx
  2. 54
      src/components/community.tsx
  3. 6
      src/components/create-community.tsx
  4. 5
      src/components/create-post.tsx
  5. 5
      src/components/iframely-card.tsx
  6. 60
      src/components/inbox.tsx
  7. 17
      src/components/login.tsx
  8. 10
      src/components/main.tsx
  9. 69
      src/components/post-listing.tsx
  10. 5
      src/components/post-listings.tsx
  11. 17
      src/components/private-message.tsx
  12. 12
      src/components/reports.tsx
  13. 25
      src/components/search.tsx
  14. 16
      src/components/setup.tsx
  15. 5
      src/components/site-form.tsx
  16. 4
      src/components/user-details.tsx
  17. 42
      src/components/user.tsx
  18. 2
      src/components/welcome.tsx

15
src/components/community-dropdown.tsx

@ -295,14 +295,17 @@ export class CommunityDropdown extends Component<
return;
} else if (res.op == UserOperation.ListCommunities) {
let data = res.data as ListCommunitiesResponse;
this.state.communities = data.communities;
this.state.loading = false;
this.setState(this.state);
this.setState({
communities: data.communities,
loading: false
});
} else if (res.op == UserOperation.GetUserDetails) {
let data = res.data as UserDetailsResponse;
this.state.subscriptions = data.follows;
this.setState(this.state);
this.onLoadingComplete();
this.setState({
subscriptions: data.follows,
}, () => {
this.onLoadingComplete();
});
}
}
}

54
src/components/community.tsx

@ -345,12 +345,12 @@ export class BaseCommunity extends Component<any, State> {
);
}
nextPage(i: Community) {
nextPage(i: BaseCommunity) {
i.updateUrl({ page: (i.state.page as number) + 1 });
window.scrollTo(0, 0);
}
prevPage(i: Community) {
prevPage(i: BaseCommunity) {
i.updateUrl({ page: (i.state.page as number) - 1 });
window.scrollTo(0, 0);
}
@ -425,17 +425,20 @@ export class BaseCommunity extends Component<any, State> {
this.fetchData();
} else if (res.op == UserOperation.GetCommunity) {
let data = res.data as GetCommunityResponse;
this.state.community = data.community;
this.state.moderators = data.moderators;
this.state.admins = data.admins;
this.state.online = data.online;
this.setState({
community: data.community,
moderators: data.moderators,
admins: data.admins,
online: data.online,
}, () => {
this.fetchData();
});
document.title = `/c/${this.state.community.name} - ${this.state.site.name}`;
this.setState(this.state);
this.fetchData();
} else if (res.op == UserOperation.EditCommunity) {
let data = res.data as CommunityResponse;
this.state.community = data.community;
this.setState(this.state);
this.setState({
community: data.community
});
} else if (res.op == UserOperation.FollowCommunity) {
let data = res.data as CommunityResponse;
this.state.community.subscribed = data.community.subscribed;
@ -444,10 +447,12 @@ export class BaseCommunity extends Component<any, State> {
this.setState(this.state);
} else if (res.op == UserOperation.GetPosts) {
let data = res.data as GetPostsResponse;
this.state.posts = data.posts;
this.state.loading = false;
this.setState(this.state);
setupTippy();
this.setState({
posts: data.posts,
loading: false
}, () => {
setupTippy()
});
} else if (res.op == UserOperation.EditPost) {
let data = res.data as PostResponse;
editPostFindRes(data, this.state.posts);
@ -462,21 +467,21 @@ export class BaseCommunity extends Component<any, State> {
this.setState(this.state);
} else if (res.op == UserOperation.AddModToCommunity) {
let data = res.data as AddModToCommunityResponse;
this.state.moderators = data.moderators;
this.setState(this.state);
this.setState({
moderators: data.moderators
});
} else if (res.op == UserOperation.BanFromCommunity) {
let data = res.data as BanFromCommunityResponse;
this.state.posts
.filter(p => p.creator_id == data.user.id)
.forEach(p => (p.banned = data.banned));
this.setState(this.state);
} else if (res.op == UserOperation.GetComments) {
let data = res.data as GetCommentsResponse;
this.state.comments = data.comments;
this.state.loading = false;
this.setState(this.state);
this.setState({
comments: data.comments,
loading: false
});
} else if (res.op == UserOperation.EditComment) {
let data = res.data as CommentResponse;
editCommentRes(data, this.state.comments);
@ -492,15 +497,14 @@ export class BaseCommunity extends Component<any, State> {
} else if (res.op == UserOperation.SaveComment) {
let data = res.data as CommentResponse;
saveCommentRes(data, this.state.comments);
this.setState(this.state);
} else if (res.op == UserOperation.CreateCommentLike) {
let data = res.data as CommentResponse;
createCommentLikeRes(data, this.state.comments);
this.setState(this.state);
} else if (res.op == UserOperation.GetSite) {
let data = res.data as GetSiteResponse;
this.state.site = data.site;
this.setState(this.state);
this.setState({
site: data.site
});
}
}
}

6
src/components/create-community.tsx

@ -68,15 +68,15 @@ export class BaseCreateCommunity extends Component<any, CreateCommunityState> {
}
parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (msg.error) {
// Toast errors are already handled by community-form
return;
} else if (res.op == UserOperation.GetSite) {
let data = res.data as GetSiteResponse;
this.state.enableNsfw = data.site.enable_nsfw;
this.setState(this.state);
this.setState({
enableNsfw: data.site.enable_nsfw
});
document.title = `${i18n.t('create_community')} - ${data.site.name}`;
}
}

5
src/components/create-post.tsx

@ -116,8 +116,9 @@ export class BaseCreatePost extends Component<any, CreatePostState> {
return;
} else if (res.op == UserOperation.GetSite) {
let data = res.data as GetSiteResponse;
this.state.site = data.site;
this.setState(this.state);
this.setState({
site: data.site
});
document.title = `${i18n.t('create_post')} - ${data.site.name}`;
}
}

5
src/components/iframely-card.tsx

@ -105,7 +105,8 @@ export class IFramelyCard extends Component<
}
handleIframeExpand(i: IFramelyCard) {
i.state.expanded = !i.state.expanded;
i.setState(i.state);
this.setState((prevState) => ({
expanded: !prevState.expanded
}));
}
}

60
src/components/inbox.tsx

@ -348,29 +348,37 @@ export class Inbox extends Component<any, InboxState> {
}
nextPage(i: Inbox) {
i.state.page++;
i.setState(i.state);
i.refetch();
this.setState((prevState) => ({
page: prevState.page + 1
}), () => {
i.refetch();
});
}
prevPage(i: Inbox) {
i.state.page--;
i.setState(i.state);
i.refetch();
this.setState((prevState) => ({
page: prevState.page - 1
}), () => {
i.refetch();
});
}
handleUnreadOrAllChange(i: Inbox, event: any) {
i.state.unreadOrAll = Number(event.target.value);
i.state.page = 1;
i.setState(i.state);
i.refetch();
this.setState({
unreadOrAll: Number(event.target.value),
page: 1
}, () => {
i.refetch();
});
}
handleMessageTypeChange(i: Inbox, event: any) {
i.state.messageType = Number(event.target.value);
i.state.page = 1;
i.setState(i.state);
i.refetch();
this.setState({
messageType: Number(event.target.value),
page: 1
}, () => {
i.refetch();
});
}
refetch() {
@ -399,20 +407,24 @@ export class Inbox extends Component<any, InboxState> {
}
handleSortChange(val: SortType) {
this.state.sort = val;
this.state.page = 1;
this.setState(this.state);
this.refetch();
this.setState({
sort: val,
page: 1
}, () => {
this.refetch();
});
}
markAllAsRead(i: Inbox) {
WebSocketService.Instance.markAllAsRead();
i.state.replies = [];
i.state.mentions = [];
i.state.messages = [];
i.sendUnreadCount();
window.scrollTo(0, 0);
i.setState(i.state);
this.setState({
replies: [],
mentions: [],
messages: [],
}, () => {
i.sendUnreadCount();
window.scrollTo(0, 0);
});
}
parseMessage(msg: WebSocketJsonResponse) {

17
src/components/login.tsx

@ -172,8 +172,7 @@ export class Login extends Component<any, State> {
<div className="form-group row">
{/*hcaptcha target*/}
<div
className="h-captcha"
className="col-sm-10"
className="col-sm-10 h-captcha"
id="h-captcha"
data-sitekey={HCAPTCHA_SITE_KEY}
data-theme="dark"
@ -340,8 +339,7 @@ export class Login extends Component<any, State> {
<div className="form-group row">
{/*hcaptcha target*/}
<div
className="h-captcha h-captcha-register"
className="col-sm-10"
className="col-sm-10 h-captcha h-captcha-register"
id="h-captcha-register"
data-sitekey={HCAPTCHA_SITE_KEY}
data-theme="dark"
@ -513,9 +511,14 @@ export class Login extends Component<any, State> {
toast(i18n.t('reset_password_mail_sent'));
} else if (res.op == UserOperation.GetSite) {
let data = res.data as GetSiteResponse;
this.state.enable_nsfw = data.site.enable_nsfw;
this.setState(this.state);
document.title = `${i18n.t('login')} - ${data.site.name}`;
if (data.site) {
this.setState({
enable_nsfw: data.site.enable_nsfw
});
document.title = `${i18n.t('login')} - ${data.site.name}`;
} else {
console.log('site is null');
}
}
}
}

10
src/components/main.tsx

@ -606,13 +606,15 @@ class Main extends Component<any, MainState> {
}
handleEditClick(i: Main) {
i.state.showEditSite = true;
i.setState(i.state);
this.setState({
showEditSite: true
});
}
handleEditCancel() {
this.state.showEditSite = false;
this.setState(this.state);
this.setState({
showEditSite: false
});
}
nextPage(i: Main) {

69
src/components/post-listing.tsx

@ -120,14 +120,13 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
}
UNSAFE_componentWillReceiveProps(nextProps: PostListingProps) {
this.state.my_vote = nextProps.post.my_vote;
this.state.upvotes = nextProps.post.upvotes;
this.state.downvotes = nextProps.post.downvotes;
this.state.score = nextProps.post.score;
if (this.props.post.id !== nextProps.post.id) {
this.state.imageExpanded = false;
}
this.setState(this.state);
this.setState({
my_vote: nextProps.post.my_vote,
upvotes: nextProps.post.upvotes,
downvotes: nextProps.post.downvotes,
score: nextProps.post.score,
imageExpanded: this.props.post.id === nextProps.post.id
});
}
render() {
@ -1130,7 +1129,7 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
);
}
handlePostLike(i: PostListing) {
handlePostLike(i: BasePostListing) {
if (!UserService.Instance.user) {
this.props.history.push(`/login`);
}
@ -1161,7 +1160,7 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
setupTippy();
}
handlePostDisLike(i: PostListing) {
handlePostDisLike(i: BasePostListing) {
if (!UserService.Instance.user) {
this.props.history.push(`/login`);
}
@ -1192,7 +1191,7 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
setupTippy();
}
handleEditClick(i: PostListing) {
handleEditClick(i: BasePostListing) {
i.state.showEdit = true;
i.setState(i.state);
}
@ -1208,7 +1207,7 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
this.setState(this.state);
}
handleDeleteClick(i: PostListing) {
handleDeleteClick(i: BasePostListing) {
let deleteForm: PostFormI = {
body: i.props.post.body,
community_id: i.props.post.community_id,
@ -1223,7 +1222,7 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
WebSocketService.Instance.editPost(deleteForm);
}
handleSavePostClick(i: PostListing) {
handleSavePostClick(i: BasePostListing) {
let saved = i.props.post.saved == undefined ? true : !i.props.post.saved;
let form: SavePostForm = {
post_id: i.props.post.id,
@ -1254,12 +1253,12 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
i.setState(i.state);
}
handleModRemoveReasonChange(i: PostListing, event: any) {
handleModRemoveReasonChange(i: BasePostListing, event: any) {
i.state.removeReason = event.target.value;
i.setState(i.state);
}
handleModRemoveSubmit(i: PostListing) {
handleModRemoveSubmit(i: BasePostListing) {
event.preventDefault();
let form: PostFormI = {
name: i.props.post.name,
@ -1276,7 +1275,7 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
i.setState(i.state);
}
handleModLock(i: PostListing) {
handleModLock(i: BasePostListing) {
let form: PostFormI = {
name: i.props.post.name,
community_id: i.props.post.community_id,
@ -1289,7 +1288,7 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
WebSocketService.Instance.editPost(form);
}
handleModSticky(i: PostListing) {
handleModSticky(i: BasePostListing) {
let form: PostFormI = {
name: i.props.post.name,
community_id: i.props.post.community_id,
@ -1302,41 +1301,41 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
WebSocketService.Instance.editPost(form);
}
handleModBanFromCommunityShow(i: PostListing) {
handleModBanFromCommunityShow(i: BasePostListing) {
i.state.showBanDialog = true;
i.state.banType = BanType.Community;
i.setState(i.state);
}
handleModBanShow(i: PostListing) {
handleModBanShow(i: BasePostListing) {
i.state.showBanDialog = true;
i.state.banType = BanType.Site;
i.setState(i.state);
}
handleModBanReasonChange(i: PostListing, event: any) {
handleModBanReasonChange(i: BasePostListing, event: any) {
i.state.banReason = event.target.value;
i.setState(i.state);
}
handleModBanExpiresChange(i: PostListing, event: any) {
handleModBanExpiresChange(i: BasePostListing, event: any) {
i.state.banExpires = event.target.value;
i.setState(i.state);
}
handleModBanFromCommunitySubmit(i: PostListing) {
handleModBanFromCommunitySubmit(i: BasePostListing) {
i.state.banType = BanType.Community;
i.setState(i.state);
i.handleModBanBothSubmit(i);
}
handleModBanSubmit(i: PostListing) {
handleModBanSubmit(i: BasePostListing) {
i.state.banType = BanType.Site;
i.setState(i.state);
i.handleModBanBothSubmit(i);
}
handleModBanBothSubmit(i: PostListing) {
handleModBanBothSubmit(i: BasePostListing) {
event.preventDefault();
if (i.state.banType == BanType.Community) {
@ -1381,17 +1380,17 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
i.setState(i.state);
}
handleShowConfirmTransferCommunity(i: PostListing) {
handleShowConfirmTransferCommunity(i: BasePostListing) {
i.state.showConfirmTransferCommunity = true;
i.setState(i.state);
}
handleCancelShowConfirmTransferCommunity(i: PostListing) {
handleCancelShowConfirmTransferCommunity(i: BasePostListing) {
i.state.showConfirmTransferCommunity = false;
i.setState(i.state);
}
handleTransferCommunity(i: PostListing) {
handleTransferCommunity(i: BasePostListing) {
let form: TransferCommunityForm = {
community_id: i.props.post.community_id,
user_id: i.props.post.creator_id,
@ -1401,17 +1400,17 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
i.setState(i.state);
}
handleShowConfirmTransferSite(i: PostListing) {
handleShowConfirmTransferSite(i: BasePostListing) {
i.state.showConfirmTransferSite = true;
i.setState(i.state);
}
handleCancelShowConfirmTransferSite(i: PostListing) {
handleCancelShowConfirmTransferSite(i: BasePostListing) {
i.state.showConfirmTransferSite = false;
i.setState(i.state);
}
handleTransferSite(i: PostListing) {
handleTransferSite(i: BasePostListing) {
let form: TransferSiteForm = {
user_id: i.props.post.creator_id,
};
@ -1420,27 +1419,27 @@ class BasePostListing extends Component<PostListingProps, PostListingState> {
i.setState(i.state);
}
handleImageExpandClick(i: PostListing) {
handleImageExpandClick(i: BasePostListing) {
i.state.imageExpanded = !i.state.imageExpanded;
i.setState(i.state);
}
handleViewSource(i: PostListing) {
handleViewSource(i: BasePostListing) {
i.state.viewSource = !i.state.viewSource;
i.setState(i.state);
}
handleReportPost(i: PostListing) {
handleReportPost(i: BasePostListing) {
i.state.showReportDialog = !i.state.showReportDialog;
i.setState(i.state);
}
handleReportReasonChange(i: PostListing, event: any) {
handleReportReasonChange(i: BasePostListing, event: any) {
i.state.reportReason = event.target.value;
i.setState(i.state);
}
handleReportSubmit(i: PostListing, e: any) {
handleReportSubmit(i: BasePostListing, e: any) {
e.preventDefault();
WebSocketService.Instance.createPostReport({

5
src/components/post-listings.tsx

@ -36,8 +36,9 @@ export class PostListings extends Component<
//are we getting updated post array? save current scroll pos
UNSAFE_componentWillReceiveProps() {
this.state.scrollPos = window.scrollY;
this.setState(this.state);
this.setState({
scrollPos: window.scrollY
});
}
//have we updated? revert scroll to top (bug on inferno side?) - scroll back to previous pos

17
src/components/private-message.tsx

@ -266,9 +266,10 @@ export class PrivateMessage extends Component<
}
handleReplyCancel() {
this.state.showReply = false;
this.state.showEdit = false;
this.setState(this.state);
this.setState({
showReply: false,
showEdit: false
});
}
handleMarkRead(i: PrivateMessage) {
@ -290,13 +291,15 @@ export class PrivateMessage extends Component<
}
handlePrivateMessageEdit() {
this.state.showEdit = false;
this.setState(this.state);
this.setState({
showEdit: false
});
}
handlePrivateMessageCreate() {
this.state.showReply = false;
this.setState(this.state);
this.setState({
showReply: false
});
toast(i18n.t('message_sent'));
}
}

12
src/components/reports.tsx

@ -404,7 +404,7 @@ export class BaseReports extends Component<{}, ReportsState> {
this.setState({ currentBanDialog: report, banReason: '' });
}
handleBanSubmit(i: Reports, event: any) {
handleBanSubmit(i: BaseReports, event: any) {
event.preventDefault();
const form: BanFromCommunityForm = {
@ -423,7 +423,7 @@ export class BaseReports extends Component<{}, ReportsState> {
});
}
handleBanReasonChange(i: Reports, event: any) {
handleBanReasonChange(i: BaseReports, event: any) {
i.state.banReason = event.target.value;
i.setState(i.state);
}
@ -432,7 +432,7 @@ export class BaseReports extends Component<{}, ReportsState> {
this.setState({ currentRemoveDialog: report, removeReason: '' });
}
handleRemoveCommentSubmit(i: Reports, event: any) {
handleRemoveCommentSubmit(i: BaseReports, event: any) {
event.preventDefault();
const {
@ -460,7 +460,7 @@ export class BaseReports extends Component<{}, ReportsState> {
});
}
handleRemovePostSubmit(i: Reports, event: any) {
handleRemovePostSubmit(i: BaseReports, event: any) {
event.preventDefault();
const {
@ -487,7 +487,7 @@ export class BaseReports extends Component<{}, ReportsState> {
i.setState(i.state);
}
handleRemoveReasonChange(i: Reports, event: any) {
handleRemoveReasonChange(i: BaseReports, event: any) {
i.state.removeReason = event.target.value;
i.setState(i.state);
}
@ -565,7 +565,7 @@ export class BaseReports extends Component<{}, ReportsState> {
currentRemoveDialog: PostReport | CommentReport | null;
report: PostReport | CommentReport;
removeReason: string;
cb: (i: Reports, event: any) => void;
cb: (i: BaseReports, event: any) => void;
}) {
return (
currentRemoveDialog &&

25
src/components/search.tsx

@ -90,6 +90,7 @@ export class Search extends Component<any, SearchState> {
number_of_comments: undefined,
number_of_communities: undefined,
enable_downvotes: undefined,
enable_create_communities: undefined,
open_registration: undefined,
enable_nsfw: undefined,
},
@ -499,13 +500,15 @@ export class Search extends Component<any, SearchState> {
return;
} else if (res.op == UserOperation.Search) {
let data = res.data as SearchResponse;
this.state.searchResponse = data;
this.state.loading = false;
document.title = `${i18n.t('search')} - ${this.state.q} - ${
this.state.site.name
}`;
window.scrollTo(0, 0);
this.setState(this.state);
this.setState({
searchResponse: data,
loading: false,
}, () => {
document.title = `${i18n.t('search')} - ${this.state.q} - ${
this.state.site.name
}`;
window.scrollTo(0, 0);
});
} else if (res.op == UserOperation.CreateCommentLike) {
let data = res.data as CommentResponse;
createCommentLikeRes(data, this.state.searchResponse.comments);
@ -516,9 +519,11 @@ export class Search extends Component<any, SearchState> {
this.setState(this.state);
} else if (res.op == UserOperation.GetSite) {
let data = res.data as GetSiteResponse;
this.state.site = data.site;
this.setState(this.state);
document.title = `${i18n.t('search')} - ${data.site.name}`;
this.setState({
site: data.site
}, () => {
document.title = `${i18n.t('search')} - ${data.site.name}`;
});
}
}
}

16
src/components/setup.tsx

@ -192,15 +192,17 @@ export class Setup extends Component<any, State> {
let res = wsJsonToRes(msg);
if (msg.error) {
toast(i18n.t(msg.error), 'danger');
this.state.userLoading = false;
this.setState(this.state);
return;
this.setState({
userLoading: false
});
} else if (res.op == UserOperation.Register) {
let data = res.data as LoginResponse;
this.state.userLoading = false;
this.state.doneRegisteringUser = true;
UserService.Instance.login(data);
this.setState(this.state);
this.setState({
userLoading: false,
doneRegisteringUser: true
}, () => {
UserService.Instance.login(data)
});
} else if (res.op == UserOperation.CreateSite) {
this.props.history.push('/');
}

5
src/components/site-form.tsx

@ -52,8 +52,9 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
// Necessary to stop the loading
UNSAFE_componentWillReceiveProps() {
this.state.loading = false;
this.setState(this.state);
this.setState({
loading: false
});
}
componentDidUpdate() {

4
src/components/user-details.tsx

@ -229,11 +229,11 @@ class BaseUserDetails extends Component<UserDetailsProps, UserDetailsState> {
);
}
nextPage(i: UserDetails) {
nextPage(i: BaseUserDetails) {
i.props.onPageChange((i.props.page as number) + 1);
}
prevPage(i: UserDetails) {
prevPage(i: BaseUserDetails) {
i.props.onPageChange((i.props.page as number) - 1);
}

42
src/components/user.tsx

@ -990,36 +990,36 @@ class BaseUser extends Component<any, UserState> {
this.updateUrl({ sort: SortType[val].toLowerCase(), page: 1 });
}
handleViewChange(i: User, event: any) {
handleViewChange(i: BaseUser, event: any) {
i.updateUrl({
view: UserDetailsView[Number(event.target.value)].toLowerCase(),
page: 1,
});
}
handleUserSettingsShowNsfwChange(i: User, event: any) {
handleUserSettingsShowNsfwChange(i: BaseUser, event: any) {
i.state.userSettingsForm.show_nsfw = event.target.checked;
i.setState(i.state);
}
handleUserSettingsShowAvatarsChange(i: User, event: any) {
handleUserSettingsShowAvatarsChange(i: BaseUser, event: any) {
i.state.userSettingsForm.show_avatars = event.target.checked;
UserService.Instance.user.show_avatars = event.target.checked; // Just for instant updates
i.setState(i.state);
}
handleUserSettingsSendNotificationsToEmailChange(i: User, event: any) {
handleUserSettingsSendNotificationsToEmailChange(i: BaseUser, event: any) {
i.state.userSettingsForm.send_notifications_to_email = event.target.checked;
i.setState(i.state);
}
handleUserSettingsThemeChange(i: User, event: any) {
handleUserSettingsThemeChange(i: BaseUser, event: any) {
i.state.userSettingsForm.theme = event.target.value;
setTheme(event.target.value, true);
i.setState(i.state);
}
handleUserSettingsLangChange(i: User, event: any) {
handleUserSettingsLangChange(i: BaseUser, event: any) {
i.state.userSettingsForm.lang = event.target.value;
i18n.changeLanguage(i.state.userSettingsForm.lang);
i.setState(i.state);
@ -1036,7 +1036,7 @@ class BaseUser extends Component<any, UserState> {
this.setState(this.state);
}
handleUserSettingsEmailChange(i: User, event: any) {
handleUserSettingsEmailChange(i: BaseUser, event: any) {
i.state.userSettingsForm.email = event.target.value;
if (i.state.userSettingsForm.email == '' && !i.state.user.email) {
i.state.userSettingsForm.email = undefined;
@ -1044,7 +1044,7 @@ class BaseUser extends Component<any, UserState> {
i.setState(i.state);
}
handleUserSettingsMatrixUserIdChange(i: User, event: any) {
handleUserSettingsMatrixUserIdChange(i: BaseUser, event: any) {
i.state.userSettingsForm.matrix_user_id = event.target.value;
if (
i.state.userSettingsForm.matrix_user_id == '' &&
@ -1055,7 +1055,7 @@ class BaseUser extends Component<any, UserState> {
i.setState(i.state);
}
handleUserSettingsNewPasswordChange(i: User, event: any) {
handleUserSettingsNewPasswordChange(i: BaseUser, event: any) {
i.state.userSettingsForm.new_password = event.target.value;
if (i.state.userSettingsForm.new_password == '') {
i.state.userSettingsForm.new_password = undefined;
@ -1063,7 +1063,7 @@ class BaseUser extends Component<any, UserState> {
i.setState(i.state);
}
handleUserSettingsNewPasswordVerifyChange(i: User, event: any) {
handleUserSettingsNewPasswordVerifyChange(i: BaseUser, event: any) {
i.state.userSettingsForm.new_password_verify = event.target.value;
if (i.state.userSettingsForm.new_password_verify == '') {
i.state.userSettingsForm.new_password_verify = undefined;
@ -1071,7 +1071,7 @@ class BaseUser extends Component<any, UserState> {
i.setState(i.state);
}
handleUserSettingsOldPasswordChange(i: User, event: any) {
handleUserSettingsOldPasswordChange(i: BaseUser, event: any) {
i.state.userSettingsForm.old_password = event.target.value;
if (i.state.userSettingsForm.old_password == '') {
i.state.userSettingsForm.old_password = undefined;
@ -1079,7 +1079,7 @@ class BaseUser extends Component<any, UserState> {
i.setState(i.state);
}
handleImageUpload(i: User, event: any) {
handleImageUpload(i: BaseUser, event: any) {
event.preventDefault();
let file = event.target.files[0];
const imageUploadUrl = `/pictrs/image`;
@ -1116,7 +1116,7 @@ class BaseUser extends Component<any, UserState> {
});
}
removeAvatar(i: User, event: any) {
removeAvatar(i: BaseUser, event: any) {
event.preventDefault();
i.state.userSettingsLoading = true;
i.state.userSettingsForm.avatar = '';
@ -1132,7 +1132,7 @@ class BaseUser extends Component<any, UserState> {
);
}
handleUserSettingsSubmit(i: User, event: any) {
handleUserSettingsSubmit(i: BaseUser, event: any) {
event.preventDefault();
i.state.userSettingsLoading = true;
i.setState(i.state);
@ -1166,23 +1166,23 @@ class BaseUser extends Component<any, UserState> {
this.setState({ additionalPronouns: e.target.value });
}
handleDeleteAccountShowConfirmToggle(i: User, event: any) {
handleDeleteAccountShowConfirmToggle(i: BaseUser, event: any) {
event.preventDefault();
i.state.deleteAccountShowConfirm = !i.state.deleteAccountShowConfirm;
i.setState(i.state);
}
handleDeleteAccountPasswordChange(i: User, event: any) {
handleDeleteAccountPasswordChange(i: BaseUser, event: any) {
i.state.deleteAccountForm.password = event.target.value;
i.setState(i.state);
}
handleLogoutClick(i: User) {
handleLogoutClick(i: BaseUser) {
UserService.Instance.logout();
i.context.router.history.push('/');
}
handleDeleteAccount(i: User, event: any) {
handleDeleteAccount(i: BaseUser, event: any) {
event.preventDefault();
i.state.deleteAccountLoading = true;
i.setState(i.state);
@ -1190,17 +1190,17 @@ class BaseUser extends Component<any, UserState> {
WebSocketService.Instance.deleteAccount(i.state.deleteAccountForm);
}
handleBanUserShow(i: User) {
handleBanUserShow(i: BaseUser) {
i.state.banUserShow = !i.state.banUserShow;
i.setState(i.state);
}
handleBanReasonChange(i: User, event: any) {
handleBanReasonChange(i: BaseUser, event: any) {
i.state.banReason = event.target.value;
i.setState(i.state);
}
handleBan(i: User, event: any) {
handleBan(i: BaseUser, event: any) {
event.preventDefault();
if (i.canAdmin) {
const form: BanUserForm = {

2
src/components/welcome.tsx

@ -31,6 +31,7 @@ export class WelcomePage extends Component<any, State> {
loginForm: {
username_or_email: undefined,
password: undefined,
captcha_id: undefined,
},
registerForm: {
username: undefined,
@ -38,6 +39,7 @@ export class WelcomePage extends Component<any, State> {
password_verify: undefined,
admin: false,
show_nsfw: false,
captcha_id: undefined,
},
loginLoading: false,
registerLoading: false,

Loading…
Cancel
Save