diff --git a/lemmy-translations b/lemmy-translations index 6b373bf76..abd40d473 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit 6b373bf7665ed58a81d8285009ad147248acfd7c +Subproject commit abd40d4737fa732321fd7b62e42bbfcd51081cb6 diff --git a/package.json b/package.json index 0ec4c20a5..0a3d97440 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/shared/components/comment/comment-report.tsx b/src/shared/components/comment/comment-report.tsx index d5d0bba73..8d2e04018 100644 --- a/src/shared/components/comment/comment-report.tsx +++ b/src/shared/components/comment/comment-report.tsx @@ -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, diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index 8f3c0bb57..021214b41 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -57,12 +57,10 @@ import { LockPost, MarkCommentReplyAsRead, MarkPersonMentionAsRead, - MarkPostAsRead, PaginationCursor, PostResponse, PurgeComment, PurgeCommunity, - PurgeItemResponse, PurgePerson, PurgePost, RemoveComment, @@ -71,6 +69,7 @@ import { SaveComment, SavePost, SortType, + SuccessResponse, TransferCommunity, } from "lemmy-js-client"; import { fetchLimit, relTags } from "../../config"; @@ -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) { @@ -436,7 +434,7 @@ export class Community extends Component< onAddAdmin={this.handleAddAdmin} onTransferCommunity={this.handleTransferCommunity} onFeaturePost={this.handleFeaturePost} - onMarkPostAsRead={this.handleMarkPostAsRead} + onMarkPostAsRead={() => {}} /> ); } @@ -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); @@ -882,7 +875,7 @@ export class Community extends Component< }); } - purgeItem(purgeRes: RequestState) { + purgeItem(purgeRes: RequestState) { if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx index a799b455f..26a49fe2b 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -359,7 +359,7 @@ export class AdminSettings extends Component { async handleDeleteEmoji(form: DeleteCustomEmoji) { const res = await HttpService.client.deleteCustomEmoji(form); if (res.state === "success") { - removeFromEmojiDataModel(res.data.id); + removeFromEmojiDataModel(form.id); } } diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 257f46c73..cac283ab8 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -58,11 +58,9 @@ import { LockPost, MarkCommentReplyAsRead, MarkPersonMentionAsRead, - MarkPostAsRead, PaginationCursor, PostResponse, PurgeComment, - PurgeItemResponse, PurgePerson, PurgePost, RemoveComment, @@ -70,6 +68,7 @@ import { SaveComment, SavePost, SortType, + SuccessResponse, TransferCommunity, } from "lemmy-js-client"; import { fetchLimit, relTags, trendingFetchLimit } from "../../config"; @@ -276,7 +275,6 @@ export class Home 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); // Only fetch the data if coming from another route if (FirstLoadService.isFirstLoad) { @@ -713,7 +711,7 @@ export class Home extends Component { onAddAdmin={this.handleAddAdmin} onTransferCommunity={this.handleTransferCommunity} onFeaturePost={this.handleFeaturePost} - onMarkPostAsRead={this.handleMarkPostAsRead} + onMarkPostAsRead={() => {}} /> ); } @@ -1043,11 +1041,6 @@ export class Home extends Component { this.updateBan(banRes); } - async handleMarkPostAsRead(form: MarkPostAsRead) { - const res = await HttpService.client.markPostAsRead(form); - this.findAndUpdatePost(res); - } - updateBanFromCommunity(banRes: RequestState) { // Maybe not necessary if (banRes.state === "success") { @@ -1090,7 +1083,7 @@ export class Home extends Component { } } - purgeItem(purgeRes: RequestState) { + purgeItem(purgeRes: RequestState) { if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); diff --git a/src/shared/components/person/inbox.tsx b/src/shared/components/person/inbox.tsx index d1237e7b8..02b3b63d9 100644 --- a/src/shared/components/person/inbox.tsx +++ b/src/shared/components/person/inbox.tsx @@ -52,11 +52,11 @@ import { PrivateMessageView, PrivateMessagesResponse, PurgeComment, - PurgeItemResponse, PurgePerson, PurgePost, RemoveComment, SaveComment, + SuccessResponse, TransferCommunity, } from "lemmy-js-client"; import { fetchLimit, relTags } from "../../config"; @@ -1038,7 +1038,7 @@ export class Inbox extends Component { } } - purgeItem(purgeRes: RequestState) { + purgeItem(purgeRes: RequestState) { if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); diff --git a/src/shared/components/person/password-change.tsx b/src/shared/components/person/password-change.tsx index 8fc8078d0..2d3d3df2e 100644 --- a/src/shared/components/person/password-change.tsx +++ b/src/shared/components/person/password-change.tsx @@ -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, @@ -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; + passwordChangeRes: RequestState; form: { token: string; password?: string; @@ -125,10 +126,7 @@ export class PasswordChange extends Component { }); 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") { diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index 37477105d..d1e813cc7 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -58,11 +58,9 @@ import { LockPost, MarkCommentReplyAsRead, MarkPersonMentionAsRead, - MarkPostAsRead, PersonView, PostResponse, PurgeComment, - PurgeItemResponse, PurgePerson, PurgePost, RemoveComment, @@ -70,6 +68,7 @@ import { SaveComment, SavePost, SortType, + SuccessResponse, TransferCommunity, } from "lemmy-js-client"; import { fetchLimit, relTags } from "../../config"; @@ -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) { @@ -378,7 +376,7 @@ export class Profile extends Component< onSavePost={this.handleSavePost} onPurgePost={this.handlePurgePost} onFeaturePost={this.handleFeaturePost} - onMarkPostAsRead={this.handleMarkPostAsRead} + onMarkPostAsRead={() => {}} /> @@ -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); @@ -1002,7 +995,7 @@ export class Profile extends Component< } } - purgeItem(purgeRes: RequestState) { + purgeItem(purgeRes: RequestState) { if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx index 2e74aa09b..c7dabb982 100644 --- a/src/shared/components/person/settings.tsx +++ b/src/shared/components/person/settings.tsx @@ -23,7 +23,6 @@ import { BlockInstanceResponse, BlockPersonResponse, CommunityBlockView, - DeleteAccountResponse, GenerateTotpSecretResponse, GetFederatedInstancesResponse, GetSiteResponse, @@ -33,6 +32,7 @@ import { LoginResponse, PersonBlockView, SortType, + SuccessResponse, UpdateTotpResponse, } from "lemmy-js-client"; import { elementUrl, emDash, relTags } from "../../config"; @@ -66,9 +66,9 @@ type SettingsData = RouteDataResponse<{ }>; interface SettingsState { - saveRes: RequestState; + saveRes: RequestState; changePasswordRes: RequestState; - deleteAccountRes: RequestState; + deleteAccountRes: RequestState; instancesRes: RequestState; generateTotpRes: RequestState; updateTotpRes: RequestState; @@ -1436,11 +1436,6 @@ export class Settings extends Component { }); if (saveRes.state === "success") { - UserService.Instance.login({ - res: saveRes.data, - showToast: false, - }); - const siteRes = await HttpService.client.getSite(); if (siteRes.state === "success") { @@ -1471,10 +1466,6 @@ export class Settings extends Component { old_password, }); if (changePasswordRes.state === "success") { - UserService.Instance.login({ - res: changePasswordRes.data, - showToast: false, - }); window.scrollTo(0, 0); toast(I18NextService.i18n.t("password_changed")); } diff --git a/src/shared/components/person/verify-email.tsx b/src/shared/components/person/verify-email.tsx index 35bece5ff..e8f116c48 100644 --- a/src/shared/components/person/verify-email.tsx +++ b/src/shared/components/person/verify-email.tsx @@ -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, @@ -13,7 +13,7 @@ import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; interface State { - verifyRes: RequestState; + verifyRes: RequestState; siteRes: GetSiteResponse; } diff --git a/src/shared/components/post/post-report.tsx b/src/shared/components/post/post-report.tsx index ea3b68cfb..a215e646b 100644 --- a/src/shared/components/post/post-report.tsx +++ b/src/shared/components/post/post-report.tsx @@ -56,6 +56,7 @@ export class PostReport extends Component { creator_blocked: false, my_vote: r.my_vote, unread_comments: 0, + creator_is_moderator: false, }; return ( diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 519bff48c..73fcfb6ac 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -61,12 +61,9 @@ import { GetSiteResponse, LockPost, MarkCommentReplyAsRead, - MarkPersonMentionAsRead, - MarkPostAsRead, PostResponse, PurgeComment, PurgeCommunity, - PurgeItemResponse, PurgePerson, PurgePost, RemoveComment, @@ -74,6 +71,7 @@ import { RemovePost, SaveComment, SavePost, + SuccessResponse, TransferCommunity, } from "lemmy-js-client"; import { commentTreeMaxDepth } from "../../config"; @@ -164,7 +162,6 @@ export class Post extends Component { this.handleTransferCommunity = this.handleTransferCommunity.bind(this); this.handleFetchChildren = this.handleFetchChildren.bind(this); this.handleCommentReplyRead = this.handleCommentReplyRead.bind(this); - this.handlePersonMentionRead = this.handlePersonMentionRead.bind(this); this.handleBanFromCommunity = this.handleBanFromCommunity.bind(this); this.handleBanPerson = this.handleBanPerson.bind(this); this.handlePostEdit = this.handlePostEdit.bind(this); @@ -176,7 +173,6 @@ export class Post 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.state = { ...this.state, commentSectionRef: createRef() }; @@ -387,7 +383,7 @@ export class Post extends Component { onAddAdmin={this.handleAddAdmin} onTransferCommunity={this.handleTransferCommunity} onFeaturePost={this.handleFeaturePost} - onMarkPostAsRead={this.handleMarkPostAsRead} + onMarkPostAsRead={() => {}} />
@@ -589,7 +585,7 @@ export class Post extends Component { onPurgeComment={this.handlePurgeComment} onPurgePerson={this.handlePurgePerson} onCommentReplyRead={this.handleCommentReplyRead} - onPersonMentionRead={this.handlePersonMentionRead} + onPersonMentionRead={() => {}} onBanPersonFromCommunity={this.handleBanFromCommunity} onBanPerson={this.handleBanPerson} onCreateComment={this.handleCreateComment} @@ -676,7 +672,7 @@ export class Post extends Component { onPurgeComment={this.handlePurgeComment} onPurgePerson={this.handlePurgePerson} onCommentReplyRead={this.handleCommentReplyRead} - onPersonMentionRead={this.handlePersonMentionRead} + onPersonMentionRead={() => {}} onBanPersonFromCommunity={this.handleBanFromCommunity} onBanPerson={this.handleBanPerson} onCreateComment={this.handleCreateComment} @@ -936,16 +932,6 @@ export class Post extends Component { this.findAndUpdateCommentReply(readRes); } - async handlePersonMentionRead(form: MarkPersonMentionAsRead) { - // TODO not sure what to do here. Maybe it is actually optional, because post doesn't need it. - await HttpService.client.markPersonMentionAsRead(form); - } - - async handleMarkPostAsRead(form: MarkPostAsRead) { - const res = await HttpService.client.markPostAsRead(form); - this.updatePost(res); - } - async handleBanFromCommunity(form: BanFromCommunity) { const banRes = await HttpService.client.banFromCommunity(form); this.updateBan(banRes); @@ -1029,7 +1015,7 @@ export class Post extends Component { }); } - purgeItem(purgeRes: RequestState) { + purgeItem(purgeRes: RequestState) { if (purgeRes.state === "success") { toast(I18NextService.i18n.t("purge_success")); this.context.router.history.push(`/`); diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 46bb51198..2b90da51f 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -665,10 +665,10 @@ export class Search extends Component { Number( ((b.data as CommentView | PostView).counts.score | (b.data as CommunityView).counts.subscribers | - (b.data as PersonView).counts.comment_score) - + (b.data as PersonView).counts.comment_count) - ((a.data as CommentView | PostView).counts.score | (a.data as CommunityView).counts.subscribers | - (a.data as PersonView).counts.comment_score), + (a.data as PersonView).counts.comment_count), ), ); } diff --git a/src/shared/services/UserService.ts b/src/shared/services/UserService.ts index 3e459a1ac..c53ca1fae 100644 --- a/src/shared/services/UserService.ts +++ b/src/shared/services/UserService.ts @@ -35,9 +35,6 @@ export class UserService { res: LoginResponse; showToast?: boolean; }) { - const expires = new Date(); - expires.setDate(expires.getDate() + 365); - if (isBrowser() && res.jwt) { showToast && toast(I18NextService.i18n.t("logged_in")); setAuthCookie(res.jwt); @@ -53,6 +50,8 @@ export class UserService { clearAuthCookie(); } + HttpService.client.logout(); + if (isAuthPath(location.pathname)) { location.replace("/"); } else { diff --git a/yarn.lock b/yarn.lock index 6e2b5c79a..ec0f69886 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6069,10 +6069,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.14: - version "0.19.0-rc.14" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.19.0-rc.14.tgz#41885611c2d78e5cb6b01cf167d68205a471c215" - integrity sha512-U0KKFLrU0K+A7UlZr+k4olrXCXBxD+9cwMicu7L/wFyZ2aWHtGPaeO8V6mk6suv9vn2w2PWuimIIC+YICQ5xKg== +lemmy-js-client@0.19.0-alpha.16: + version "0.19.0-alpha.16" + resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.19.0-alpha.16.tgz#4ec26e393856db7ddf86dba83f24633eeacee7c4" + integrity sha512-pmfrkPrHBkhEFhw/BDiTPy2/aQLoURLwBftMa4Lc+ZYiRfVClCOPkbKiqDSYXYlWcPz5MtwM/bjSNxasvVHfTA== dependencies: cross-fetch "^3.1.5" form-data "^4.0.0"