From fec9200bd66f7e24aabd89fcab06b1fa42d80468 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 16 Feb 2023 21:10:03 -0500 Subject: [PATCH 01/30] Fix issue with empty markdown content not nulling DB. Fixes #924 (#925) * Fix issue with empty markdown content not nulling DB. Fixes #924 * Better syntax --- src/shared/components/common/markdown-textarea.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 9b51a7ebf..48b90428b 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -390,9 +390,9 @@ export class MarkdownTextArea extends Component< } contentChange() { - if (this.state.content) { - this.props.onContentChange?.(this.state.content); - } + // Coerces the undefineds to empty strings, for replacing in the DB + let content = this.state.content ?? ""; + this.props.onContentChange?.(content); } handleContentChange(i: MarkdownTextArea, event: any) { From a5569bb470a99f184a69b7c12419a96bfffd0c96 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 21 Feb 2023 15:52:12 -0500 Subject: [PATCH 02/30] Remove buggy navbar search. Fixes #921 (#950) --- src/assets/css/main.css | 10 --- src/shared/components/app/navbar.tsx | 64 ++-------------- src/shared/components/search.tsx | 109 +++++++++++++++------------ 3 files changed, 66 insertions(+), 117 deletions(-) diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 98e98d267..766c9dbd1 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -305,16 +305,6 @@ pre { transition: width 0.2s ease-out 0s !important; } -.show-input { - width: 13vw !important; -} -.hide-input { - background: transparent !important; - background-color: transparent !important; - width: 0px !important; - padding: 0 !important; -} - br.big { display: block; content: ""; diff --git a/src/shared/components/app/navbar.tsx b/src/shared/components/app/navbar.tsx index d758af60f..4d0b88fdc 100644 --- a/src/shared/components/app/navbar.tsx +++ b/src/shared/components/app/navbar.tsx @@ -1,4 +1,4 @@ -import { Component, createRef, linkEvent, RefObject } from "inferno"; +import { Component, linkEvent } from "inferno"; import { NavLink } from "inferno-router"; import { CommentResponse, @@ -44,7 +44,6 @@ interface NavbarState { unreadReportCount: number; unreadApplicationCount: number; searchParam: string; - toggleSearch: boolean; showDropdown: boolean; onSiteBanner?(url: string): any; } @@ -55,14 +54,12 @@ export class Navbar extends Component { private unreadInboxCountSub: Subscription; private unreadReportCountSub: Subscription; private unreadApplicationCountSub: Subscription; - private searchTextField: RefObject; state: NavbarState = { unreadInboxCount: 0, unreadReportCount: 0, unreadApplicationCount: 0, expanded: false, searchParam: "", - toggleSearch: false, showDropdown: false, }; subscription: any; @@ -77,8 +74,6 @@ export class Navbar extends Component { componentDidMount() { // Subscribe to jwt changes if (isBrowser()) { - this.searchTextField = createRef(); - // On the first load, check the unreads let auth = myAuth(false); if (auth && UserService.Instance.myUserInfo) { @@ -123,7 +118,6 @@ export class Navbar extends Component { updateUrl() { const searchParam = this.state.searchParam; this.setState({ searchParam: "" }); - this.setState({ toggleSearch: false }); this.setState({ showDropdown: false, expanded: false }); if (searchParam === "") { this.context.router.history.push(`/search/`); @@ -308,35 +302,13 @@ export class Navbar extends Component { ) && (
  • -
    - - - -
    + +
)} @@ -520,28 +492,6 @@ export class Navbar extends Component { i.setState({ searchParam: event.target.value }); } - handleSearchSubmit(i: Navbar, event: any) { - event.preventDefault(); - i.updateUrl(); - } - - handleSearchBtn(i: Navbar, event: any) { - event.preventDefault(); - i.setState({ toggleSearch: true }); - - i.searchTextField.current?.focus(); - const offsetWidth = i.searchTextField.current?.offsetWidth; - if (i.state.searchParam && offsetWidth && offsetWidth > 100) { - i.updateUrl(); - } - } - - handleSearchBlur(i: Navbar, event: any) { - if (!(event.relatedTarget && event.relatedTarget.name !== "search-btn")) { - i.setState({ toggleSearch: false }); - } - } - handleLogoutClick(i: Navbar) { i.setState({ showDropdown: false, expanded: false }); UserService.Instance.logout(); diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 102e0fcae..b96e1c5ce 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -75,7 +75,7 @@ if (isBrowser()) { } interface SearchProps { - q: string; + q?: string; type_: SearchType; sort: SortType; listingType: ListingType; @@ -85,7 +85,7 @@ interface SearchProps { } interface SearchState { - q: string; + q?: string; type_: SearchType; sort: SortType; listingType: ListingType; @@ -97,7 +97,7 @@ interface SearchState { creatorDetails?: GetPersonDetailsResponse; loading: boolean; siteRes: GetSiteResponse; - searchText: string; + searchText?: string; resolveObjectResponse?: ResolveObjectResponse; } @@ -135,13 +135,13 @@ export class Search extends Component { this.props.match.params.community_id ), creatorId: Search.getCreatorIdFromProps(this.props.match.params.creator_id), - loading: true, + loading: false, siteRes: this.isoData.site_res, communities: [], }; - static getSearchQueryFromProps(q: string): string { - return decodeURIComponent(q) || ""; + static getSearchQueryFromProps(q?: string): string | undefined { + return q ? decodeURIComponent(q) : undefined; } static getSearchTypeFromProps(type_: string): SearchType { @@ -219,7 +219,10 @@ export class Search extends Component { } } else { this.fetchCommunities(); - this.search(); + + if (this.state.q) { + this.search(); + } } } @@ -298,29 +301,33 @@ export class Search extends Component { promises.push(Promise.resolve()); } - let form: SearchForm = { - q: this.getSearchQueryFromProps(pathSplit[3]), - community_id, - creator_id, - type_: this.getSearchTypeFromProps(pathSplit[5]), - sort: this.getSortTypeFromProps(pathSplit[7]), - listing_type: this.getListingTypeFromProps(pathSplit[9]), - page: this.getPageFromProps(pathSplit[15]), - limit: fetchLimit, - auth: req.auth, - }; + let q = this.getSearchQueryFromProps(pathSplit[3]); + + if (q) { + let form: SearchForm = { + q, + community_id, + creator_id, + type_: this.getSearchTypeFromProps(pathSplit[5]), + sort: this.getSortTypeFromProps(pathSplit[7]), + listing_type: this.getListingTypeFromProps(pathSplit[9]), + page: this.getPageFromProps(pathSplit[15]), + limit: fetchLimit, + auth: req.auth, + }; - let resolveObjectForm: ResolveObject = { - q: this.getSearchQueryFromProps(pathSplit[3]), - auth: req.auth, - }; + let resolveObjectForm: ResolveObject = { + q, + auth: req.auth, + }; - if (form.q != "") { - promises.push(req.client.search(form)); - promises.push(req.client.resolveObject(resolveObjectForm)); - } else { - promises.push(Promise.resolve()); - promises.push(Promise.resolve()); + if (form.q != "") { + promises.push(req.client.search(form)); + promises.push(req.client.resolveObject(resolveObjectForm)); + } else { + promises.push(Promise.resolve()); + promises.push(Promise.resolve()); + } } return promises; @@ -336,11 +343,13 @@ export class Search extends Component { lastState.creatorId !== this.state.creatorId || lastState.page !== this.state.page ) { - this.setState({ - loading: true, - searchText: this.state.q, - }); - this.search(); + if (this.state.q) { + this.setState({ + loading: true, + searchText: this.state.q, + }); + this.search(); + } } } @@ -779,24 +788,24 @@ export class Search extends Component { this.state.creatorId == 0 ? undefined : this.state.creatorId; let auth = myAuth(false); - let form: SearchForm = { - q: this.state.q, - community_id, - creator_id, - type_: this.state.type_, - sort: this.state.sort, - listing_type: this.state.listingType, - page: this.state.page, - limit: fetchLimit, - auth, - }; + if (this.state.q && this.state.q != "") { + let form: SearchForm = { + q: this.state.q, + community_id, + creator_id, + type_: this.state.type_, + sort: this.state.sort, + listing_type: this.state.listingType, + page: this.state.page, + limit: fetchLimit, + auth, + }; - let resolveObjectForm: ResolveObject = { - q: this.state.q, - auth, - }; + let resolveObjectForm: ResolveObject = { + q: this.state.q, + auth, + }; - if (this.state.q != "") { this.setState({ searchResponse: undefined, resolveObjectResponse: undefined, @@ -919,7 +928,7 @@ export class Search extends Component { updateUrl(paramUpdates: UrlParams) { const qStr = paramUpdates.q || this.state.q; - const qStrEncoded = encodeURIComponent(qStr); + const qStrEncoded = encodeURIComponent(qStr || ""); const typeStr = paramUpdates.type_ || this.state.type_; const listingTypeStr = paramUpdates.listingType || this.state.listingType; const sortStr = paramUpdates.sort || this.state.sort; From b9fbfab0c2869584dbe89da1971fe218497cb832 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 21 Feb 2023 15:52:57 -0500 Subject: [PATCH 03/30] Do local community checks for buttons. Fixes #918 (#948) --- .../components/comment/comment-node.tsx | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index 50da45614..6f903b48a 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -163,27 +163,29 @@ export class CommentNode extends Component { ? i18n.t("purge_comment") : `${i18n.t("purge")} ${cv.creator.name}`; - let canMod_ = canMod( - cv.creator.id, - this.props.moderators, - this.props.admins - ); - let canModOnSelf = canMod( - cv.creator.id, - this.props.moderators, - this.props.admins, - UserService.Instance.myUserInfo, - true - ); - let canAdmin_ = canAdmin(cv.creator.id, this.props.admins); - let canAdminOnSelf = canAdmin( - cv.creator.id, - this.props.admins, - UserService.Instance.myUserInfo, - true - ); + let canMod_ = + canMod(cv.creator.id, this.props.moderators, this.props.admins) && + cv.community.local; + let canModOnSelf = + canMod( + cv.creator.id, + this.props.moderators, + this.props.admins, + UserService.Instance.myUserInfo, + true + ) && cv.community.local; + let canAdmin_ = + canAdmin(cv.creator.id, this.props.admins) && cv.community.local; + let canAdminOnSelf = + canAdmin( + cv.creator.id, + this.props.admins, + UserService.Instance.myUserInfo, + true + ) && cv.community.local; let isMod_ = isMod(cv.creator.id, this.props.moderators); - let isAdmin_ = isAdmin(cv.creator.id, this.props.admins); + let isAdmin_ = + isAdmin(cv.creator.id, this.props.admins) && cv.community.local; let amCommunityCreator_ = amCommunityCreator( cv.creator.id, this.props.moderators From 7721d41f6da291f6b8c8588cb96580940b002121 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 21 Feb 2023 15:53:15 -0500 Subject: [PATCH 04/30] Fixing line formatting. (#947) --- src/shared/components/post/post-listing.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index f8140c3e9..7580daf37 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -434,15 +434,18 @@ export class PostListing extends Component { let post = this.props.post_view.post; return ( -
+
); } @@ -457,16 +460,19 @@ export class PostListing extends Component { {url ? ( this.props.showBody ? ( -
+
) : ( this.postLink @@ -477,7 +483,7 @@ export class PostListing extends Component { {(url && isImage(url)) || (post.thumbnail_url && ( -
- )} +
+
+ {i18n.t("undetermined_language_warning")} +
+
+ +
+ {this.selectBtn} + {this.props.multiple && ( +
+ +
+ )} +
); From 0375d71cceb990902ee934b019b5d0c8a544f9d1 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 21 Feb 2023 15:53:51 -0500 Subject: [PATCH 06/30] Let any mod feature and lock posts. Fixes #875 (#944) * Let any mod feature and lock posts. Fixes #875 * Change to amAdmin --- src/shared/components/post/post-listing.tsx | 55 ++++++++++++--------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 7580daf37..d0e72e4da 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -30,6 +30,7 @@ import { UserService, WebSocketService } from "../../services"; import { amAdmin, amCommunityCreator, + amMod, canAdmin, canMod, futureDaysToUnixTime, @@ -614,7 +615,8 @@ export class PostListing extends Component { {this.state.showAdvanced && ( <> {this.showBody && post_view.post.body && this.viewSourceButton} - {this.canModOnSelf_ && ( + {/* Any mod can do these, not limited to hierarchy*/} + {(amMod(this.props.moderators) || amAdmin()) && ( <> {this.lockButton} {this.featureButton} @@ -848,41 +850,40 @@ export class PostListing extends Component { } get featureButton() { - const featured_community = this.props.post_view.post.featured_community; - const label_community = featured_community + const featuredCommunity = this.props.post_view.post.featured_community; + const labelCommunity = featuredCommunity ? i18n.t("unfeature_from_community") : i18n.t("feature_in_community"); - const is_admin = amAdmin(); - const featured_local = this.props.post_view.post.featured_local; - const label_local = featured_local + const featuredLocal = this.props.post_view.post.featured_local; + const labelLocal = featuredLocal ? i18n.t("unfeature_from_local") : i18n.t("feature_in_local"); return ( - {is_admin && ( + {amAdmin() && (
+
+
+
+ + +
+
+
+ {!UserService.Instance.myUserInfo && ( +
+ {i18n.t("profile_not_logged_in_alert")} +
+ )}
diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index c1d282e92..b5b391e43 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -1,4 +1,5 @@ import { Component } from "inferno"; +import { Redirect } from "inferno-router"; import { GetCommunity, GetCommunityResponse, @@ -53,11 +54,6 @@ export class CreatePost extends Component { this.parseMessage = this.parseMessage.bind(this); this.subscription = wsSubscribe(this.parseMessage); - if (!UserService.Instance.myUserInfo && isBrowser()) { - toast(i18n.t("not_logged_in"), "danger"); - this.context.router.history.push(`/login`); - } - // Only fetch the data if coming from another route if (this.isoData.path == this.context.router.route.match.url) { this.state = { @@ -117,6 +113,7 @@ export class CreatePost extends Component { let res = this.state.listCommunitiesResponse; return (
+ {!UserService.Instance.myUserInfo && } { url: urlParams.get("url") ?? undefined, }; - return params; + const locationState = this.props.history.location.state as + | PostFormParams + | undefined; + + this.props.history.replace( + `/create_post${getQueryString(queryParams)}`, + locationState + ); + + this.fetchCommunity(); } get prevCommunityName(): string | undefined { From 8fe83a2594c46051a354106cc24f468ed9df4588 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Thu, 4 May 2023 01:47:37 +0000 Subject: [PATCH 17/30] Get rid of "No Results" showing while search is still loading. (#997) --- src/shared/components/search.tsx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index b96e1c5ce..41e95cfcb 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -368,16 +368,13 @@ export class Search extends Component { path={this.context.router.route.match.url} />
{i18n.t("search")}
- {this.selects()} - {this.searchForm()} - {this.state.type_ == SearchType.All && this.all()} - {this.state.type_ == SearchType.Comments && this.comments()} - {this.state.type_ == SearchType.Posts && this.posts()} - {this.state.type_ == SearchType.Communities && this.communities()} - {this.state.type_ == SearchType.Users && this.users()} - {this.state.type_ == SearchType.Url && this.posts()} - {this.resultsCount() == 0 && {i18n.t("no_results")}} - + {this.selects} + {this.searchForm} + {this.displayResults(type)} + {this.resultsCount === 0 && !this.state.searchLoading && ( + {i18n.t("no_results")} + )} +
); } @@ -988,8 +985,8 @@ export class Search extends Component { } checkFinishedLoading() { - if (this.state.searchResponse && this.state.resolveObjectResponse) { - this.setState({ loading: false }); + if (this.state.searchResponse || this.state.resolveObjectResponse) { + this.setState({ searchLoading: false }); } } } From d52c5491dcfb6827c31b55fb2551bb3138941003 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Thu, 4 May 2023 02:06:59 +0000 Subject: [PATCH 18/30] Add content warning to modlog and fix modlog routing bug (#994) * Add content warning to modlog and fix modlog routing bug * Add translation logic --- src/assets/css/main.css | 49 +++++++++++++++++++ .../components/common/markdown-textarea.tsx | 6 +-- src/shared/components/community/sidebar.tsx | 2 +- src/shared/components/modlog.tsx | 18 ++++++- src/shared/components/post/create-post.tsx | 11 +---- src/shared/components/post/post-form.tsx | 6 +-- src/shared/components/search.tsx | 17 ++++--- src/shared/routes.ts | 2 +- 8 files changed, 86 insertions(+), 25 deletions(-) diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 766c9dbd1..b98182343 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -129,10 +129,52 @@ user-select: none; } +.icon-emoji { + width: 4em; + height: auto; + max-height: inherit; +} + +.icon-emoji-admin { + max-width: 24px; + max-height: 24px; + display: inline-block; +} + .icon-inline { margin-bottom: 2px; } +.emoji-picker-container { + position: absolute; + top: 30px; + z-index: 1000; + transform: translateX(-50%); +} + +@media only screen and (max-width: 992px) { + .emoji-picker-container { + width: 100vw; + transform: translateX(0%); + position: fixed; + left: 0; + } + + .emoji-picker-container > section { + width: 100% !important; + } +} + +.click-away-container { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.3); + z-index: 999; +} + .spinner-large { display: grid; display: block; @@ -209,6 +251,10 @@ hr { text-overflow: ellipsis; } +.text-xs-center { + text-align: center; +} + .overflow-wrap-anywhere { overflow-wrap: anywhere; } @@ -384,3 +430,6 @@ br.big { .lang-select-action:focus { width: auto; } +em-emoji-picker { + width: 100%; +} diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 48b90428b..322958927 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -372,9 +372,9 @@ export class MarkdownTextArea extends Component< let textarea: any = document.getElementById(i.id); autosize.update(textarea); pictrsDeleteToast( - `${i18n.t("click_to_delete_picture")}: ${file.name}`, - `${i18n.t("picture_deleted")}: ${file.name}`, - `${i18n.t("failed_to_delete_picture")}: ${file.name}`, + i18n.t("click_to_delete_picture", file.name), + i18n.t("picture_deleted", file.name), + i18n.t("failed_to_delete_picture", file.name), deleteUrl ); } else { diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index 9862d9ed1..601895ad6 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -262,7 +262,7 @@ export class Sidebar extends Component {
  • {i18n.t("modlog")} diff --git a/src/shared/components/modlog.tsx b/src/shared/components/modlog.tsx index 140d56a80..e5e4ee2a2 100644 --- a/src/shared/components/modlog.tsx +++ b/src/shared/components/modlog.tsx @@ -1,4 +1,5 @@ import { Component, linkEvent } from "inferno"; +import { T } from "inferno-i18next-dess"; import { Link } from "inferno-router"; import { AdminPurgeCommentView, @@ -47,7 +48,7 @@ import { wsSubscribe, } from "../utils"; import { HtmlTags } from "./common/html-tags"; -import { Spinner } from "./common/icon"; +import { Icon, Spinner } from "./common/icon"; import { MomentTime } from "./common/moment-time"; import { Paginator } from "./common/paginator"; import { CommunityLink } from "./community/community-link"; @@ -604,6 +605,21 @@ export class Modlog extends Component { title={this.documentTitle} path={this.context.router.route.match.url} /> +
    +
    + + + ### + +
    +
    {this.state.loading ? (
    diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index b5b391e43..709e26a84 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -163,16 +163,7 @@ export class CreatePost extends Component { url: urlParams.get("url") ?? undefined, }; - const locationState = this.props.history.location.state as - | PostFormParams - | undefined; - - this.props.history.replace( - `/create_post${getQueryString(queryParams)}`, - locationState - ); - - this.fetchCommunity(); + return params; } get prevCommunityName(): string | undefined { diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index 490f7dcd9..13b593065 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -608,9 +608,9 @@ export class PostForm extends Component { i.state.form.url = url; i.setState({ imageLoading: false }); pictrsDeleteToast( - `${i18n.t("click_to_delete_picture")}: ${file.name}`, - `${i18n.t("picture_deleted")}: ${file.name}`, - `${i18n.t("failed_to_delete_picture")}: ${file.name}`, + i18n.t("click_to_delete_picture", file.name), + i18n.t("picture_deleted", file.name), + i18n.t("failed_to_delete_picture", file.name), deleteUrl ); } else { diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 41e95cfcb..c0f08996e 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -368,13 +368,18 @@ export class Search extends Component { path={this.context.router.route.match.url} />
    {i18n.t("search")}
    - {this.selects} - {this.searchForm} - {this.displayResults(type)} - {this.resultsCount === 0 && !this.state.searchLoading && ( + {this.selects()} + {this.searchForm()} + {this.state.type_ == SearchType.All && this.all()} + {this.state.type_ == SearchType.Comments && this.comments()} + {this.state.type_ == SearchType.Posts && this.posts()} + {this.state.type_ == SearchType.Communities && this.communities()} + {this.state.type_ == SearchType.Users && this.users()} + {this.state.type_ == SearchType.Url && this.posts()} + {this.resultsCount() === 0 && !this.state.loading && ( {i18n.t("no_results")} )} - + ); } @@ -986,7 +991,7 @@ export class Search extends Component { checkFinishedLoading() { if (this.state.searchResponse || this.state.resolveObjectResponse) { - this.setState({ searchLoading: false }); + this.setState({ loading: false }); } } } diff --git a/src/shared/routes.ts b/src/shared/routes.ts index b4404a798..ee7a32df9 100644 --- a/src/shared/routes.ts +++ b/src/shared/routes.ts @@ -114,7 +114,7 @@ export const routes: IRoutePropsWithFetch[] = [ component: Settings, }, { - path: `/modlog/community/:community_id`, + path: `/modlog/:communityId`, component: Modlog, fetchInitialData: req => Modlog.fetchInitialData(req), }, From c2325ba743f5a99097930996742263fb60a433f8 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 21 Feb 2023 15:53:35 -0500 Subject: [PATCH 19/30] Adding a warning for deselecting the undetermined language. (#945) - Fixes #930 --- src/shared/components/common/language-select.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/shared/components/common/language-select.tsx b/src/shared/components/common/language-select.tsx index 64cbac498..d98be2e29 100644 --- a/src/shared/components/common/language-select.tsx +++ b/src/shared/components/common/language-select.tsx @@ -48,11 +48,9 @@ export class LanguageSelect extends Component { this.selectBtn ) : (
    - {this.props.multiple && ( -
    - {i18n.t("undetermined_language_warning")} -
    - )} +
    + {i18n.t("undetermined_language_warning")} +
  • + + { + this.props.allLanguages.find( + lang => lang.id === post_view.post.language_id + )?.name + } +
  • {url && !(hostname(url) == externalHost) && ( <> From d6d249c7a6dfb73e442d12b446f3f8f35213ef81 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Fri, 12 May 2023 03:15:04 +0200 Subject: [PATCH 23/30] Remove "banned" badge from posts and comments (fixes 899) (#1011) It doesnt need to be emphasized so much that a user is banned. Anyway this can already be seen in the mod log. For users who are banned from the entire site it is still shown on the profile. Co-authored-by: Dessalines --- src/shared/components/comment/comment-node.tsx | 5 ----- src/shared/components/post/post-listing.tsx | 7 ------- 2 files changed, 12 deletions(-) diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index 78f31884b..a1aefc671 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -257,11 +257,6 @@ export class CommentNode extends Component { {i18n.t("bot_account").toLowerCase()} )} - {(cv.creator_banned_from_community || isBanned(cv.creator)) && ( -
    - {i18n.t("banned")} -
    - )} {this.props.showCommunity && ( <> {i18n.t("to")} diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index d4fa7d857..acc64c2bc 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -335,13 +335,6 @@ export class PostListing extends Component { {i18n.t("bot_account").toLowerCase()} )} - {(post_view.creator_banned_from_community || - isBanned(post_view.creator)) && ( - {i18n.t("banned")} - )} - {post_view.creator_blocked && ( - {"blocked"} - )} {this.props.showCommunity && ( {i18n.t("to")} From ade413c2992ece3bfc625a2aeb18404f18701fdb Mon Sep 17 00:00:00 2001 From: Nutomic Date: Sat, 13 May 2023 22:07:05 +0200 Subject: [PATCH 24/30] Dont preselect new post language (#1008) Lemmy-ui currently preselects the first language in the user settings when creating a new post or comment. This is a bad idea because this language might not actually be allowed in the community. It is better to pass the language as None if the user didnt specify it explicitly, because then the backend can smartly choose a language based on the overlap of user languages and community languages. This fixes the problem described in [this thread](https://lemmy.ml/post/1066608), where a user tries to post in a community that has only English allowed, with all languages enabled in user settings. In this case lemmy-ui preselects "undetermined language" as default, which is not allowed and results in an error. This PR fixes the issue because it lets the backend automatically select the correct language (English). --- lemmy-translations | 2 +- src/shared/components/comment/comment-form.tsx | 11 ----------- src/shared/components/common/language-select.tsx | 5 +++++ src/shared/components/post/post-form.tsx | 9 +-------- src/shared/utils.ts | 14 -------------- 5 files changed, 7 insertions(+), 34 deletions(-) diff --git a/lemmy-translations b/lemmy-translations index 3ad48e2c3..a1fff8b48 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit 3ad48e2c3cb444c76399aa31d50a13f7571e4aab +Subproject commit a1fff8b481f4b02327e4ee04088606af627628f2 diff --git a/src/shared/components/comment/comment-form.tsx b/src/shared/components/comment/comment-form.tsx index 9c29381da..d988c020a 100644 --- a/src/shared/components/comment/comment-form.tsx +++ b/src/shared/components/comment/comment-form.tsx @@ -17,7 +17,6 @@ import { UserService, WebSocketService } from "../../services"; import { capitalizeFirstLetter, myAuth, - myFirstDiscussionLanguageId, wsClient, wsSubscribe, } from "../../utils"; @@ -77,21 +76,11 @@ export class CommentForm extends Component { : undefined : undefined; - let selectedLang = - typeof this.props.node !== "number" - ? this.props.node.comment_view.comment.language_id - : myFirstDiscussionLanguageId( - this.props.allLanguages, - this.props.siteLanguages, - UserService.Instance.myUserInfo - ); - return (
    {UserService.Instance.myUserInfo ? ( { aria-label="action" multiple={this.props.multiple} > + {!this.props.multiple && ( + + )} {filteredLangs.map(l => (