-import { Component } from 'inferno';
-import { Subscription } from 'rxjs';
-import { PostForm } from './post-form';
-import { HtmlTags } from './html-tags';
-import { Spinner } from './icon';
+import { Component } from "inferno";
+import { Subscription } from "rxjs";
+import { PostForm } from "./post-form";
+import { HtmlTags } from "./html-tags";
+import { Spinner } from "./icon";
import {
authField,
isBrowser,
wsJsonToRes,
wsSubscribe,
wsUserOp,
-} from '../utils';
-import { UserService, WebSocketService } from '../services';
+} from "../utils";
+import { UserService, WebSocketService } from "../services";
import {
UserOperation,
ListCommunitiesResponse,
SortType,
ListingType,
PostView,
-} from 'lemmy-js-client';
-import { i18n } from '../i18next';
-import { InitialFetchRequest, PostFormParams } from 'shared/interfaces';
+} from "lemmy-js-client";
+import { i18n } from "../i18next";
+import { InitialFetchRequest, PostFormParams } from "shared/interfaces";
interface CreatePostState {
site_view: SiteView;
this.state = this.emptyState;
if (!UserService.Instance.user && isBrowser()) {
- toast(i18n.t('not_logged_in'), 'danger');
+ toast(i18n.t("not_logged_in"), "danger");
this.context.router.history.push(`/login`);
}
}
get documentTitle(): string {
- return `${i18n.t('create_post')} - ${this.state.site_view.site.name}`;
+ return `${i18n.t("create_post")} - ${this.state.site_view.site.name}`;
}
render() {
) : (
<div class="row">
<div class="col-12 col-lg-6 offset-lg-3 mb-4">
- <h5>{i18n.t('create_post')}</h5>
+ <h5>{i18n.t("create_post")}</h5>
<PostForm
communities={this.state.communities}
onCreate={this.handlePostCreate}
get params(): PostFormParams {
let urlParams = new URLSearchParams(this.props.location.search);
let params: PostFormParams = {
- name: urlParams.get('title'),
- community_name: urlParams.get('community_name') || this.prevCommunityName,
- community_id: urlParams.get('community_id')
- ? Number(urlParams.get('community_id')) || this.prevCommunityId
+ name: urlParams.get("title"),
+ community_name: urlParams.get("community_name") || this.prevCommunityName,
+ community_id: urlParams.get("community_id")
+ ? Number(urlParams.get("community_id")) || this.prevCommunityId
: null,
- body: urlParams.get('body'),
- url: urlParams.get('url'),
+ body: urlParams.get("body"),
+ url: urlParams.get("url"),
};
return params;
return this.props.match.params.name;
} else if (this.props.location.state) {
let lastLocation = this.props.location.state.prevPath;
- if (lastLocation.includes('/c/')) {
- return lastLocation.split('/c/')[1];
+ if (lastLocation.includes("/c/")) {
+ return lastLocation.split("/c/")[1];
}
}
return null;
return this.props.match.params.id;
} else if (this.props.location.state) {
let lastLocation = this.props.location.state.prevPath;
- if (lastLocation.includes('/community/')) {
- return Number(lastLocation.split('/community/')[1]);
+ if (lastLocation.includes("/community/")) {
+ return Number(lastLocation.split("/community/")[1]);
}
}
return null;
parseMessage(msg: any) {
let op = wsUserOp(msg);
if (msg.error) {
- toast(i18n.t(msg.error), 'danger');
+ toast(i18n.t(msg.error), "danger");
return;
} else if (op == UserOperation.ListCommunities) {
let data = wsJsonToRes<ListCommunitiesResponse>(msg).data;