Fixing a few things, commenting out props for now.
This commit is contained in:
parent
f8dc8caa99
commit
5bd558000c
10 changed files with 61 additions and 137 deletions
13
package.json
13
package.json
|
@ -17,9 +17,16 @@
|
|||
"start": "yarn build:dev --watch"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx,js}": ["prettier --write", "eslint --fix"],
|
||||
"*.{css, scss}": ["prettier --write"],
|
||||
"package.json": ["sortpack"]
|
||||
"*.{ts,tsx,js}": [
|
||||
"prettier --write",
|
||||
"eslint --fix"
|
||||
],
|
||||
"*.{css, scss}": [
|
||||
"prettier --write"
|
||||
],
|
||||
"package.json": [
|
||||
"sortpack"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||
|
|
|
@ -53,7 +53,6 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
|||
expanded: false,
|
||||
showDropdown: false,
|
||||
};
|
||||
subscription: any;
|
||||
collapseButtonRef = createRef<HTMLButtonElement>();
|
||||
|
||||
constructor(props: any, context: any) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import autosize from "autosize";
|
||||
import { NoOptionI18nKeys } from "i18next";
|
||||
import { Component, linkEvent } from "inferno";
|
||||
import { Prompt } from "inferno-router";
|
||||
import { Language } from "lemmy-js-client";
|
||||
import { i18n } from "../../i18next";
|
||||
import { HttpService, UserService } from "../../services";
|
||||
|
@ -104,14 +103,6 @@ export class MarkdownTextArea extends Component<
|
|||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (!this.props.hideNavigationWarnings && this.state.content) {
|
||||
window.onbeforeunload = () => true;
|
||||
} else {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: MarkdownTextAreaProps) {
|
||||
if (nextProps.finished) {
|
||||
this.setState({
|
||||
|
@ -131,19 +122,16 @@ export class MarkdownTextArea extends Component<
|
|||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
|
||||
render() {
|
||||
const languageId = this.state.languageId;
|
||||
|
||||
// TODO add these prompts back in at some point
|
||||
// <Prompt
|
||||
// when={!this.props.hideNavigationWarnings && this.state.content}
|
||||
// message={i18n.t("block_leaving")}
|
||||
// />
|
||||
return (
|
||||
<form id={this.formId} onSubmit={linkEvent(this, this.handleSubmit)}>
|
||||
<Prompt
|
||||
when={!this.props.hideNavigationWarnings && this.state.content}
|
||||
message={i18n.t("block_leaving")}
|
||||
/>
|
||||
<div className="form-group row">
|
||||
<div className={`col-sm-12`}>
|
||||
<textarea
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
ListCommunitiesResponse,
|
||||
ListingType,
|
||||
} from "lemmy-js-client";
|
||||
import { Subscription } from "rxjs";
|
||||
import { i18n } from "../../i18next";
|
||||
import { InitialFetchRequest } from "../../interfaces";
|
||||
import { HttpService, RequestState } from "../../services/HttpService";
|
||||
|
@ -16,7 +15,6 @@ import {
|
|||
getPageFromString,
|
||||
getQueryParams,
|
||||
getQueryString,
|
||||
isBrowser,
|
||||
isInitialRoute,
|
||||
myAuth,
|
||||
myAuthRequired,
|
||||
|
@ -48,7 +46,6 @@ function getListingTypeFromQuery(listingType?: string): ListingType {
|
|||
}
|
||||
|
||||
export class Communities extends Component<any, CommunitiesState> {
|
||||
private subscription?: Subscription;
|
||||
private isoData = setIsoData(this.context);
|
||||
state: CommunitiesState = {
|
||||
listCommunitiesResponse: { state: "empty" },
|
||||
|
@ -76,12 +73,6 @@ export class Communities extends Component<any, CommunitiesState> {
|
|||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (isBrowser()) {
|
||||
this.subscription?.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
get documentTitle(): string {
|
||||
return `${i18n.t("communities")} - ${
|
||||
this.state.siteRes.site_view.site.name
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import { Component, linkEvent } from "inferno";
|
||||
import { Prompt } from "inferno-router";
|
||||
import {
|
||||
CommunityView,
|
||||
CreateCommunity,
|
||||
EditCommunity,
|
||||
Language,
|
||||
} from "lemmy-js-client";
|
||||
import { Subscription } from "rxjs";
|
||||
import { i18n } from "../../i18next";
|
||||
import { capitalizeFirstLetter, myAuthRequired, randomStr } from "../../utils";
|
||||
import { Icon, Spinner } from "../common/icon";
|
||||
|
@ -43,7 +41,6 @@ export class CommunityForm extends Component<
|
|||
CommunityFormState
|
||||
> {
|
||||
private id = `community-form-${randomStr()}`;
|
||||
private subscription?: Subscription;
|
||||
|
||||
state: CommunityFormState = {
|
||||
form: {},
|
||||
|
@ -84,36 +81,20 @@ export class CommunityForm extends Component<
|
|||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (
|
||||
!this.state.loading &&
|
||||
(this.state.form.name ||
|
||||
this.state.form.title ||
|
||||
this.state.form.description)
|
||||
) {
|
||||
window.onbeforeunload = () => true;
|
||||
} else {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.subscription?.unsubscribe();
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
// TODO
|
||||
// <Prompt
|
||||
// when={
|
||||
// !this.state.loading &&
|
||||
// (this.state.form.name ||
|
||||
// this.state.form.title ||
|
||||
// this.state.form.description)
|
||||
// }
|
||||
// message={i18n.t("block_leaving")}
|
||||
// />
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
<Prompt
|
||||
when={
|
||||
!this.state.loading &&
|
||||
(this.state.form.name ||
|
||||
this.state.form.title ||
|
||||
this.state.form.description)
|
||||
}
|
||||
message={i18n.t("block_leaving")}
|
||||
/>
|
||||
<form onSubmit={linkEvent(this, this.handleCreateCommunitySubmit)}>
|
||||
{!this.props.community_view && (
|
||||
<div className="form-group row">
|
||||
|
|
|
@ -58,7 +58,5 @@ export class CreateCommunity extends Component<any, CreateCommunityState> {
|
|||
const name = res.data.community_view.community.name;
|
||||
this.props.history.replace(`/c/${name}`);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
InfernoMouseEvent,
|
||||
linkEvent,
|
||||
} from "inferno";
|
||||
import { Prompt } from "inferno-router";
|
||||
import {
|
||||
CreateSite,
|
||||
EditSite,
|
||||
|
@ -115,40 +114,23 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
this.setState({ loading: false });
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (
|
||||
!this.state.loading &&
|
||||
!this.props.siteRes.site_view.local_site.site_setup &&
|
||||
(this.state.siteForm.name ||
|
||||
this.state.siteForm.sidebar ||
|
||||
this.state.siteForm.application_question ||
|
||||
this.state.siteForm.description)
|
||||
) {
|
||||
window.onbeforeunload = () => true;
|
||||
} else {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
// TODO
|
||||
// <Prompt
|
||||
// when={
|
||||
// !this.state.loading &&
|
||||
// !siteSetup &&
|
||||
// (this.state.siteForm.name ||
|
||||
// this.state.siteForm.sidebar ||
|
||||
// this.state.siteForm.application_question ||
|
||||
// this.state.siteForm.description)
|
||||
// }
|
||||
// message={i18n.t("block_leaving")}
|
||||
// />
|
||||
|
||||
render() {
|
||||
const siteSetup = this.props.siteRes.site_view.local_site.site_setup;
|
||||
return (
|
||||
<>
|
||||
<Prompt
|
||||
when={
|
||||
!this.state.loading &&
|
||||
!siteSetup &&
|
||||
(this.state.siteForm.name ||
|
||||
this.state.siteForm.sidebar ||
|
||||
this.state.siteForm.application_question ||
|
||||
this.state.siteForm.description)
|
||||
}
|
||||
message={i18n.t("block_leaving")}
|
||||
/>
|
||||
<form onSubmit={linkEvent(this, this.handleSaveSiteSubmit)}>
|
||||
<h5>{`${
|
||||
siteSetup
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import autosize from "autosize";
|
||||
import { Component, linkEvent } from "inferno";
|
||||
import { Prompt } from "inferno-router";
|
||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||
import {
|
||||
CreatePost,
|
||||
EditPost,
|
||||
|
@ -142,22 +141,19 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
}
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(
|
||||
{ selectedCommunityChoice, post_view }: PostFormProps,
|
||||
{ form, ...restState }: PostFormState
|
||||
) {
|
||||
return post_view
|
||||
? {
|
||||
...restState,
|
||||
form,
|
||||
}
|
||||
: {
|
||||
...restState,
|
||||
form: {
|
||||
...form,
|
||||
community_id: getIdFromString(selectedCommunityChoice?.value),
|
||||
},
|
||||
};
|
||||
componentWillReceiveProps(
|
||||
nextProps: Readonly<{ children?: InfernoNode } & PostFormProps>
|
||||
): void {
|
||||
if (this.props != nextProps) {
|
||||
this.setState(
|
||||
s => (
|
||||
(s.form.community_id = getIdFromString(
|
||||
nextProps.selectedCommunityChoice?.value
|
||||
)),
|
||||
s
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -166,18 +162,12 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
|
||||
const url = this.state.form.url;
|
||||
|
||||
// TODO
|
||||
// const promptCheck =
|
||||
// !!this.state.form.name || !!this.state.form.url || !!this.state.form.body;
|
||||
// <Prompt when={promptCheck} message={i18n.t("block_leaving")} />
|
||||
return (
|
||||
<div>
|
||||
<Prompt
|
||||
when={
|
||||
!(
|
||||
this.state.form.name ||
|
||||
this.state.form.url ||
|
||||
this.state.form.body
|
||||
)
|
||||
}
|
||||
message={i18n.t("block_leaving")}
|
||||
/>
|
||||
<form onSubmit={linkEvent(this, this.handlePostSubmit)}>
|
||||
<div className="form-group row">
|
||||
<label className="col-sm-2 col-form-label" htmlFor="post-url">
|
||||
|
@ -513,8 +503,6 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
auth,
|
||||
});
|
||||
}
|
||||
|
||||
i.setState({ loading: false });
|
||||
}
|
||||
|
||||
copySuggestedTitle(d: { i: PostForm; suggestedTitle?: string }) {
|
||||
|
@ -624,6 +612,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
if (res.data.msg === "ok") {
|
||||
i.state.form.url = res.data.url;
|
||||
pictrsDeleteToast(file.name, res.data.delete_url as string);
|
||||
i.setState({ imageLoading: false });
|
||||
} else {
|
||||
toast(JSON.stringify(res), "danger");
|
||||
}
|
||||
|
@ -631,8 +620,6 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
|||
console.error(res.msg);
|
||||
toast(res.msg, "danger");
|
||||
}
|
||||
|
||||
i.setState({ imageLoading: false });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,11 @@ import {
|
|||
GetPersonDetailsResponse,
|
||||
GetSiteResponse,
|
||||
} from "lemmy-js-client";
|
||||
import { Subscription } from "rxjs";
|
||||
import { i18n } from "../../i18next";
|
||||
import { InitialFetchRequest } from "../../interfaces";
|
||||
import { HttpService, RequestState } from "../../services/HttpService";
|
||||
import {
|
||||
getRecipientIdFromProps,
|
||||
isBrowser,
|
||||
isInitialRoute,
|
||||
myAuth,
|
||||
setIsoData,
|
||||
|
@ -32,7 +30,6 @@ export class CreatePrivateMessage extends Component<
|
|||
CreatePrivateMessageState
|
||||
> {
|
||||
private isoData = setIsoData(this.context);
|
||||
private subscription?: Subscription;
|
||||
state: CreatePrivateMessageState = {
|
||||
siteRes: this.isoData.site_res,
|
||||
recipientRes: { state: "empty" },
|
||||
|
@ -96,12 +93,6 @@ export class CreatePrivateMessage extends Component<
|
|||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (isBrowser()) {
|
||||
this.subscription?.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
renderRecipientRes() {
|
||||
switch (this.state.recipientRes.state) {
|
||||
case "loading":
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||
import { T } from "inferno-i18next-dess";
|
||||
import { Prompt } from "inferno-router";
|
||||
import {
|
||||
CreatePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
|
@ -63,14 +62,15 @@ export class PrivateMessageForm extends Component<
|
|||
this.setState({ loading: false, content: undefined, previewMode: false });
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
// <Prompt
|
||||
// when={!this.state.loading && this.state.content}
|
||||
// message={i18n.t("block_leaving")}
|
||||
// />
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Prompt
|
||||
when={!this.state.loading && this.state.content}
|
||||
message={i18n.t("block_leaving")}
|
||||
/>
|
||||
<form onSubmit={linkEvent(this, this.handlePrivateMessageSubmit)}>
|
||||
{!this.props.privateMessageView && (
|
||||
<div className="form-group row">
|
||||
|
|
Loading…
Reference in a new issue