Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade for lemmy js client 0.19.0-alpha.16 #2210

Merged
merged 3 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"inferno-router": "^8.2.2",
"inferno-server": "^8.2.2",
"jwt-decode": "^3.1.2",
"lemmy-js-client": "0.19.0-rc.14",
"lemmy-js-client": "0.19.0-alpha.16",
"lodash.isequal": "^4.5.0",
"markdown-it": "^13.0.1",
"markdown-it-bidi": "^0.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/shared/components/comment/comment-report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class CommentReport extends Component<
post: r.post,
community: r.community,
creator_banned_from_community: r.creator_banned_from_community,
creator_is_moderator: false,
counts: r.counts,
subscribed: "NotSubscribed",
saved: false,
Expand Down
13 changes: 3 additions & 10 deletions src/shared/components/community/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ import {
LockPost,
MarkCommentReplyAsRead,
MarkPersonMentionAsRead,
MarkPostAsRead,
PaginationCursor,
PostResponse,
PurgeComment,
PurgeCommunity,
PurgeItemResponse,
PurgePerson,
PurgePost,
RemoveComment,
Expand All @@ -71,6 +69,7 @@ import {
SaveComment,
SavePost,
SortType,
SuccessResponse,
TransferCommunity,
} from "lemmy-js-client";
import { fetchLimit, relTags } from "../../config";
Expand Down Expand Up @@ -198,7 +197,6 @@ export class Community extends Component<
this.handleSavePost = this.handleSavePost.bind(this);
this.handlePurgePost = this.handlePurgePost.bind(this);
this.handleFeaturePost = this.handleFeaturePost.bind(this);
this.handleMarkPostAsRead = this.handleMarkPostAsRead.bind(this);
this.mainContentRef = createRef();
// Only fetch the data if coming from another route
if (FirstLoadService.isFirstLoad) {
Expand Down Expand Up @@ -436,7 +434,7 @@ export class Community extends Component<
onAddAdmin={this.handleAddAdmin}
onTransferCommunity={this.handleTransferCommunity}
onFeaturePost={this.handleFeaturePost}
onMarkPostAsRead={this.handleMarkPostAsRead}
onMarkPostAsRead={() => {}}
/>
);
}
Expand Down Expand Up @@ -804,11 +802,6 @@ export class Community extends Component<
await HttpService.client.markPersonMentionAsRead(form);
}

async handleMarkPostAsRead(form: MarkPostAsRead) {
const res = await HttpService.client.markPostAsRead(form);
this.findAndUpdatePost(res);
}

async handleBanFromCommunity(form: BanFromCommunity) {
const banRes = await HttpService.client.banFromCommunity(form);
this.updateBanFromCommunity(banRes);
Expand Down Expand Up @@ -882,7 +875,7 @@ export class Community extends Component<
});
}

purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
purgeItem(purgeRes: RequestState<SuccessResponse>) {
if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/home/admin-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
async handleDeleteEmoji(form: DeleteCustomEmoji) {
const res = await HttpService.client.deleteCustomEmoji(form);
if (res.state === "success") {
removeFromEmojiDataModel(res.data.id);
removeFromEmojiDataModel(form.id);
}
}

Expand Down
13 changes: 3 additions & 10 deletions src/shared/components/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,17 @@ import {
LockPost,
MarkCommentReplyAsRead,
MarkPersonMentionAsRead,
MarkPostAsRead,
PaginationCursor,
PostResponse,
PurgeComment,
PurgeItemResponse,
PurgePerson,
PurgePost,
RemoveComment,
RemovePost,
SaveComment,
SavePost,
SortType,
SuccessResponse,
TransferCommunity,
} from "lemmy-js-client";
import { fetchLimit, relTags, trendingFetchLimit } from "../../config";
Expand Down Expand Up @@ -276,7 +275,6 @@ export class Home extends Component<any, HomeState> {
this.handleSavePost = this.handleSavePost.bind(this);
this.handlePurgePost = this.handlePurgePost.bind(this);
this.handleFeaturePost = this.handleFeaturePost.bind(this);
this.handleMarkPostAsRead = this.handleMarkPostAsRead.bind(this);

// Only fetch the data if coming from another route
if (FirstLoadService.isFirstLoad) {
Expand Down Expand Up @@ -713,7 +711,7 @@ export class Home extends Component<any, HomeState> {
onAddAdmin={this.handleAddAdmin}
onTransferCommunity={this.handleTransferCommunity}
onFeaturePost={this.handleFeaturePost}
onMarkPostAsRead={this.handleMarkPostAsRead}
onMarkPostAsRead={() => {}}
/>
);
}
Expand Down Expand Up @@ -1043,11 +1041,6 @@ export class Home extends Component<any, HomeState> {
this.updateBan(banRes);
}

async handleMarkPostAsRead(form: MarkPostAsRead) {
const res = await HttpService.client.markPostAsRead(form);
this.findAndUpdatePost(res);
}

updateBanFromCommunity(banRes: RequestState<BanFromCommunityResponse>) {
// Maybe not necessary
if (banRes.state === "success") {
Expand Down Expand Up @@ -1090,7 +1083,7 @@ export class Home extends Component<any, HomeState> {
}
}

purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
purgeItem(purgeRes: RequestState<SuccessResponse>) {
if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/person/inbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ import {
PrivateMessageView,
PrivateMessagesResponse,
PurgeComment,
PurgeItemResponse,
PurgePerson,
PurgePost,
RemoveComment,
SaveComment,
SuccessResponse,
TransferCommunity,
} from "lemmy-js-client";
import { fetchLimit, relTags } from "../../config";
Expand Down Expand Up @@ -1038,7 +1038,7 @@ export class Inbox extends Component<any, InboxState> {
}
}

purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
purgeItem(purgeRes: RequestState<SuccessResponse>) {
if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
Expand Down
10 changes: 4 additions & 6 deletions src/shared/components/person/password-change.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { setIsoData } from "@utils/app";
import { capitalizeFirstLetter } from "@utils/helpers";
import { Component, linkEvent } from "inferno";
import { GetSiteResponse, LoginResponse } from "lemmy-js-client";
import { GetSiteResponse, SuccessResponse } from "lemmy-js-client";
import { HttpService, I18NextService, UserService } from "../../services";
import {
EMPTY_REQUEST,
Expand All @@ -11,9 +11,10 @@ import {
import { HtmlTags } from "../common/html-tags";
import { Spinner } from "../common/icon";
import PasswordInput from "../common/password-input";
import { toast } from "../../toast";

interface State {
passwordChangeRes: RequestState<LoginResponse>;
passwordChangeRes: RequestState<SuccessResponse>;
form: {
token: string;
password?: string;
Expand Down Expand Up @@ -125,10 +126,7 @@ export class PasswordChange extends Component<any, State> {
});

if (i.state.passwordChangeRes.state === "success") {
const data = i.state.passwordChangeRes.data;
UserService.Instance.login({
res: data,
});
toast(I18NextService.i18n.t("password_changed"));

const site = await HttpService.client.getSite();
if (site.state === "success") {
Expand Down
13 changes: 3 additions & 10 deletions src/shared/components/person/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,17 @@ import {
LockPost,
MarkCommentReplyAsRead,
MarkPersonMentionAsRead,
MarkPostAsRead,
PersonView,
PostResponse,
PurgeComment,
PurgeItemResponse,
PurgePerson,
PurgePost,
RemoveComment,
RemovePost,
SaveComment,
SavePost,
SortType,
SuccessResponse,
TransferCommunity,
} from "lemmy-js-client";
import { fetchLimit, relTags } from "../../config";
Expand Down Expand Up @@ -222,7 +221,6 @@ export class Profile extends Component<
this.handlePurgePost = this.handlePurgePost.bind(this);
this.handleFeaturePost = this.handleFeaturePost.bind(this);
this.handleModBanSubmit = this.handleModBanSubmit.bind(this);
this.handleMarkPostAsRead = this.handleMarkPostAsRead.bind(this);

// Only fetch the data if coming from another route
if (FirstLoadService.isFirstLoad) {
Expand Down Expand Up @@ -378,7 +376,7 @@ export class Profile extends Component<
onSavePost={this.handleSavePost}
onPurgePost={this.handlePurgePost}
onFeaturePost={this.handleFeaturePost}
onMarkPostAsRead={this.handleMarkPostAsRead}
onMarkPostAsRead={() => {}}
/>
</div>

Expand Down Expand Up @@ -947,11 +945,6 @@ export class Profile extends Component<
await HttpService.client.markPersonMentionAsRead(form);
}

async handleMarkPostAsRead(form: MarkPostAsRead) {
const res = await HttpService.client.markPostAsRead(form);
this.findAndUpdatePost(res);
}

async handleBanFromCommunity(form: BanFromCommunity) {
const banRes = await HttpService.client.banFromCommunity(form);
this.updateBanFromCommunity(banRes);
Expand Down Expand Up @@ -1002,7 +995,7 @@ export class Profile extends Component<
}
}

purgeItem(purgeRes: RequestState<PurgeItemResponse>) {
purgeItem(purgeRes: RequestState<SuccessResponse>) {
if (purgeRes.state === "success") {
toast(I18NextService.i18n.t("purge_success"));
this.context.router.history.push(`/`);
Expand Down
15 changes: 3 additions & 12 deletions src/shared/components/person/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
BlockInstanceResponse,
BlockPersonResponse,
CommunityBlockView,
DeleteAccountResponse,
GenerateTotpSecretResponse,
GetFederatedInstancesResponse,
GetSiteResponse,
Expand All @@ -33,6 +32,7 @@ import {
LoginResponse,
PersonBlockView,
SortType,
SuccessResponse,
UpdateTotpResponse,
} from "lemmy-js-client";
import { elementUrl, emDash, relTags } from "../../config";
Expand Down Expand Up @@ -66,9 +66,9 @@ type SettingsData = RouteDataResponse<{
}>;

interface SettingsState {
saveRes: RequestState<LoginResponse>;
saveRes: RequestState<SuccessResponse>;
changePasswordRes: RequestState<LoginResponse>;
deleteAccountRes: RequestState<DeleteAccountResponse>;
deleteAccountRes: RequestState<SuccessResponse>;
instancesRes: RequestState<GetFederatedInstancesResponse>;
generateTotpRes: RequestState<GenerateTotpSecretResponse>;
updateTotpRes: RequestState<UpdateTotpResponse>;
Expand Down Expand Up @@ -1436,11 +1436,6 @@ export class Settings extends Component<any, SettingsState> {
});

if (saveRes.state === "success") {
UserService.Instance.login({
res: saveRes.data,
showToast: false,
});

const siteRes = await HttpService.client.getSite();

if (siteRes.state === "success") {
Expand Down Expand Up @@ -1471,10 +1466,6 @@ export class Settings extends Component<any, SettingsState> {
old_password,
});
if (changePasswordRes.state === "success") {
UserService.Instance.login({
res: changePasswordRes.data,
showToast: false,
});
window.scrollTo(0, 0);
toast(I18NextService.i18n.t("password_changed"));
}
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/person/verify-email.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setIsoData } from "@utils/app";
import { Component } from "inferno";
import { GetSiteResponse, VerifyEmailResponse } from "lemmy-js-client";
import { GetSiteResponse, SuccessResponse } from "lemmy-js-client";
import { I18NextService } from "../../services";
import {
EMPTY_REQUEST,
Expand All @@ -13,7 +13,7 @@ import { HtmlTags } from "../common/html-tags";
import { Spinner } from "../common/icon";

interface State {
verifyRes: RequestState<VerifyEmailResponse>;
verifyRes: RequestState<SuccessResponse>;
siteRes: GetSiteResponse;
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/components/post/post-report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class PostReport extends Component<PostReportProps, PostReportState> {
creator_blocked: false,
my_vote: r.my_vote,
unread_comments: 0,
creator_is_moderator: false,
};

return (
Expand Down
Loading