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