mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 22:01:13 +00:00
Merge branch 'main' into remote-follow
This commit is contained in:
commit
3ba232ea42
49 changed files with 105 additions and 338 deletions
|
@ -68,7 +68,7 @@
|
||||||
"inferno-router": "^8.2.2",
|
"inferno-router": "^8.2.2",
|
||||||
"inferno-server": "^8.2.2",
|
"inferno-server": "^8.2.2",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"lemmy-js-client": "^0.19.0-rc.7",
|
"lemmy-js-client": "^0.19.0-rc.12",
|
||||||
"lodash.isequal": "^4.5.0",
|
"lodash.isequal": "^4.5.0",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"markdown-it-container": "^3.0.0",
|
"markdown-it-container": "^3.0.0",
|
||||||
|
|
|
@ -6,7 +6,7 @@ import fetch from "cross-fetch";
|
||||||
import type { Request, Response } from "express";
|
import type { Request, Response } from "express";
|
||||||
import { StaticRouter, matchPath } from "inferno-router";
|
import { StaticRouter, matchPath } from "inferno-router";
|
||||||
import { renderToString } from "inferno-server";
|
import { renderToString } from "inferno-server";
|
||||||
import { GetSite, GetSiteResponse, LemmyHttp } from "lemmy-js-client";
|
import { GetSiteResponse, LemmyHttp } from "lemmy-js-client";
|
||||||
import { App } from "../../shared/components/app/app";
|
import { App } from "../../shared/components/app/app";
|
||||||
import {
|
import {
|
||||||
InitialFetchRequest,
|
InitialFetchRequest,
|
||||||
|
@ -26,18 +26,19 @@ export default async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const activeRoute = routes.find(route => matchPath(req.path, route));
|
const activeRoute = routes.find(route => matchPath(req.path, route));
|
||||||
|
|
||||||
let auth = req.headers.cookie
|
|
||||||
? cookie.parse(req.headers.cookie).jwt
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const getSiteForm: GetSite = { auth };
|
|
||||||
|
|
||||||
const headers = setForwardedHeaders(req.headers);
|
const headers = setForwardedHeaders(req.headers);
|
||||||
|
|
||||||
const client = wrapClient(
|
const client = wrapClient(
|
||||||
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
|
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const auth = req.headers.cookie
|
||||||
|
? cookie.parse(req.headers.cookie).jwt
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (auth) {
|
||||||
|
client.setHeaders({ Authorization: `Bearer ${auth}` });
|
||||||
|
}
|
||||||
const { path, url, query } = req;
|
const { path, url, query } = req;
|
||||||
|
|
||||||
// Get site data first
|
// Get site data first
|
||||||
|
@ -46,15 +47,14 @@ export default async (req: Request, res: Response) => {
|
||||||
let site: GetSiteResponse | undefined = undefined;
|
let site: GetSiteResponse | undefined = undefined;
|
||||||
let routeData: RouteData = {};
|
let routeData: RouteData = {};
|
||||||
let errorPageData: ErrorPageData | undefined = undefined;
|
let errorPageData: ErrorPageData | undefined = undefined;
|
||||||
let try_site = await client.getSite(getSiteForm);
|
let try_site = await client.getSite();
|
||||||
|
|
||||||
if (try_site.state === "failed" && try_site.msg === "not_logged_in") {
|
if (try_site.state === "failed" && try_site.msg === "not_logged_in") {
|
||||||
console.error(
|
console.error(
|
||||||
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie",
|
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie",
|
||||||
);
|
);
|
||||||
getSiteForm.auth = undefined;
|
client.setHeaders({});
|
||||||
auth = undefined;
|
try_site = await client.getSite();
|
||||||
try_site = await client.getSite(getSiteForm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!auth && isAuthPath(path)) {
|
if (!auth && isAuthPath(path)) {
|
||||||
|
@ -72,7 +72,6 @@ export default async (req: Request, res: Response) => {
|
||||||
if (site && activeRoute?.fetchInitialData) {
|
if (site && activeRoute?.fetchInitialData) {
|
||||||
const initialFetchReq: InitialFetchRequest = {
|
const initialFetchReq: InitialFetchRequest = {
|
||||||
client,
|
client,
|
||||||
auth,
|
|
||||||
path,
|
path,
|
||||||
query,
|
query,
|
||||||
site,
|
site,
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default async (req: Request, res: Response) => {
|
||||||
const client = wrapClient(
|
const client = wrapClient(
|
||||||
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
|
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
|
||||||
);
|
);
|
||||||
const site = await client.getSite({});
|
const site = await client.getSite();
|
||||||
|
|
||||||
if (site.state === "success") {
|
if (site.state === "success") {
|
||||||
manifest = await generateManifestJson(site.data);
|
manifest = await generateManifestJson(site.data);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { removeAuthParam } from "@utils/helpers";
|
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
import { Link } from "inferno-router";
|
import { Link } from "inferno-router";
|
||||||
|
@ -56,11 +55,7 @@ export class ErrorPage extends Component<any, any> {
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{errorPageData?.error && (
|
{errorPageData?.error && (
|
||||||
<T
|
<T i18nKey="error_code_message" parent="p">
|
||||||
i18nKey="error_code_message"
|
|
||||||
parent="p"
|
|
||||||
interpolation={{ error: removeAuthParam(errorPageData.error) }}
|
|
||||||
>
|
|
||||||
#<strong className="text-danger">#</strong>#
|
#<strong className="text-danger">#</strong>#
|
||||||
</T>
|
</T>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -450,28 +450,21 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
fetchUnreads() {
|
fetchUnreads() {
|
||||||
poll(async () => {
|
poll(async () => {
|
||||||
if (window.document.visibilityState !== "hidden") {
|
if (window.document.visibilityState !== "hidden") {
|
||||||
const auth = myAuth();
|
if (myAuth()) {
|
||||||
if (auth) {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
unreadInboxCountRes: await HttpService.client.getUnreadCount({
|
unreadInboxCountRes: await HttpService.client.getUnreadCount(),
|
||||||
auth,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.moderatesSomething) {
|
if (this.moderatesSomething) {
|
||||||
this.setState({
|
this.setState({
|
||||||
unreadReportCountRes: await HttpService.client.getReportCount({
|
unreadReportCountRes: await HttpService.client.getReportCount({}),
|
||||||
auth,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amAdmin()) {
|
if (amAdmin()) {
|
||||||
this.setState({
|
this.setState({
|
||||||
unreadApplicationCountRes:
|
unreadApplicationCountRes:
|
||||||
await HttpService.client.getUnreadRegistrationApplicationCount({
|
await HttpService.client.getUnreadRegistrationApplicationCount(),
|
||||||
auth,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
|
@ -92,7 +91,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
||||||
content,
|
content,
|
||||||
post_id,
|
post_id,
|
||||||
language_id,
|
language_id,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (edit) {
|
if (edit) {
|
||||||
|
@ -101,7 +99,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
||||||
content,
|
content,
|
||||||
comment_id,
|
comment_id,
|
||||||
language_id,
|
language_id,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const post_id = node.comment_view.post.id;
|
const post_id = node.comment_view.post.id;
|
||||||
|
@ -111,7 +108,6 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
||||||
parent_id,
|
parent_id,
|
||||||
post_id,
|
post_id,
|
||||||
language_id,
|
language_id,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { colorList, getCommentParentId, showScores } from "@utils/app";
|
||||||
colorList,
|
|
||||||
getCommentParentId,
|
|
||||||
myAuth,
|
|
||||||
myAuthRequired,
|
|
||||||
showScores,
|
|
||||||
} from "@utils/app";
|
|
||||||
import { futureDaysToUnixTime, numToSI } from "@utils/helpers";
|
import { futureDaysToUnixTime, numToSI } from "@utils/helpers";
|
||||||
import {
|
import {
|
||||||
amCommunityCreator,
|
amCommunityCreator,
|
||||||
|
@ -1380,7 +1374,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onSaveComment({
|
i.props.onSaveComment({
|
||||||
comment_id: i.commentView.comment.id,
|
comment_id: i.commentView.comment.id,
|
||||||
save: !i.commentView.saved,
|
save: !i.commentView.saved,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1389,7 +1382,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onBlockPerson({
|
i.props.onBlockPerson({
|
||||||
person_id: i.commentView.creator.id,
|
person_id: i.commentView.creator.id,
|
||||||
block: true,
|
block: true,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1400,13 +1392,11 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onPersonMentionRead({
|
i.props.onPersonMentionRead({
|
||||||
person_mention_id: cv.person_mention.id,
|
person_mention_id: cv.person_mention.id,
|
||||||
read: !cv.person_mention.read,
|
read: !cv.person_mention.read,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else if (i.isCommentReplyType(cv)) {
|
} else if (i.isCommentReplyType(cv)) {
|
||||||
i.props.onCommentReplyRead({
|
i.props.onCommentReplyRead({
|
||||||
comment_reply_id: cv.comment_reply.id,
|
comment_reply_id: cv.comment_reply.id,
|
||||||
read: !cv.comment_reply.read,
|
read: !cv.comment_reply.read,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1416,7 +1406,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onDeleteComment({
|
i.props.onDeleteComment({
|
||||||
comment_id: i.commentId,
|
comment_id: i.commentId,
|
||||||
deleted: !i.commentView.comment.deleted,
|
deleted: !i.commentView.comment.deleted,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1426,7 +1415,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onRemoveComment({
|
i.props.onRemoveComment({
|
||||||
comment_id: i.commentId,
|
comment_id: i.commentId,
|
||||||
removed: !i.commentView.comment.removed,
|
removed: !i.commentView.comment.removed,
|
||||||
auth: myAuthRequired(),
|
|
||||||
reason: i.state.removeReason,
|
reason: i.state.removeReason,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1436,7 +1424,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onDistinguishComment({
|
i.props.onDistinguishComment({
|
||||||
comment_id: i.commentId,
|
comment_id: i.commentId,
|
||||||
distinguished: !i.commentView.comment.distinguished,
|
distinguished: !i.commentView.comment.distinguished,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1449,7 +1436,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
reason: i.state.banReason,
|
reason: i.state.banReason,
|
||||||
remove_data: i.state.removeData,
|
remove_data: i.state.removeData,
|
||||||
expires: futureDaysToUnixTime(i.state.banExpireDays),
|
expires: futureDaysToUnixTime(i.state.banExpireDays),
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1461,7 +1447,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
reason: i.state.banReason,
|
reason: i.state.banReason,
|
||||||
remove_data: i.state.removeData,
|
remove_data: i.state.removeData,
|
||||||
expires: futureDaysToUnixTime(i.state.banExpireDays),
|
expires: futureDaysToUnixTime(i.state.banExpireDays),
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1482,7 +1467,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
community_id: i.commentView.community.id,
|
community_id: i.commentView.community.id,
|
||||||
person_id: i.commentView.creator.id,
|
person_id: i.commentView.creator.id,
|
||||||
added,
|
added,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1493,7 +1477,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onAddAdmin({
|
i.props.onAddAdmin({
|
||||||
person_id: i.commentView.creator.id,
|
person_id: i.commentView.creator.id,
|
||||||
added,
|
added,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1502,7 +1485,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onTransferCommunity({
|
i.props.onTransferCommunity({
|
||||||
community_id: i.commentView.community.id,
|
community_id: i.commentView.community.id,
|
||||||
person_id: i.commentView.creator.id,
|
person_id: i.commentView.creator.id,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1510,7 +1492,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
this.props.onCommentReport({
|
this.props.onCommentReport({
|
||||||
comment_id: this.commentId,
|
comment_id: this.commentId,
|
||||||
reason,
|
reason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1526,13 +1507,11 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
i.props.onPurgePerson({
|
i.props.onPurgePerson({
|
||||||
person_id: i.commentView.creator.id,
|
person_id: i.commentView.creator.id,
|
||||||
reason: i.state.purgeReason,
|
reason: i.state.purgeReason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
i.props.onPurgeComment({
|
i.props.onPurgeComment({
|
||||||
comment_id: i.commentId,
|
comment_id: i.commentId,
|
||||||
reason: i.state.purgeReason,
|
reason: i.state.purgeReason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1545,7 +1524,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
limit: 999, // TODO
|
limit: 999, // TODO
|
||||||
type_: "All",
|
type_: "All",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth: myAuth(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
import {
|
import {
|
||||||
|
@ -149,7 +148,6 @@ export class CommentReport extends Component<
|
||||||
i.props.onResolveReport({
|
i.props.onResolveReport({
|
||||||
report_id: i.props.report.comment_report.id,
|
report_id: i.props.report.comment_report.id,
|
||||||
resolved: !i.props.report.comment_report.resolved,
|
resolved: !i.props.report.comment_report.resolved,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
import {
|
import {
|
||||||
|
@ -149,7 +148,6 @@ export class RegistrationApplication extends Component<
|
||||||
i.props.onApproveApplication({
|
i.props.onApproveApplication({
|
||||||
id: i.props.application.registration_application.id,
|
id: i.props.application.registration_application.id,
|
||||||
approve: true,
|
approve: true,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +158,6 @@ export class RegistrationApplication extends Component<
|
||||||
id: i.props.application.registration_application.id,
|
id: i.props.application.registration_application.id,
|
||||||
approve: false,
|
approve: false,
|
||||||
deny_reason: i.state.denyReason,
|
deny_reason: i.state.denyReason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
i.setState({ denyExpanded: true });
|
i.setState({ denyExpanded: true });
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { myAuthRequired, newVote, showScores } from "@utils/app";
|
import { newVote, showScores } from "@utils/app";
|
||||||
import { numToSI } from "@utils/helpers";
|
import { numToSI } from "@utils/helpers";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
|
@ -53,7 +53,6 @@ const handleUpvote = (i: VoteButtons) => {
|
||||||
i.props.onVote({
|
i.props.onVote({
|
||||||
comment_id: i.props.id,
|
comment_id: i.props.id,
|
||||||
score: newVote(VoteType.Upvote, i.props.my_vote),
|
score: newVote(VoteType.Upvote, i.props.my_vote),
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case VoteContentType.Post:
|
case VoteContentType.Post:
|
||||||
|
@ -61,7 +60,6 @@ const handleUpvote = (i: VoteButtons) => {
|
||||||
i.props.onVote({
|
i.props.onVote({
|
||||||
post_id: i.props.id,
|
post_id: i.props.id,
|
||||||
score: newVote(VoteType.Upvote, i.props.my_vote),
|
score: newVote(VoteType.Upvote, i.props.my_vote),
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -73,7 +71,6 @@ const handleDownvote = (i: VoteButtons) => {
|
||||||
i.props.onVote({
|
i.props.onVote({
|
||||||
comment_id: i.props.id,
|
comment_id: i.props.id,
|
||||||
score: newVote(VoteType.Downvote, i.props.my_vote),
|
score: newVote(VoteType.Downvote, i.props.my_vote),
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case VoteContentType.Post:
|
case VoteContentType.Post:
|
||||||
|
@ -81,7 +78,6 @@ const handleDownvote = (i: VoteButtons) => {
|
||||||
i.props.onVote({
|
i.props.onVote({
|
||||||
post_id: i.props.id,
|
post_id: i.props.id,
|
||||||
score: newVote(VoteType.Downvote, i.props.my_vote),
|
score: newVote(VoteType.Downvote, i.props.my_vote),
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { editCommunity, setIsoData, showLocal } from "@utils/app";
|
||||||
editCommunity,
|
|
||||||
myAuth,
|
|
||||||
myAuthRequired,
|
|
||||||
setIsoData,
|
|
||||||
showLocal,
|
|
||||||
} from "@utils/app";
|
|
||||||
import {
|
import {
|
||||||
getPageFromString,
|
getPageFromString,
|
||||||
getQueryParams,
|
getQueryParams,
|
||||||
|
@ -308,7 +302,6 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
query: { listingType, sort, page },
|
query: { listingType, sort, page },
|
||||||
client,
|
client,
|
||||||
auth,
|
|
||||||
}: InitialFetchRequest<
|
}: InitialFetchRequest<
|
||||||
QueryParams<CommunitiesProps>
|
QueryParams<CommunitiesProps>
|
||||||
>): Promise<CommunitiesData> {
|
>): Promise<CommunitiesData> {
|
||||||
|
@ -317,7 +310,6 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
sort: getSortTypeFromQuery(sort),
|
sort: getSortTypeFromQuery(sort),
|
||||||
limit: communityLimit,
|
limit: communityLimit,
|
||||||
page: getPageFromString(page),
|
page: getPageFromString(page),
|
||||||
auth: auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -335,7 +327,6 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
const res = await HttpService.client.followCommunity({
|
const res = await HttpService.client.followCommunity({
|
||||||
community_id: data.communityId,
|
community_id: data.communityId,
|
||||||
follow: data.follow,
|
follow: data.follow,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
data.i.findAndUpdateCommunity(res);
|
data.i.findAndUpdateCommunity(res);
|
||||||
}
|
}
|
||||||
|
@ -351,7 +342,6 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
sort: sort,
|
sort: sort,
|
||||||
limit: communityLimit,
|
limit: communityLimit,
|
||||||
page,
|
page,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { capitalizeFirstLetter, randomStr } from "@utils/helpers";
|
import { capitalizeFirstLetter, randomStr } from "@utils/helpers";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import { Prompt } from "inferno-router";
|
import { Prompt } from "inferno-router";
|
||||||
|
@ -279,7 +278,6 @@ export class CommunityForm extends Component<
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
i.setState({ submitted: true });
|
i.setState({ submitted: true });
|
||||||
const cForm = i.state.form;
|
const cForm = i.state.form;
|
||||||
const auth = myAuthRequired();
|
|
||||||
|
|
||||||
const cv = i.props.community_view;
|
const cv = i.props.community_view;
|
||||||
|
|
||||||
|
@ -293,7 +291,6 @@ export class CommunityForm extends Component<
|
||||||
nsfw: cForm.nsfw,
|
nsfw: cForm.nsfw,
|
||||||
posting_restricted_to_mods: cForm.posting_restricted_to_mods,
|
posting_restricted_to_mods: cForm.posting_restricted_to_mods,
|
||||||
discussion_languages: cForm.discussion_languages,
|
discussion_languages: cForm.discussion_languages,
|
||||||
auth,
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (cForm.title && cForm.name) {
|
if (cForm.title && cForm.name) {
|
||||||
|
@ -306,7 +303,6 @@ export class CommunityForm extends Component<
|
||||||
nsfw: cForm.nsfw,
|
nsfw: cForm.nsfw,
|
||||||
posting_restricted_to_mods: cForm.posting_restricted_to_mods,
|
posting_restricted_to_mods: cForm.posting_restricted_to_mods,
|
||||||
discussion_languages: cForm.discussion_languages,
|
discussion_languages: cForm.discussion_languages,
|
||||||
auth,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
enableNsfw,
|
enableNsfw,
|
||||||
getCommentParentId,
|
getCommentParentId,
|
||||||
getDataTypeString,
|
getDataTypeString,
|
||||||
myAuth,
|
|
||||||
postToCommentSortType,
|
postToCommentSortType,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
showLocal,
|
showLocal,
|
||||||
|
@ -217,7 +216,6 @@ export class Community extends Component<
|
||||||
this.setState({
|
this.setState({
|
||||||
communityRes: await HttpService.client.getCommunity({
|
communityRes: await HttpService.client.getCommunity({
|
||||||
name: this.props.match.params.name,
|
name: this.props.match.params.name,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -234,7 +232,6 @@ export class Community extends Component<
|
||||||
client,
|
client,
|
||||||
path,
|
path,
|
||||||
query: { dataType: urlDataType, page: urlPage, sort: urlSort },
|
query: { dataType: urlDataType, page: urlPage, sort: urlSort },
|
||||||
auth,
|
|
||||||
}: InitialFetchRequest<QueryParams<CommunityProps>>): Promise<
|
}: InitialFetchRequest<QueryParams<CommunityProps>>): Promise<
|
||||||
Promise<CommunityData>
|
Promise<CommunityData>
|
||||||
> {
|
> {
|
||||||
|
@ -243,7 +240,6 @@ export class Community extends Component<
|
||||||
const communityName = pathSplit[2];
|
const communityName = pathSplit[2];
|
||||||
const communityForm: GetCommunity = {
|
const communityForm: GetCommunity = {
|
||||||
name: communityName,
|
name: communityName,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataType = getDataTypeFromQuery(urlDataType);
|
const dataType = getDataTypeFromQuery(urlDataType);
|
||||||
|
@ -265,7 +261,6 @@ export class Community extends Component<
|
||||||
sort,
|
sort,
|
||||||
type_: "All",
|
type_: "All",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
postsResponse = await client.getPosts(getPostsForm);
|
postsResponse = await client.getPosts(getPostsForm);
|
||||||
|
@ -277,7 +272,6 @@ export class Community extends Component<
|
||||||
sort: postToCommentSortType(sort),
|
sort: postToCommentSortType(sort),
|
||||||
type_: "All",
|
type_: "All",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
commentsResponse = await client.getComments(getCommentsForm);
|
commentsResponse = await client.getComments(getCommentsForm);
|
||||||
|
@ -600,7 +594,6 @@ export class Community extends Component<
|
||||||
type_: "All",
|
type_: "All",
|
||||||
community_name: name,
|
community_name: name,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -613,7 +606,6 @@ export class Community extends Component<
|
||||||
type_: "All",
|
type_: "All",
|
||||||
community_name: name,
|
community_name: name,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { getUnixTime, hostname } from "@utils/helpers";
|
import { getUnixTime, hostname } from "@utils/helpers";
|
||||||
import { amAdmin, amMod, amTopMod } from "@utils/roles";
|
import { amAdmin, amMod, amTopMod } from "@utils/roles";
|
||||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||||
|
@ -500,7 +499,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
i.props.onFollowCommunity({
|
i.props.onFollowCommunity({
|
||||||
community_id: i.props.community_view.community.id,
|
community_id: i.props.community_view.community.id,
|
||||||
follow: false,
|
follow: false,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,7 +507,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
i.props.onFollowCommunity({
|
i.props.onFollowCommunity({
|
||||||
community_id: i.props.community_view.community.id,
|
community_id: i.props.community_view.community.id,
|
||||||
follow: true,
|
follow: true,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +516,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
i.props.onBlockCommunity({
|
i.props.onBlockCommunity({
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
block: !blocked,
|
block: !blocked,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +527,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
community_id: i.props.community_view.community.id,
|
community_id: i.props.community_view.community.id,
|
||||||
person_id: myId,
|
person_id: myId,
|
||||||
added: false,
|
added: false,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,7 +536,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
i.props.onDeleteCommunity({
|
i.props.onDeleteCommunity({
|
||||||
community_id: i.props.community_view.community.id,
|
community_id: i.props.community_view.community.id,
|
||||||
deleted: !i.props.community_view.community.deleted,
|
deleted: !i.props.community_view.community.deleted,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +547,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
removed: !i.props.community_view.community.removed,
|
removed: !i.props.community_view.community.removed,
|
||||||
reason: i.state.removeReason,
|
reason: i.state.removeReason,
|
||||||
expires: getUnixTime(i.state.removeExpires), // TODO fix this
|
expires: getUnixTime(i.state.removeExpires), // TODO fix this
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,7 +556,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
i.props.onPurgeCommunity({
|
i.props.onPurgeCommunity({
|
||||||
community_id: i.props.community_view.community.id,
|
community_id: i.props.community_view.community.id,
|
||||||
reason: i.state.purgeReason,
|
reason: i.state.purgeReason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
import {
|
import { fetchThemeList, setIsoData, showLocal } from "@utils/app";
|
||||||
fetchThemeList,
|
|
||||||
myAuthRequired,
|
|
||||||
setIsoData,
|
|
||||||
showLocal,
|
|
||||||
} from "@utils/app";
|
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
@ -85,16 +80,11 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
auth,
|
|
||||||
client,
|
client,
|
||||||
}: InitialFetchRequest): Promise<AdminSettingsData> {
|
}: InitialFetchRequest): Promise<AdminSettingsData> {
|
||||||
return {
|
return {
|
||||||
bannedRes: await client.getBannedPersons({
|
bannedRes: await client.getBannedPersons(),
|
||||||
auth: auth as string,
|
instancesRes: await client.getFederatedInstances(),
|
||||||
}),
|
|
||||||
instancesRes: await client.getFederatedInstances({
|
|
||||||
auth: auth as string,
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,11 +236,9 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
|
||||||
themeList: [],
|
themeList: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const auth = myAuthRequired();
|
|
||||||
|
|
||||||
const [bannedRes, instancesRes, themeList] = await Promise.all([
|
const [bannedRes, instancesRes, themeList] = await Promise.all([
|
||||||
HttpService.client.getBannedPersons({ auth }),
|
HttpService.client.getBannedPersons(),
|
||||||
HttpService.client.getFederatedInstances({ auth }),
|
HttpService.client.getFederatedInstances(),
|
||||||
fetchThemeList(),
|
fetchThemeList(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -347,9 +335,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
|
||||||
async handleLeaveAdminTeam(i: AdminSettings) {
|
async handleLeaveAdminTeam(i: AdminSettings) {
|
||||||
i.setState({ leaveAdminTeamRes: { state: "loading" } });
|
i.setState({ leaveAdminTeamRes: { state: "loading" } });
|
||||||
this.setState({
|
this.setState({
|
||||||
leaveAdminTeamRes: await HttpService.client.leaveAdmin({
|
leaveAdminTeamRes: await HttpService.client.leaveAdmin(),
|
||||||
auth: myAuthRequired(),
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.state.leaveAdminTeamRes.state === "success") {
|
if (this.state.leaveAdminTeamRes.state === "success") {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { myAuthRequired, setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import {
|
import {
|
||||||
|
@ -418,7 +418,6 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
if (d.cv.id !== 0) {
|
if (d.cv.id !== 0) {
|
||||||
d.i.props.onDelete({
|
d.i.props.onDelete({
|
||||||
id: d.cv.id,
|
id: d.cv.id,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const custom_emojis = [...d.i.state.customEmojis];
|
const custom_emojis = [...d.i.state.customEmojis];
|
||||||
|
@ -439,7 +438,6 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
image_url: d.cv.image_url,
|
image_url: d.cv.image_url,
|
||||||
alt_text: d.cv.alt_text,
|
alt_text: d.cv.alt_text,
|
||||||
keywords: uniqueKeywords,
|
keywords: uniqueKeywords,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
d.i.props.onCreate({
|
d.i.props.onCreate({
|
||||||
|
@ -448,7 +446,6 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
image_url: d.cv.image_url,
|
image_url: d.cv.image_url,
|
||||||
alt_text: d.cv.alt_text,
|
alt_text: d.cv.alt_text,
|
||||||
keywords: uniqueKeywords,
|
keywords: uniqueKeywords,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,6 @@ type HomeData = RouteDataResponse<{
|
||||||
|
|
||||||
function getRss(listingType: ListingType) {
|
function getRss(listingType: ListingType) {
|
||||||
const { sort } = getHomeQueryParams();
|
const { sort } = getHomeQueryParams();
|
||||||
const auth = myAuth();
|
|
||||||
|
|
||||||
let rss: string | undefined = undefined;
|
let rss: string | undefined = undefined;
|
||||||
|
|
||||||
|
@ -143,6 +142,7 @@ function getRss(listingType: ListingType) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "Subscribed": {
|
case "Subscribed": {
|
||||||
|
const auth = myAuth();
|
||||||
rss = auth ? `/feeds/front/${auth}.xml?sort=${sort}` : undefined;
|
rss = auth ? `/feeds/front/${auth}.xml?sort=${sort}` : undefined;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,6 @@ export class Home extends Component<any, HomeState> {
|
||||||
|
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
client,
|
client,
|
||||||
auth,
|
|
||||||
query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
|
query: { dataType: urlDataType, listingType, page: urlPage, sort: urlSort },
|
||||||
site,
|
site,
|
||||||
}: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
|
}: InitialFetchRequest<QueryParams<HomeProps>>): Promise<HomeData> {
|
||||||
|
@ -334,7 +333,6 @@ export class Home extends Component<any, HomeState> {
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
sort,
|
sort,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
postsRes = await client.getPosts(getPostsForm);
|
postsRes = await client.getPosts(getPostsForm);
|
||||||
|
@ -345,7 +343,6 @@ export class Home extends Component<any, HomeState> {
|
||||||
sort: postToCommentSortType(sort),
|
sort: postToCommentSortType(sort),
|
||||||
type_,
|
type_,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
commentsRes = await client.getComments(getCommentsForm);
|
commentsRes = await client.getComments(getCommentsForm);
|
||||||
|
@ -355,7 +352,6 @@ export class Home extends Component<any, HomeState> {
|
||||||
type_: "Local",
|
type_: "Local",
|
||||||
sort: "Hot",
|
sort: "Hot",
|
||||||
limit: trendingFetchLimit,
|
limit: trendingFetchLimit,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -800,13 +796,11 @@ export class Home extends Component<any, HomeState> {
|
||||||
type_: "Local",
|
type_: "Local",
|
||||||
sort: "Hot",
|
sort: "Hot",
|
||||||
limit: trendingFetchLimit,
|
limit: trendingFetchLimit,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchData() {
|
async fetchData() {
|
||||||
const auth = myAuth();
|
|
||||||
const { dataType, page, listingType, sort } = getHomeQueryParams();
|
const { dataType, page, listingType, sort } = getHomeQueryParams();
|
||||||
|
|
||||||
if (dataType === DataType.Post) {
|
if (dataType === DataType.Post) {
|
||||||
|
@ -828,7 +822,6 @@ export class Home extends Component<any, HomeState> {
|
||||||
sort,
|
sort,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
type_: listingType,
|
type_: listingType,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -843,7 +836,6 @@ export class Home extends Component<any, HomeState> {
|
||||||
sort: postToCommentSortType(sort),
|
sort: postToCommentSortType(sort),
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
type_: listingType,
|
type_: listingType,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ export class Instances extends Component<any, InstancesState> {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
instancesRes: await HttpService.client.getFederatedInstances({}),
|
instancesRes: await HttpService.client.getFederatedInstances(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ export class Instances extends Component<any, InstancesState> {
|
||||||
client,
|
client,
|
||||||
}: InitialFetchRequest): Promise<InstancesData> {
|
}: InitialFetchRequest): Promise<InstancesData> {
|
||||||
return {
|
return {
|
||||||
federatedInstancesResponse: await client.getFederatedInstances({}),
|
federatedInstancesResponse: await client.getFederatedInstances(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { myAuth, setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
import { isBrowser } from "@utils/browser";
|
||||||
import { getQueryParams } from "@utils/helpers";
|
import { getQueryParams } from "@utils/helpers";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
|
@ -62,9 +62,7 @@ async function handleLoginSubmit(i: Login, event: any) {
|
||||||
UserService.Instance.login({
|
UserService.Instance.login({
|
||||||
res: loginRes.data,
|
res: loginRes.data,
|
||||||
});
|
});
|
||||||
const site = await HttpService.client.getSite({
|
const site = await HttpService.client.getSite();
|
||||||
auth: myAuth(),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (site.state === "success") {
|
if (site.state === "success") {
|
||||||
UserService.Instance.myUserInfo = site.data.my_user;
|
UserService.Instance.myUserInfo = site.data.my_user;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Component, FormEventHandler, linkEvent } from "inferno";
|
import { Component, FormEventHandler, linkEvent } from "inferno";
|
||||||
|
@ -114,15 +113,12 @@ function handlePerSecondChange(
|
||||||
|
|
||||||
function submitRateLimitForm(i: RateLimitsForm, event: any) {
|
function submitRateLimitForm(i: RateLimitsForm, event: any) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const auth = myAuthRequired();
|
|
||||||
const form: EditSite = Object.entries(i.state.form).reduce(
|
const form: EditSite = Object.entries(i.state.form).reduce(
|
||||||
(acc, [key, val]) => {
|
(acc, [key, val]) => {
|
||||||
acc[`rate_limit_${key}`] = val;
|
acc[`rate_limit_${key}`] = val;
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{
|
{},
|
||||||
auth,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
i.props.onSaveSite(form);
|
i.props.onSaveSite(form);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { myAuth, setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
import { isBrowser } from "@utils/browser";
|
||||||
import { validEmail } from "@utils/helpers";
|
import { validEmail } from "@utils/helpers";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
|
@ -67,7 +67,7 @@ export class Signup extends Component<any, State> {
|
||||||
async fetchCaptcha() {
|
async fetchCaptcha() {
|
||||||
this.setState({ captchaRes: { state: "loading" } });
|
this.setState({ captchaRes: { state: "loading" } });
|
||||||
this.setState({
|
this.setState({
|
||||||
captchaRes: await HttpService.client.getCaptcha({}),
|
captchaRes: await HttpService.client.getCaptcha(),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState(s => {
|
this.setState(s => {
|
||||||
|
@ -397,7 +397,7 @@ export class Signup extends Component<any, State> {
|
||||||
res: data,
|
res: data,
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = await HttpService.client.getSite({ auth: myAuth() });
|
const site = await HttpService.client.getSite();
|
||||||
|
|
||||||
if (site.state === "success") {
|
if (site.state === "success") {
|
||||||
UserService.Instance.myUserInfo = site.data.my_user;
|
UserService.Instance.myUserInfo = site.data.my_user;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { capitalizeFirstLetter, validInstanceTLD } from "@utils/helpers";
|
import { capitalizeFirstLetter, validInstanceTLD } from "@utils/helpers";
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
|
@ -85,7 +84,6 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
captcha_difficulty: ls.captcha_difficulty,
|
captcha_difficulty: ls.captcha_difficulty,
|
||||||
allowed_instances: this.props.allowedInstances?.map(i => i.domain),
|
allowed_instances: this.props.allowedInstances?.map(i => i.domain),
|
||||||
blocked_instances: this.props.blockedInstances?.map(i => i.domain),
|
blocked_instances: this.props.blockedInstances?.map(i => i.domain),
|
||||||
auth: "TODO",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,8 +731,6 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
|
|
||||||
handleSaveSiteSubmit(i: SiteForm, event: any) {
|
handleSaveSiteSubmit(i: SiteForm, event: any) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const auth = myAuthRequired();
|
|
||||||
i.setState(s => ((s.siteForm.auth = auth), s));
|
|
||||||
i.setState({ submitted: true });
|
i.setState({ submitted: true });
|
||||||
|
|
||||||
const stateSiteForm = i.state.siteForm;
|
const stateSiteForm = i.state.siteForm;
|
||||||
|
@ -788,7 +784,6 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
allowed_instances: stateSiteForm.allowed_instances,
|
allowed_instances: stateSiteForm.allowed_instances,
|
||||||
blocked_instances: stateSiteForm.blocked_instances,
|
blocked_instances: stateSiteForm.blocked_instances,
|
||||||
discussion_languages: stateSiteForm.discussion_languages,
|
discussion_languages: stateSiteForm.discussion_languages,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { Component, InfernoMouseEvent, linkEvent } from "inferno";
|
import { Component, InfernoMouseEvent, linkEvent } from "inferno";
|
||||||
import { EditSite, Tagline } from "lemmy-js-client";
|
import { EditSite, Tagline } from "lemmy-js-client";
|
||||||
|
@ -143,7 +142,6 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
|
||||||
async handleSaveClick(i: TaglineForm) {
|
async handleSaveClick(i: TaglineForm) {
|
||||||
i.props.onSaveSite({
|
i.props.onSaveSite({
|
||||||
taglines: i.state.taglines,
|
taglines: i.state.taglines,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
fetchUsers,
|
fetchUsers,
|
||||||
getUpdatedSearchId,
|
getUpdatedSearchId,
|
||||||
myAuth,
|
|
||||||
personToChoice,
|
personToChoice,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
|
@ -951,7 +950,6 @@ export class Modlog extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
async refetch() {
|
async refetch() {
|
||||||
const auth = myAuth();
|
|
||||||
const { actionType, page, modId, userId } = getModlogQueryParams();
|
const { actionType, page, modId, userId } = getModlogQueryParams();
|
||||||
const { communityId: urlCommunityId } = this.props.match.params;
|
const { communityId: urlCommunityId } = this.props.match.params;
|
||||||
const communityId = getIdFromString(urlCommunityId);
|
const communityId = getIdFromString(urlCommunityId);
|
||||||
|
@ -968,7 +966,6 @@ export class Modlog extends Component<
|
||||||
.hide_modlog_mod_names
|
.hide_modlog_mod_names
|
||||||
? modId ?? undefined
|
? modId ?? undefined
|
||||||
: undefined,
|
: undefined,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -977,7 +974,6 @@ export class Modlog extends Component<
|
||||||
this.setState({
|
this.setState({
|
||||||
communityRes: await HttpService.client.getCommunity({
|
communityRes: await HttpService.client.getCommunity({
|
||||||
id: communityId,
|
id: communityId,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -987,7 +983,6 @@ export class Modlog extends Component<
|
||||||
client,
|
client,
|
||||||
path,
|
path,
|
||||||
query: { modId: urlModId, page, userId: urlUserId, actionType },
|
query: { modId: urlModId, page, userId: urlUserId, actionType },
|
||||||
auth,
|
|
||||||
site,
|
site,
|
||||||
}: InitialFetchRequest<QueryParams<ModlogProps>>): Promise<ModlogData> {
|
}: InitialFetchRequest<QueryParams<ModlogProps>>): Promise<ModlogData> {
|
||||||
const pathSplit = path.split("/");
|
const pathSplit = path.split("/");
|
||||||
|
@ -1004,7 +999,6 @@ export class Modlog extends Component<
|
||||||
type_: getActionFromString(actionType),
|
type_: getActionFromString(actionType),
|
||||||
mod_person_id: modId,
|
mod_person_id: modId,
|
||||||
other_person_id: userId,
|
other_person_id: userId,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let communityResponse: RequestState<GetCommunityResponse> = {
|
let communityResponse: RequestState<GetCommunityResponse> = {
|
||||||
|
@ -1014,7 +1008,6 @@ export class Modlog extends Component<
|
||||||
if (communityId) {
|
if (communityId) {
|
||||||
const communityForm: GetCommunity = {
|
const communityForm: GetCommunity = {
|
||||||
id: communityId,
|
id: communityId,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
communityResponse = await client.getCommunity(communityForm);
|
communityResponse = await client.getCommunity(communityForm);
|
||||||
|
@ -1027,7 +1020,6 @@ export class Modlog extends Component<
|
||||||
if (modId) {
|
if (modId) {
|
||||||
const getPersonForm: GetPersonDetails = {
|
const getPersonForm: GetPersonDetails = {
|
||||||
person_id: modId,
|
person_id: modId,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
modUserResponse = await client.getPersonDetails(getPersonForm);
|
modUserResponse = await client.getPersonDetails(getPersonForm);
|
||||||
|
@ -1040,7 +1032,6 @@ export class Modlog extends Component<
|
||||||
if (userId) {
|
if (userId) {
|
||||||
const getPersonForm: GetPersonDetails = {
|
const getPersonForm: GetPersonDetails = {
|
||||||
person_id: userId,
|
person_id: userId,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
userResponse = await client.getPersonDetails(getPersonForm);
|
userResponse = await client.getPersonDetails(getPersonForm);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {
|
||||||
enableDownvotes,
|
enableDownvotes,
|
||||||
getCommentParentId,
|
getCommentParentId,
|
||||||
myAuth,
|
myAuth,
|
||||||
myAuthRequired,
|
|
||||||
setIsoData,
|
setIsoData,
|
||||||
updatePersonBlock,
|
updatePersonBlock,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
|
@ -63,7 +62,11 @@ import {
|
||||||
import { fetchLimit, relTags } from "../../config";
|
import { fetchLimit, relTags } from "../../config";
|
||||||
import { CommentViewType, InitialFetchRequest } from "../../interfaces";
|
import { CommentViewType, InitialFetchRequest } from "../../interfaces";
|
||||||
import { FirstLoadService, I18NextService, UserService } from "../../services";
|
import { FirstLoadService, I18NextService, UserService } from "../../services";
|
||||||
import { HttpService, RequestState } from "../../services/HttpService";
|
import {
|
||||||
|
EmptyRequestState,
|
||||||
|
HttpService,
|
||||||
|
RequestState,
|
||||||
|
} from "../../services/HttpService";
|
||||||
import { toast } from "../../toast";
|
import { toast } from "../../toast";
|
||||||
import { CommentNodes } from "../comment/comment-nodes";
|
import { CommentNodes } from "../comment/comment-nodes";
|
||||||
import { CommentSortSelect } from "../common/comment-sort-select";
|
import { CommentSortSelect } from "../common/comment-sort-select";
|
||||||
|
@ -719,38 +722,40 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
|
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
client,
|
client,
|
||||||
auth,
|
|
||||||
}: InitialFetchRequest): Promise<InboxData> {
|
}: InitialFetchRequest): Promise<InboxData> {
|
||||||
const sort: CommentSortType = "New";
|
const sort: CommentSortType = "New";
|
||||||
|
const empty: EmptyRequestState = { state: "empty" };
|
||||||
return {
|
let inboxData: InboxData = {
|
||||||
mentionsRes: auth
|
mentionsRes: empty,
|
||||||
? await client.getPersonMentions({
|
messagesRes: empty,
|
||||||
sort,
|
repliesRes: empty,
|
||||||
unread_only: true,
|
|
||||||
page: 1,
|
|
||||||
limit: fetchLimit,
|
|
||||||
auth,
|
|
||||||
})
|
|
||||||
: { state: "empty" },
|
|
||||||
messagesRes: auth
|
|
||||||
? await client.getPrivateMessages({
|
|
||||||
unread_only: true,
|
|
||||||
page: 1,
|
|
||||||
limit: fetchLimit,
|
|
||||||
auth,
|
|
||||||
})
|
|
||||||
: { state: "empty" },
|
|
||||||
repliesRes: auth
|
|
||||||
? await client.getReplies({
|
|
||||||
sort,
|
|
||||||
unread_only: true,
|
|
||||||
page: 1,
|
|
||||||
limit: fetchLimit,
|
|
||||||
auth,
|
|
||||||
})
|
|
||||||
: { state: "empty" },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (myAuth()) {
|
||||||
|
const [mentionsRes, messagesRes, repliesRes] = await Promise.all([
|
||||||
|
client.getPersonMentions({
|
||||||
|
sort,
|
||||||
|
unread_only: true,
|
||||||
|
page: 1,
|
||||||
|
limit: fetchLimit,
|
||||||
|
}),
|
||||||
|
client.getPrivateMessages({
|
||||||
|
unread_only: true,
|
||||||
|
page: 1,
|
||||||
|
limit: fetchLimit,
|
||||||
|
}),
|
||||||
|
client.getReplies({
|
||||||
|
sort,
|
||||||
|
unread_only: true,
|
||||||
|
page: 1,
|
||||||
|
limit: fetchLimit,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
inboxData = { mentionsRes, messagesRes, repliesRes };
|
||||||
|
}
|
||||||
|
|
||||||
|
return inboxData;
|
||||||
}
|
}
|
||||||
|
|
||||||
async refetch() {
|
async refetch() {
|
||||||
|
@ -758,7 +763,6 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
const unread_only = this.state.unreadOrAll === UnreadOrAll.Unread;
|
const unread_only = this.state.unreadOrAll === UnreadOrAll.Unread;
|
||||||
const page = this.state.page;
|
const page = this.state.page;
|
||||||
const limit = fetchLimit;
|
const limit = fetchLimit;
|
||||||
const auth = myAuthRequired();
|
|
||||||
|
|
||||||
this.setState({ repliesRes: { state: "loading" } });
|
this.setState({ repliesRes: { state: "loading" } });
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -767,7 +771,6 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
unread_only,
|
unread_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -778,7 +781,6 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
unread_only,
|
unread_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -788,7 +790,6 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
unread_only,
|
unread_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -802,9 +803,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
i.setState({ markAllAsReadRes: { state: "loading" } });
|
i.setState({ markAllAsReadRes: { state: "loading" } });
|
||||||
|
|
||||||
i.setState({
|
i.setState({
|
||||||
markAllAsReadRes: await HttpService.client.markAllAsRead({
|
markAllAsReadRes: await HttpService.client.markAllAsRead(),
|
||||||
auth: myAuthRequired(),
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (i.state.markAllAsReadRes.state === "success") {
|
if (i.state.markAllAsReadRes.state === "success") {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { myAuth, setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import { GetSiteResponse, LoginResponse } from "lemmy-js-client";
|
import { GetSiteResponse, LoginResponse } from "lemmy-js-client";
|
||||||
|
@ -126,7 +126,7 @@ export class PasswordChange extends Component<any, State> {
|
||||||
res: data,
|
res: data,
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = await HttpService.client.getSite({ auth: myAuth() });
|
const site = await HttpService.client.getSite();
|
||||||
if (site.state === "success") {
|
if (site.state === "success") {
|
||||||
UserService.Instance.myUserInfo = site.data.my_user;
|
UserService.Instance.myUserInfo = site.data.my_user;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import {
|
||||||
enableDownvotes,
|
enableDownvotes,
|
||||||
enableNsfw,
|
enableNsfw,
|
||||||
getCommentParentId,
|
getCommentParentId,
|
||||||
myAuth,
|
|
||||||
myAuthRequired,
|
|
||||||
setIsoData,
|
setIsoData,
|
||||||
updatePersonBlock,
|
updatePersonBlock,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
|
@ -243,7 +241,6 @@ export class Profile extends Component<
|
||||||
saved_only: view === PersonDetailsView.Saved,
|
saved_only: view === PersonDetailsView.Saved,
|
||||||
page,
|
page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
restoreScrollPosition(this.context);
|
restoreScrollPosition(this.context);
|
||||||
|
@ -278,7 +275,6 @@ export class Profile extends Component<
|
||||||
client,
|
client,
|
||||||
path,
|
path,
|
||||||
query: { page, sort, view: urlView },
|
query: { page, sort, view: urlView },
|
||||||
auth,
|
|
||||||
}: InitialFetchRequest<QueryParams<ProfileProps>>): Promise<ProfileData> {
|
}: InitialFetchRequest<QueryParams<ProfileProps>>): Promise<ProfileData> {
|
||||||
const pathSplit = path.split("/");
|
const pathSplit = path.split("/");
|
||||||
|
|
||||||
|
@ -291,7 +287,6 @@ export class Profile extends Component<
|
||||||
saved_only: view === PersonDetailsView.Saved,
|
saved_only: view === PersonDetailsView.Saved,
|
||||||
page: getPageFromString(page),
|
page: getPageFromString(page),
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -782,7 +777,6 @@ export class Profile extends Component<
|
||||||
remove_data: removeData,
|
remove_data: removeData,
|
||||||
reason: banReason,
|
reason: banReason,
|
||||||
expires: futureDaysToUnixTime(banExpireDays),
|
expires: futureDaysToUnixTime(banExpireDays),
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
// TODO
|
// TODO
|
||||||
this.updateBan(res);
|
this.updateBan(res);
|
||||||
|
@ -794,7 +788,6 @@ export class Profile extends Component<
|
||||||
const res = await HttpService.client.blockPerson({
|
const res = await HttpService.client.blockPerson({
|
||||||
person_id: recipientId,
|
person_id: recipientId,
|
||||||
block,
|
block,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
updatePersonBlock(res.data);
|
updatePersonBlock(res.data);
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import {
|
import { editRegistrationApplication, myAuth, setIsoData } from "@utils/app";
|
||||||
editRegistrationApplication,
|
|
||||||
myAuthRequired,
|
|
||||||
setIsoData,
|
|
||||||
} from "@utils/app";
|
|
||||||
import { randomStr } from "@utils/helpers";
|
import { randomStr } from "@utils/helpers";
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
@ -205,16 +201,14 @@ export class RegistrationApplications extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
auth,
|
|
||||||
client,
|
client,
|
||||||
}: InitialFetchRequest): Promise<RegistrationApplicationsData> {
|
}: InitialFetchRequest): Promise<RegistrationApplicationsData> {
|
||||||
return {
|
return {
|
||||||
listRegistrationApplicationsResponse: auth
|
listRegistrationApplicationsResponse: myAuth()
|
||||||
? await client.listRegistrationApplications({
|
? await client.listRegistrationApplications({
|
||||||
unread_only: true,
|
unread_only: true,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth: auth as string,
|
|
||||||
})
|
})
|
||||||
: { state: "empty" },
|
: { state: "empty" },
|
||||||
};
|
};
|
||||||
|
@ -230,7 +224,6 @@ export class RegistrationApplications extends Component<
|
||||||
unread_only: unread_only,
|
unread_only: unread_only,
|
||||||
page: this.state.page,
|
page: this.state.page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth: myAuthRequired(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import {
|
||||||
editCommentReport,
|
editCommentReport,
|
||||||
editPostReport,
|
editPostReport,
|
||||||
editPrivateMessageReport,
|
editPrivateMessageReport,
|
||||||
myAuthRequired,
|
|
||||||
setIsoData,
|
setIsoData,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { randomStr } from "@utils/helpers";
|
import { randomStr } from "@utils/helpers";
|
||||||
|
@ -531,7 +530,6 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
auth,
|
|
||||||
client,
|
client,
|
||||||
}: InitialFetchRequest): Promise<ReportsData> {
|
}: InitialFetchRequest): Promise<ReportsData> {
|
||||||
const unresolved_only = true;
|
const unresolved_only = true;
|
||||||
|
@ -542,14 +540,12 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
unresolved_only,
|
unresolved_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
auth: auth as string,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const postReportsForm: ListPostReports = {
|
const postReportsForm: ListPostReports = {
|
||||||
unresolved_only,
|
unresolved_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
auth: auth as string,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const data: ReportsData = {
|
const data: ReportsData = {
|
||||||
|
@ -563,7 +559,6 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
unresolved_only,
|
unresolved_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
auth: auth as string,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
data.messageReportsRes = await client.listPrivateMessageReports(
|
data.messageReportsRes = await client.listPrivateMessageReports(
|
||||||
|
@ -578,7 +573,6 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
const unresolved_only = this.state.unreadOrAll === UnreadOrAll.Unread;
|
const unresolved_only = this.state.unreadOrAll === UnreadOrAll.Unread;
|
||||||
const page = this.state.page;
|
const page = this.state.page;
|
||||||
const limit = fetchLimit;
|
const limit = fetchLimit;
|
||||||
const auth = myAuthRequired();
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
commentReportsRes: { state: "loading" },
|
commentReportsRes: { state: "loading" },
|
||||||
|
@ -593,7 +587,6 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
unresolved_only,
|
unresolved_only,
|
||||||
page,
|
page,
|
||||||
limit,
|
limit,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
fetchThemeList,
|
fetchThemeList,
|
||||||
fetchUsers,
|
fetchUsers,
|
||||||
myAuth,
|
myAuth,
|
||||||
myAuthRequired,
|
|
||||||
personToChoice,
|
personToChoice,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
setTheme,
|
setTheme,
|
||||||
|
@ -993,7 +992,6 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
const res = await HttpService.client.blockPerson({
|
const res = await HttpService.client.blockPerson({
|
||||||
person_id: Number(value),
|
person_id: Number(value),
|
||||||
block: true,
|
block: true,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
this.personBlock(res);
|
this.personBlock(res);
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1007,6 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
const res = await HttpService.client.blockPerson({
|
const res = await HttpService.client.blockPerson({
|
||||||
person_id: recipientId,
|
person_id: recipientId,
|
||||||
block: false,
|
block: false,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
ctx.personBlock(res);
|
ctx.personBlock(res);
|
||||||
}
|
}
|
||||||
|
@ -1019,19 +1016,16 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
const res = await HttpService.client.blockCommunity({
|
const res = await HttpService.client.blockCommunity({
|
||||||
community_id: Number(value),
|
community_id: Number(value),
|
||||||
block: true,
|
block: true,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
this.communityBlock(res);
|
this.communityBlock(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleUnblockCommunity(i: { ctx: Settings; communityId: number }) {
|
async handleUnblockCommunity(i: { ctx: Settings; communityId: number }) {
|
||||||
const auth = myAuth();
|
if (myAuth()) {
|
||||||
if (auth) {
|
|
||||||
const res = await HttpService.client.blockCommunity({
|
const res = await HttpService.client.blockCommunity({
|
||||||
community_id: i.communityId,
|
community_id: i.communityId,
|
||||||
block: false,
|
block: false,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
i.ctx.communityBlock(res);
|
i.ctx.communityBlock(res);
|
||||||
}
|
}
|
||||||
|
@ -1232,7 +1226,6 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
|
|
||||||
const saveRes = await HttpService.client.saveUserSettings({
|
const saveRes = await HttpService.client.saveUserSettings({
|
||||||
...i.state.saveUserSettingsForm,
|
...i.state.saveUserSettingsForm,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (saveRes.state === "success") {
|
if (saveRes.state === "success") {
|
||||||
|
@ -1258,7 +1251,6 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
new_password,
|
new_password,
|
||||||
new_password_verify,
|
new_password_verify,
|
||||||
old_password,
|
old_password,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
if (changePasswordRes.state === "success") {
|
if (changePasswordRes.state === "success") {
|
||||||
UserService.Instance.login({
|
UserService.Instance.login({
|
||||||
|
@ -1288,8 +1280,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
i.setState({ deleteAccountRes: { state: "loading" } });
|
i.setState({ deleteAccountRes: { state: "loading" } });
|
||||||
const deleteAccountRes = await HttpService.client.deleteAccount({
|
const deleteAccountRes = await HttpService.client.deleteAccount({
|
||||||
password,
|
password,
|
||||||
auth: myAuthRequired(),
|
// TODO: promt user weather he wants the content to be deleted
|
||||||
// TODO: promt user weather he wants the content to be deleted,
|
|
||||||
delete_content: false,
|
delete_content: false,
|
||||||
});
|
});
|
||||||
if (deleteAccountRes.state === "success") {
|
if (deleteAccountRes.state === "success") {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { enableDownvotes, enableNsfw, myAuth, setIsoData } from "@utils/app";
|
import { enableDownvotes, enableNsfw, setIsoData } from "@utils/app";
|
||||||
import { getIdFromString, getQueryParams } from "@utils/helpers";
|
import { getIdFromString, getQueryParams } from "@utils/helpers";
|
||||||
import type { QueryParams } from "@utils/types";
|
import type { QueryParams } from "@utils/types";
|
||||||
import { Choice, RouteDataResponse } from "@utils/types";
|
import { Choice, RouteDataResponse } from "@utils/types";
|
||||||
|
@ -96,12 +96,10 @@ export class CreatePost extends Component<
|
||||||
|
|
||||||
async fetchCommunity() {
|
async fetchCommunity() {
|
||||||
const { communityId } = getCreatePostQueryParams();
|
const { communityId } = getCreatePostQueryParams();
|
||||||
const auth = myAuth();
|
|
||||||
|
|
||||||
if (communityId) {
|
if (communityId) {
|
||||||
const res = await HttpService.client.getCommunity({
|
const res = await HttpService.client.getCommunity({
|
||||||
id: communityId,
|
id: communityId,
|
||||||
auth,
|
|
||||||
});
|
});
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -239,7 +237,6 @@ export class CreatePost extends Component<
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
client,
|
client,
|
||||||
query: { communityId },
|
query: { communityId },
|
||||||
auth,
|
|
||||||
}: InitialFetchRequest<
|
}: InitialFetchRequest<
|
||||||
QueryParams<CreatePostProps>
|
QueryParams<CreatePostProps>
|
||||||
>): Promise<CreatePostData> {
|
>): Promise<CreatePostData> {
|
||||||
|
@ -250,7 +247,6 @@ export class CreatePost extends Component<
|
||||||
|
|
||||||
if (communityId) {
|
if (communityId) {
|
||||||
const form: GetCommunity = {
|
const form: GetCommunity = {
|
||||||
auth,
|
|
||||||
id: getIdFromString(communityId),
|
id: getIdFromString(communityId),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
import {
|
import { communityToChoice, fetchCommunities } from "@utils/app";
|
||||||
communityToChoice,
|
|
||||||
fetchCommunities,
|
|
||||||
myAuth,
|
|
||||||
myAuthRequired,
|
|
||||||
} from "@utils/app";
|
|
||||||
import {
|
import {
|
||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
debounce,
|
debounce,
|
||||||
|
@ -89,7 +84,6 @@ function handlePostSubmit(i: PostForm, event: any) {
|
||||||
i.setState(s => ((s.form.url = undefined), s));
|
i.setState(s => ((s.form.url = undefined), s));
|
||||||
}
|
}
|
||||||
i.setState({ loading: true, submitted: true });
|
i.setState({ loading: true, submitted: true });
|
||||||
const auth = myAuthRequired();
|
|
||||||
|
|
||||||
const pForm = i.state.form;
|
const pForm = i.state.form;
|
||||||
const pv = i.props.post_view;
|
const pv = i.props.post_view;
|
||||||
|
@ -102,7 +96,6 @@ function handlePostSubmit(i: PostForm, event: any) {
|
||||||
nsfw: pForm.nsfw,
|
nsfw: pForm.nsfw,
|
||||||
post_id: pv.post.id,
|
post_id: pv.post.id,
|
||||||
language_id: pForm.language_id,
|
language_id: pForm.language_id,
|
||||||
auth,
|
|
||||||
});
|
});
|
||||||
} else if (pForm.name && pForm.community_id) {
|
} else if (pForm.name && pForm.community_id) {
|
||||||
i.props.onCreate?.({
|
i.props.onCreate?.({
|
||||||
|
@ -113,7 +106,6 @@ function handlePostSubmit(i: PostForm, event: any) {
|
||||||
nsfw: pForm.nsfw,
|
nsfw: pForm.nsfw,
|
||||||
language_id: pForm.language_id,
|
language_id: pForm.language_id,
|
||||||
honeypot: pForm.honeypot,
|
honeypot: pForm.honeypot,
|
||||||
auth,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,7 +668,6 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
community_id: this.state.form.community_id,
|
community_id: this.state.form.community_id,
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: trendingFetchLimit,
|
limit: trendingFetchLimit,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { myAuth, myAuthRequired } from "@utils/app";
|
import { myAuth } from "@utils/app";
|
||||||
import { canShare, share } from "@utils/browser";
|
import { canShare, share } from "@utils/browser";
|
||||||
import { getExternalHost, getHttpBase } from "@utils/env";
|
import { getExternalHost, getHttpBase } from "@utils/env";
|
||||||
import {
|
import {
|
||||||
|
@ -1444,7 +1444,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
this.props.onPostReport({
|
this.props.onPostReport({
|
||||||
post_id: this.postView.post.id,
|
post_id: this.postView.post.id,
|
||||||
reason,
|
reason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1457,7 +1456,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onBlockPerson({
|
i.props.onBlockPerson({
|
||||||
person_id: i.postView.creator.id,
|
person_id: i.postView.creator.id,
|
||||||
block: true,
|
block: true,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1466,7 +1464,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onDeletePost({
|
i.props.onDeletePost({
|
||||||
post_id: i.postView.post.id,
|
post_id: i.postView.post.id,
|
||||||
deleted: !i.postView.post.deleted,
|
deleted: !i.postView.post.deleted,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1475,7 +1472,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onSavePost({
|
i.props.onSavePost({
|
||||||
post_id: i.postView.post.id,
|
post_id: i.postView.post.id,
|
||||||
save: !i.postView.saved,
|
save: !i.postView.saved,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1533,7 +1529,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onRemovePost({
|
i.props.onRemovePost({
|
||||||
post_id: i.postView.post.id,
|
post_id: i.postView.post.id,
|
||||||
removed: !i.postView.post.removed,
|
removed: !i.postView.post.removed,
|
||||||
auth: myAuthRequired(),
|
|
||||||
reason: i.state.removeReason,
|
reason: i.state.removeReason,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1543,7 +1538,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onLockPost({
|
i.props.onLockPost({
|
||||||
post_id: i.postView.post.id,
|
post_id: i.postView.post.id,
|
||||||
locked: !i.postView.post.locked,
|
locked: !i.postView.post.locked,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1553,7 +1547,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
post_id: i.postView.post.id,
|
post_id: i.postView.post.id,
|
||||||
featured: !i.postView.post.featured_local,
|
featured: !i.postView.post.featured_local,
|
||||||
feature_type: "Local",
|
feature_type: "Local",
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1563,7 +1556,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
post_id: i.postView.post.id,
|
post_id: i.postView.post.id,
|
||||||
featured: !i.postView.post.featured_community,
|
featured: !i.postView.post.featured_community,
|
||||||
feature_type: "Community",
|
feature_type: "Community",
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1610,13 +1602,11 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onPurgePerson({
|
i.props.onPurgePerson({
|
||||||
person_id: i.postView.creator.id,
|
person_id: i.postView.creator.id,
|
||||||
reason: i.state.purgeReason,
|
reason: i.state.purgeReason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else if (i.state.purgeType === PurgeType.Post) {
|
} else if (i.state.purgeType === PurgeType.Post) {
|
||||||
i.props.onPurgePost({
|
i.props.onPurgePost({
|
||||||
post_id: i.postView.post.id,
|
post_id: i.postView.post.id,
|
||||||
reason: i.state.purgeReason,
|
reason: i.state.purgeReason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1662,7 +1652,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
remove_data,
|
remove_data,
|
||||||
reason,
|
reason,
|
||||||
expires,
|
expires,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
i.props.onBanPerson({
|
i.props.onBanPerson({
|
||||||
|
@ -1671,7 +1660,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
remove_data,
|
remove_data,
|
||||||
reason,
|
reason,
|
||||||
expires,
|
expires,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1682,7 +1670,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
community_id: i.postView.community.id,
|
community_id: i.postView.community.id,
|
||||||
person_id: i.postView.creator.id,
|
person_id: i.postView.creator.id,
|
||||||
added: !i.creatorIsMod_,
|
added: !i.creatorIsMod_,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1691,7 +1678,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onAddAdmin({
|
i.props.onAddAdmin({
|
||||||
person_id: i.postView.creator.id,
|
person_id: i.postView.creator.id,
|
||||||
added: !i.creatorIsAdmin_,
|
added: !i.creatorIsAdmin_,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1708,7 +1694,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.props.onTransferCommunity({
|
i.props.onTransferCommunity({
|
||||||
community_id: i.postView.community.id,
|
community_id: i.postView.community.id,
|
||||||
person_id: i.postView.creator.id,
|
person_id: i.postView.creator.id,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1725,12 +1710,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
i.setState({ imageExpanded: !i.state.imageExpanded });
|
i.setState({ imageExpanded: !i.state.imageExpanded });
|
||||||
setupTippy();
|
setupTippy();
|
||||||
|
|
||||||
const auth = myAuth();
|
if (myAuth() && !i.props.post_view.read) {
|
||||||
if (auth && !i.props.post_view.read) {
|
|
||||||
i.props.onMarkPostAsRead({
|
i.props.onMarkPostAsRead({
|
||||||
post_id: i.props.post_view.post.id,
|
post_id: i.props.post_view.post.id,
|
||||||
read: true,
|
read: true,
|
||||||
auth: auth,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
import { PostReportView, PostView, ResolvePostReport } from "lemmy-js-client";
|
import { PostReportView, PostView, ResolvePostReport } from "lemmy-js-client";
|
||||||
|
@ -137,7 +136,6 @@ export class PostReport extends Component<PostReportProps, PostReportState> {
|
||||||
i.props.onResolveReport({
|
i.props.onResolveReport({
|
||||||
report_id: i.props.report.post_report.id,
|
report_id: i.props.report.post_report.id,
|
||||||
resolved: !i.props.report.post_report.resolved,
|
resolved: !i.props.report.post_report.resolved,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
getCommentParentId,
|
getCommentParentId,
|
||||||
getDepthFromComment,
|
getDepthFromComment,
|
||||||
getIdFromProps,
|
getIdFromProps,
|
||||||
myAuth,
|
|
||||||
setIsoData,
|
setIsoData,
|
||||||
updateCommunityBlock,
|
updateCommunityBlock,
|
||||||
updatePersonBlock,
|
updatePersonBlock,
|
||||||
|
@ -201,23 +200,24 @@ export class Post extends Component<any, PostState> {
|
||||||
commentsRes: { state: "loading" },
|
commentsRes: { state: "loading" },
|
||||||
});
|
});
|
||||||
|
|
||||||
const auth = myAuth();
|
const [postRes, commentsRes] = await Promise.all([
|
||||||
|
await HttpService.client.getPost({
|
||||||
this.setState({
|
|
||||||
postRes: await HttpService.client.getPost({
|
|
||||||
id: this.state.postId,
|
id: this.state.postId,
|
||||||
comment_id: this.state.commentId,
|
comment_id: this.state.commentId,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
commentsRes: await HttpService.client.getComments({
|
HttpService.client.getComments({
|
||||||
post_id: this.state.postId,
|
post_id: this.state.postId,
|
||||||
parent_id: this.state.commentId,
|
parent_id: this.state.commentId,
|
||||||
max_depth: commentTreeMaxDepth,
|
max_depth: commentTreeMaxDepth,
|
||||||
sort: this.state.commentSort,
|
sort: this.state.commentSort,
|
||||||
type_: "All",
|
type_: "All",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
postRes,
|
||||||
|
commentsRes,
|
||||||
});
|
});
|
||||||
|
|
||||||
setupTippy();
|
setupTippy();
|
||||||
|
@ -232,23 +232,19 @@ export class Post extends Component<any, PostState> {
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
client,
|
client,
|
||||||
path,
|
path,
|
||||||
auth,
|
|
||||||
}: InitialFetchRequest): Promise<PostData> {
|
}: InitialFetchRequest): Promise<PostData> {
|
||||||
const pathSplit = path.split("/");
|
const pathSplit = path.split("/");
|
||||||
|
|
||||||
const pathType = pathSplit.at(1);
|
const pathType = pathSplit.at(1);
|
||||||
const id = pathSplit.at(2) ? Number(pathSplit.at(2)) : undefined;
|
const id = pathSplit.at(2) ? Number(pathSplit.at(2)) : undefined;
|
||||||
|
|
||||||
const postForm: GetPost = {
|
const postForm: GetPost = {};
|
||||||
auth,
|
|
||||||
};
|
|
||||||
|
|
||||||
const commentsForm: GetComments = {
|
const commentsForm: GetComments = {
|
||||||
max_depth: commentTreeMaxDepth,
|
max_depth: commentTreeMaxDepth,
|
||||||
sort: "Hot",
|
sort: "Hot",
|
||||||
type_: "All",
|
type_: "All",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the correct id based on the path type
|
// Set the correct id based on the path type
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getRecipientIdFromProps, myAuth, setIsoData } from "@utils/app";
|
import { getRecipientIdFromProps, setIsoData } from "@utils/app";
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
import {
|
import {
|
||||||
|
@ -62,7 +62,6 @@ export class CreatePrivateMessage extends Component<
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
client,
|
client,
|
||||||
path,
|
path,
|
||||||
auth,
|
|
||||||
}: InitialFetchRequest): Promise<CreatePrivateMessageData> {
|
}: InitialFetchRequest): Promise<CreatePrivateMessageData> {
|
||||||
const person_id = Number(path.split("/").pop());
|
const person_id = Number(path.split("/").pop());
|
||||||
|
|
||||||
|
@ -70,7 +69,6 @@ export class CreatePrivateMessage extends Component<
|
||||||
person_id,
|
person_id,
|
||||||
sort: "New",
|
sort: "New",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -88,7 +86,6 @@ export class CreatePrivateMessage extends Component<
|
||||||
person_id: this.state.recipientId,
|
person_id: this.state.recipientId,
|
||||||
sort: "New",
|
sort: "New",
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { Component, InfernoNode } from "inferno";
|
import { Component, InfernoNode } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
|
@ -128,19 +127,16 @@ export class PrivateMessageForm extends Component<
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
i.setState({ loading: true, submitted: true });
|
i.setState({ loading: true, submitted: true });
|
||||||
const pm = i.props.privateMessageView;
|
const pm = i.props.privateMessageView;
|
||||||
const auth = myAuthRequired();
|
|
||||||
const content = i.state.content ?? "";
|
const content = i.state.content ?? "";
|
||||||
if (pm) {
|
if (pm) {
|
||||||
i.props.onEdit?.({
|
i.props.onEdit?.({
|
||||||
private_message_id: pm.private_message.id,
|
private_message_id: pm.private_message.id,
|
||||||
content,
|
content,
|
||||||
auth,
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
i.props.onCreate?.({
|
i.props.onCreate?.({
|
||||||
content,
|
content,
|
||||||
recipient_id: i.props.recipient.id,
|
recipient_id: i.props.recipient.id,
|
||||||
auth,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||||
import { T } from "inferno-i18next-dess";
|
import { T } from "inferno-i18next-dess";
|
||||||
import {
|
import {
|
||||||
|
@ -105,7 +104,6 @@ export class PrivateMessageReport extends Component<Props, State> {
|
||||||
i.props.onResolveReport({
|
i.props.onResolveReport({
|
||||||
report_id: pmr.id,
|
report_id: pmr.id,
|
||||||
resolved: !pmr.resolved,
|
resolved: !pmr.resolved,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuthRequired } from "@utils/app";
|
|
||||||
import { Component, InfernoNode, linkEvent } from "inferno";
|
import { Component, InfernoNode, linkEvent } from "inferno";
|
||||||
import {
|
import {
|
||||||
CreatePrivateMessage,
|
CreatePrivateMessage,
|
||||||
|
@ -304,7 +303,6 @@ export class PrivateMessage extends Component<
|
||||||
i.props.onDelete({
|
i.props.onDelete({
|
||||||
private_message_id: i.props.private_message_view.private_message.id,
|
private_message_id: i.props.private_message_view.private_message.id,
|
||||||
deleted: !i.props.private_message_view.private_message.deleted,
|
deleted: !i.props.private_message_view.private_message.deleted,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +315,6 @@ export class PrivateMessage extends Component<
|
||||||
i.props.onMarkRead({
|
i.props.onMarkRead({
|
||||||
private_message_id: i.props.private_message_view.private_message.id,
|
private_message_id: i.props.private_message_view.private_message.id,
|
||||||
read: !i.props.private_message_view.private_message.read,
|
read: !i.props.private_message_view.private_message.read,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +334,6 @@ export class PrivateMessage extends Component<
|
||||||
this.props.onReport({
|
this.props.onReport({
|
||||||
private_message_id: this.props.private_message_view.private_message.id,
|
private_message_id: this.props.private_message_view.private_message.id,
|
||||||
reason,
|
reason,
|
||||||
auth: myAuthRequired(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { myAuthRequired, setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { getQueryParams } from "@utils/helpers";
|
import { getQueryParams } from "@utils/helpers";
|
||||||
import { QueryParams, RouteDataResponse } from "@utils/types";
|
import { QueryParams, RouteDataResponse } from "@utils/types";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
|
@ -49,7 +49,6 @@ async function handleToggleFollow(i: RemoteFetch, follow: boolean) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const communityRes = await HttpService.client.followCommunity({
|
const communityRes = await HttpService.client.followCommunity({
|
||||||
auth: myAuthRequired(),
|
|
||||||
community_id: resolveObjectRes.data.community.community.id,
|
community_id: resolveObjectRes.data.community.community.id,
|
||||||
follow,
|
follow,
|
||||||
});
|
});
|
||||||
|
@ -104,7 +103,6 @@ export class RemoteFetch extends Component<any, RemoteFetchState> {
|
||||||
this.setState({ resolveObjectRes: { state: "loading" } });
|
this.setState({ resolveObjectRes: { state: "loading" } });
|
||||||
this.setState({
|
this.setState({
|
||||||
resolveObjectRes: await HttpService.client.resolveObject({
|
resolveObjectRes: await HttpService.client.resolveObject({
|
||||||
auth: myAuthRequired(),
|
|
||||||
q: uriToQuery(uri),
|
q: uriToQuery(uri),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -204,8 +202,8 @@ export class RemoteFetch extends Component<any, RemoteFetchState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
client,
|
|
||||||
auth,
|
auth,
|
||||||
|
client,
|
||||||
query: { uri },
|
query: { uri },
|
||||||
}: InitialFetchRequest<
|
}: InitialFetchRequest<
|
||||||
QueryParams<RemoteFetchProps>
|
QueryParams<RemoteFetchProps>
|
||||||
|
@ -214,7 +212,6 @@ export class RemoteFetch extends Component<any, RemoteFetchState> {
|
||||||
|
|
||||||
if (uri && auth) {
|
if (uri && auth) {
|
||||||
data.resolveObjectRes = await client.resolveObject({
|
data.resolveObjectRes = await client.resolveObject({
|
||||||
auth,
|
|
||||||
q: uriToQuery(uri),
|
q: uriToQuery(uri),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,7 +349,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
type_: defaultListingType,
|
type_: defaultListingType,
|
||||||
sort: defaultSortType,
|
sort: defaultSortType,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth: myAuth(),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -360,7 +359,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
|
|
||||||
static async fetchInitialData({
|
static async fetchInitialData({
|
||||||
client,
|
client,
|
||||||
auth,
|
|
||||||
query: { communityId, creatorId, q, type, sort, listingType, page },
|
query: { communityId, creatorId, q, type, sort, listingType, page },
|
||||||
}: InitialFetchRequest<QueryParams<SearchProps>>): Promise<SearchData> {
|
}: InitialFetchRequest<QueryParams<SearchProps>>): Promise<SearchData> {
|
||||||
const community_id = getIdFromString(communityId);
|
const community_id = getIdFromString(communityId);
|
||||||
|
@ -373,7 +371,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
if (community_id) {
|
if (community_id) {
|
||||||
const getCommunityForm: GetCommunity = {
|
const getCommunityForm: GetCommunity = {
|
||||||
id: community_id,
|
id: community_id,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
communityResponse = await client.getCommunity(getCommunityForm);
|
communityResponse = await client.getCommunity(getCommunityForm);
|
||||||
|
@ -382,7 +379,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
type_: defaultListingType,
|
type_: defaultListingType,
|
||||||
sort: defaultSortType,
|
sort: defaultSortType,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
listCommunitiesResponse = await client.listCommunities(
|
listCommunitiesResponse = await client.listCommunities(
|
||||||
|
@ -397,7 +393,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
if (creator_id) {
|
if (creator_id) {
|
||||||
const getCreatorForm: GetPersonDetails = {
|
const getCreatorForm: GetPersonDetails = {
|
||||||
person_id: creator_id,
|
person_id: creator_id,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
creatorDetailsResponse = await client.getPersonDetails(getCreatorForm);
|
creatorDetailsResponse = await client.getPersonDetails(getCreatorForm);
|
||||||
|
@ -420,15 +415,13 @@ export class Search extends Component<any, SearchState> {
|
||||||
listing_type: getListingTypeFromQuery(listingType),
|
listing_type: getListingTypeFromQuery(listingType),
|
||||||
page: getPageFromString(page),
|
page: getPageFromString(page),
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (query !== "") {
|
if (query !== "") {
|
||||||
searchResponse = await client.search(form);
|
searchResponse = await client.search(form);
|
||||||
if (auth) {
|
if (myAuth()) {
|
||||||
const resolveObjectForm: ResolveObject = {
|
const resolveObjectForm: ResolveObject = {
|
||||||
q: query,
|
q: query,
|
||||||
auth,
|
|
||||||
};
|
};
|
||||||
resolveObjectResponse = await HttpService.silent_client.resolveObject(
|
resolveObjectResponse = await HttpService.silent_client.resolveObject(
|
||||||
resolveObjectForm,
|
resolveObjectForm,
|
||||||
|
@ -950,7 +943,6 @@ export class Search extends Component<any, SearchState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async search() {
|
async search() {
|
||||||
const auth = myAuth();
|
|
||||||
const { searchText: q } = this.state;
|
const { searchText: q } = this.state;
|
||||||
const { communityId, creatorId, type, sort, listingType, page } =
|
const { communityId, creatorId, type, sort, listingType, page } =
|
||||||
getSearchQueryParams();
|
getSearchQueryParams();
|
||||||
|
@ -967,18 +959,16 @@ export class Search extends Component<any, SearchState> {
|
||||||
listing_type: listingType,
|
listing_type: listingType,
|
||||||
page,
|
page,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
restoreScrollPosition(this.context);
|
restoreScrollPosition(this.context);
|
||||||
|
|
||||||
if (auth) {
|
if (myAuth()) {
|
||||||
this.setState({ resolveObjectRes: { state: "loading" } });
|
this.setState({ resolveObjectRes: { state: "loading" } });
|
||||||
this.setState({
|
this.setState({
|
||||||
resolveObjectRes: await HttpService.silent_client.resolveObject({
|
resolveObjectRes: await HttpService.silent_client.resolveObject({
|
||||||
q,
|
q,
|
||||||
auth,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ declare global {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InitialFetchRequest<T extends ParsedQs = ParsedQs> {
|
export interface InitialFetchRequest<T extends ParsedQs = ParsedQs> {
|
||||||
auth?: string;
|
|
||||||
client: WrappedLemmyHttp;
|
client: WrappedLemmyHttp;
|
||||||
path: string;
|
path: string;
|
||||||
query: T;
|
query: T;
|
||||||
site: GetSiteResponse;
|
site: GetSiteResponse;
|
||||||
|
auth?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostFormParams {
|
export interface PostFormParams {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import jwt_decode from "jwt-decode";
|
||||||
import { LoginResponse, MyUserInfo } from "lemmy-js-client";
|
import { LoginResponse, MyUserInfo } from "lemmy-js-client";
|
||||||
import { toast } from "../toast";
|
import { toast } from "../toast";
|
||||||
import { I18NextService } from "./I18NextService";
|
import { I18NextService } from "./I18NextService";
|
||||||
|
import { HttpService } from ".";
|
||||||
|
|
||||||
interface Claims {
|
interface Claims {
|
||||||
sub: number;
|
sub: number;
|
||||||
|
@ -81,6 +82,7 @@ export class UserService {
|
||||||
const { jwt } = cookie.parse(document.cookie);
|
const { jwt } = cookie.parse(document.cookie);
|
||||||
|
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
|
HttpService.client.setHeaders({ Authorization: `Bearer ${jwt}` });
|
||||||
this.jwtInfo = { jwt, claims: jwt_decode(jwt) };
|
this.jwtInfo = { jwt, claims: jwt_decode(jwt) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { myAuth } from "@utils/app";
|
|
||||||
import { Search, SearchType } from "lemmy-js-client";
|
import { Search, SearchType } from "lemmy-js-client";
|
||||||
import { fetchLimit } from "../../config";
|
import { fetchLimit } from "../../config";
|
||||||
import { HttpService } from "../../services";
|
import { HttpService } from "../../services";
|
||||||
|
@ -11,7 +10,6 @@ export default function fetchSearchResults(q: string, type_: SearchType) {
|
||||||
listing_type: "All",
|
listing_type: "All",
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: fetchLimit,
|
limit: fetchLimit,
|
||||||
auth: myAuth(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return HttpService.client.search(form);
|
return HttpService.client.search(form);
|
||||||
|
|
|
@ -35,7 +35,6 @@ import insertCommentIntoTree from "./insert-comment-into-tree";
|
||||||
import isAuthPath from "./is-auth-path";
|
import isAuthPath from "./is-auth-path";
|
||||||
import isPostBlocked from "./is-post-blocked";
|
import isPostBlocked from "./is-post-blocked";
|
||||||
import myAuth from "./my-auth";
|
import myAuth from "./my-auth";
|
||||||
import myAuthRequired from "./my-auth-required";
|
|
||||||
import newVote from "./new-vote";
|
import newVote from "./new-vote";
|
||||||
import nsfwCheck from "./nsfw-check";
|
import nsfwCheck from "./nsfw-check";
|
||||||
import personSearch from "./person-search";
|
import personSearch from "./person-search";
|
||||||
|
@ -92,7 +91,6 @@ export {
|
||||||
isAuthPath,
|
isAuthPath,
|
||||||
isPostBlocked,
|
isPostBlocked,
|
||||||
myAuth,
|
myAuth,
|
||||||
myAuthRequired,
|
|
||||||
newVote,
|
newVote,
|
||||||
nsfwCheck,
|
nsfwCheck,
|
||||||
personSearch,
|
personSearch,
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
import { UserService } from "../../services";
|
|
||||||
|
|
||||||
export default function myAuthRequired(): string {
|
|
||||||
return UserService.Instance.auth(true) ?? "";
|
|
||||||
}
|
|
|
@ -17,7 +17,6 @@ import isCakeDay from "./is-cake-day";
|
||||||
import numToSI from "./num-to-si";
|
import numToSI from "./num-to-si";
|
||||||
import poll from "./poll";
|
import poll from "./poll";
|
||||||
import randomStr from "./random-str";
|
import randomStr from "./random-str";
|
||||||
import removeAuthParam from "./remove-auth-param";
|
|
||||||
import sleep from "./sleep";
|
import sleep from "./sleep";
|
||||||
import validEmail from "./valid-email";
|
import validEmail from "./valid-email";
|
||||||
import validInstanceTLD from "./valid-instance-tld";
|
import validInstanceTLD from "./valid-instance-tld";
|
||||||
|
@ -44,7 +43,6 @@ export {
|
||||||
numToSI,
|
numToSI,
|
||||||
poll,
|
poll,
|
||||||
randomStr,
|
randomStr,
|
||||||
removeAuthParam,
|
|
||||||
sleep,
|
sleep,
|
||||||
validEmail,
|
validEmail,
|
||||||
validInstanceTLD,
|
validInstanceTLD,
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
export default function (err: any) {
|
|
||||||
return err
|
|
||||||
.toString()
|
|
||||||
.replace(new RegExp("[?&]auth=[^&#]*(#.*)?$"), "$1")
|
|
||||||
.replace(new RegExp("([?&])auth=[^&]*&"), "$1");
|
|
||||||
}
|
|
|
@ -6035,10 +6035,10 @@ leac@^0.6.0:
|
||||||
resolved "https://registry.yarnpkg.com/leac/-/leac-0.6.0.tgz#dcf136e382e666bd2475f44a1096061b70dc0912"
|
resolved "https://registry.yarnpkg.com/leac/-/leac-0.6.0.tgz#dcf136e382e666bd2475f44a1096061b70dc0912"
|
||||||
integrity sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==
|
integrity sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==
|
||||||
|
|
||||||
lemmy-js-client@^0.19.0-rc.7:
|
lemmy-js-client@^0.19.0-rc.12:
|
||||||
version "0.19.0-rc.7"
|
version "0.19.0-rc.12"
|
||||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.19.0-rc.7.tgz#822dd85c44c2df03eafb71c6e046dbeeb6ed854d"
|
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.19.0-rc.12.tgz#e3bd4e21b1966d583ab790ef70ece8394b012b48"
|
||||||
integrity sha512-dqnyepju5sCRu+zwwm8GeQtXJpRnz/mARo//fZBPz1EgNA70crWheamBoJ9GSm19znsZzu0853t8GxVhNT9iIw==
|
integrity sha512-1iu2fW9vlb3TrI+QR/ODP3+5pWZB0rUqL1wH09IzomDXohCqoQvfmXpwArmgF4Eq8GZgjkcfeMDC2gMrfw/i7Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
cross-fetch "^3.1.5"
|
cross-fetch "^3.1.5"
|
||||||
form-data "^4.0.0"
|
form-data "^4.0.0"
|
||||||
|
|
Loading…
Reference in a new issue