From 322a44bf24ec63bc2c0518ea7751e4a3a2f8e9e7 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Tue, 4 Jul 2023 20:53:28 +0000 Subject: [PATCH 1/5] Fix data-bs-theme (#1810) * Fix data-bs-theme * Add other dark themes * Add vaporwave-dark to dark theme list --- src/client/index.tsx | 4 ++-- src/server/handlers/catch-all-handler.tsx | 2 +- src/shared/components/app/app.tsx | 15 ++++++++------- src/shared/utils/browser/data-bs-theme.ts | 14 ++++++++++---- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/client/index.tsx b/src/client/index.tsx index 36059f97..2bdd948f 100644 --- a/src/client/index.tsx +++ b/src/client/index.tsx @@ -2,7 +2,7 @@ import { initializeSite, setupDateFns } from "@utils/app"; import { hydrate } from "inferno-hydrate"; import { Router } from "inferno-router"; import { App } from "../shared/components/app/app"; -import { HistoryService } from "../shared/services"; +import { HistoryService, UserService } from "../shared/services"; import "bootstrap/js/dist/collapse"; import "bootstrap/js/dist/dropdown"; @@ -14,7 +14,7 @@ async function startClient() { const wrapper = ( - + ); diff --git a/src/server/handlers/catch-all-handler.tsx b/src/server/handlers/catch-all-handler.tsx index 6b214944..4b011045 100644 --- a/src/server/handlers/catch-all-handler.tsx +++ b/src/server/handlers/catch-all-handler.tsx @@ -114,7 +114,7 @@ export default async (req: Request, res: Response) => { const wrapper = ( - + ); diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index 3452f962..2000bec2 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -3,6 +3,7 @@ import { dataBsTheme } from "@utils/browser"; import { Component, RefObject, createRef, linkEvent } from "inferno"; import { Provider } from "inferno-i18next-dess"; import { Route, Switch } from "inferno-router"; +import { MyUserInfo } from "lemmy-js-client"; import { IsoDataOptionalSite } from "../../interfaces"; import { routes } from "../../routes"; import { FirstLoadService, I18NextService, UserService } from "../../services"; @@ -14,10 +15,14 @@ import { Navbar } from "./navbar"; import "./styles.scss"; import { Theme } from "./theme"; -export class App extends Component { +interface AppProps { + user?: MyUserInfo; +} + +export class App extends Component { private isoData: IsoDataOptionalSite = setIsoData(this.context); private readonly mainContentRef: RefObject; - constructor(props: any, context: any) { + constructor(props: AppProps, context: any) { super(props, context); this.mainContentRef = createRef(); } @@ -29,10 +34,6 @@ export class App extends Component { user = UserService.Instance.myUserInfo; - componentDidMount() { - this.setState({ bsTheme: dataBsTheme(this.user) }); - } - render() { const siteRes = this.isoData.site_res; const siteView = siteRes?.site_view; @@ -43,7 +44,7 @@ export class App extends Component {
{
-
{getRss(listingType)}
+
+ {getRss( + listingType ?? + this.state.siteRes.site_view.local_site.default_post_listing_type + )} +
); } From c3ab9e74f8775f4b811866d2675b00f9702bde3d Mon Sep 17 00:00:00 2001 From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:08:32 -0400 Subject: [PATCH 4/5] fix toaster upon user settings change (#1802) Co-authored-by: SleeplessOne1917 --- src/shared/components/home/login.tsx | 4 +++- src/shared/components/home/setup.tsx | 2 +- src/shared/components/home/signup.tsx | 4 +++- src/shared/components/person/password-change.tsx | 4 +++- src/shared/components/person/settings.tsx | 11 +++++++++-- src/shared/services/UserService.ts | 10 ++++++++-- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index ffc372b3..e2986b57 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -175,7 +175,9 @@ export class Login extends Component { } case "success": { - UserService.Instance.login(loginRes.data); + UserService.Instance.login({ + res: loginRes.data, + }); const site = await HttpService.client.getSite({ auth: myAuth(), }); diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx index 943fd5f8..f4bdb555 100644 --- a/src/shared/components/home/setup.tsx +++ b/src/shared/components/home/setup.tsx @@ -206,7 +206,7 @@ export class Setup extends Component { if (i.state.registerRes.state == "success") { const data = i.state.registerRes.data; - UserService.Instance.login(data); + UserService.Instance.login({ res: data }); i.setState({ doneRegisteringUser: true }); } } diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 1e1f636a..bb1e1f11 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -469,7 +469,9 @@ export class Signup extends Component { // Only log them in if a jwt was set if (data.jwt) { - UserService.Instance.login(data); + UserService.Instance.login({ + res: data, + }); const site = await HttpService.client.getSite({ auth: myAuth() }); diff --git a/src/shared/components/person/password-change.tsx b/src/shared/components/person/password-change.tsx index 68a22f62..565f55e6 100644 --- a/src/shared/components/person/password-change.tsx +++ b/src/shared/components/person/password-change.tsx @@ -135,7 +135,9 @@ export class PasswordChange extends Component { if (i.state.passwordChangeRes.state === "success") { const data = i.state.passwordChangeRes.data; - UserService.Instance.login(data); + UserService.Instance.login({ + res: data, + }); const site = await HttpService.client.getSite({ auth: myAuth() }); if (site.state === "success") { diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx index dfdf79c4..4caef458 100644 --- a/src/shared/components/person/settings.tsx +++ b/src/shared/components/person/settings.tsx @@ -1175,8 +1175,12 @@ export class Settings extends Component { ...i.state.saveUserSettingsForm, auth: myAuthRequired(), }); + if (saveRes.state === "success") { - UserService.Instance.login(saveRes.data); + UserService.Instance.login({ + res: saveRes.data, + showToast: false, + }); toast(I18NextService.i18n.t("saved")); window.scrollTo(0, 0); } @@ -1198,7 +1202,10 @@ export class Settings extends Component { auth: myAuthRequired(), }); if (changePasswordRes.state === "success") { - UserService.Instance.login(changePasswordRes.data); + UserService.Instance.login({ + res: changePasswordRes.data, + showToast: false, + }); window.scrollTo(0, 0); toast(I18NextService.i18n.t("password_changed")); } diff --git a/src/shared/services/UserService.ts b/src/shared/services/UserService.ts index 0724f400..70e8e9ca 100644 --- a/src/shared/services/UserService.ts +++ b/src/shared/services/UserService.ts @@ -26,12 +26,18 @@ export class UserService { this.#setJwtInfo(); } - public login(res: LoginResponse) { + public login({ + res, + showToast = true, + }: { + res: LoginResponse; + showToast?: boolean; + }) { const expires = new Date(); expires.setDate(expires.getDate() + 365); if (isBrowser() && res.jwt) { - toast(I18NextService.i18n.t("logged_in")); + showToast && toast(I18NextService.i18n.t("logged_in")); setAuthCookie(res.jwt); this.#setJwtInfo(); } From b45c24537db2c0618626ff15a5d76ee836697e72 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Tue, 4 Jul 2023 17:24:57 -0400 Subject: [PATCH 5/5] fix: Fix focus ring styles for radio button toggles #1772 (#1773) --- .../components/common/data-type-select.tsx | 54 ++++--- .../components/common/listing-type-select.tsx | 77 +++++---- src/shared/components/person/inbox.tsx | 147 +++++++++-------- src/shared/components/person/profile.tsx | 22 ++- .../person/registration-applications.tsx | 51 +++--- src/shared/components/person/reports.tsx | 148 ++++++++++-------- src/shared/components/post/post.tsx | 125 ++++++++------- 7 files changed, 363 insertions(+), 261 deletions(-) diff --git a/src/shared/components/common/data-type-select.tsx b/src/shared/components/common/data-type-select.tsx index 6bf0666c..a0393f67 100644 --- a/src/shared/components/common/data-type-select.tsx +++ b/src/shared/components/common/data-type-select.tsx @@ -1,3 +1,5 @@ +import { randomStr } from "@utils/helpers"; +import classNames from "classnames"; import { Component, linkEvent } from "inferno"; import { DataType } from "../../interfaces"; import { I18NextService } from "../../services"; @@ -15,6 +17,8 @@ export class DataTypeSelect extends Component< DataTypeSelectProps, DataTypeSelectState > { + private id = `listing-type-input-${randomStr()}`; + state: DataTypeSelectState = { type_: this.props.type_, }; @@ -31,33 +35,41 @@ export class DataTypeSelect extends Component< render() { return ( -
+
+ + +
diff --git a/src/shared/components/common/listing-type-select.tsx b/src/shared/components/common/listing-type-select.tsx index 9d0a1b9f..1d917dcd 100644 --- a/src/shared/components/common/listing-type-select.tsx +++ b/src/shared/components/common/listing-type-select.tsx @@ -1,4 +1,5 @@ import { randomStr } from "@utils/helpers"; +import classNames from "classnames"; import { Component, linkEvent } from "inferno"; import { ListingType } from "lemmy-js-client"; import { I18NextService, UserService } from "../../services"; @@ -38,60 +39,72 @@ export class ListingTypeSelect extends Component< render() { return ( -
+
{this.props.showSubscribed && ( - + + )} {this.props.showLocal && ( - + + )} +
diff --git a/src/shared/components/person/inbox.tsx b/src/shared/components/person/inbox.tsx index 28bb0716..bf246f64 100644 --- a/src/shared/components/person/inbox.tsx +++ b/src/shared/components/person/inbox.tsx @@ -11,8 +11,9 @@ import { setIsoData, updatePersonBlock, } from "@utils/app"; -import { capitalizeFirstLetter } from "@utils/helpers"; +import { capitalizeFirstLetter, randomStr } from "@utils/helpers"; import { RouteDataResponse } from "@utils/types"; +import classNames from "classnames"; import { Component, linkEvent } from "inferno"; import { AddAdmin, @@ -283,34 +284,41 @@ export class Inbox extends Component { } unreadOrAllRadios() { + const radioId = randomStr(); + return ( -
+
+ + +
@@ -318,62 +326,75 @@ export class Inbox extends Component { } messageTypeRadios() { + const radioId = randomStr(); + return ( -
+
+ + + + + + +
diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index 96ac3da3..39979e29 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -18,6 +18,7 @@ import { getQueryParams, getQueryString, numToSI, + randomStr, } from "@utils/helpers"; import { canMod, isAdmin, isBanned } from "@utils/roles"; import type { QueryParams } from "@utils/types"; @@ -397,7 +398,7 @@ export class Profile extends Component< get viewRadios() { return ( -
+
{this.getRadio(PersonDetailsView.Overview)} {this.getRadio(PersonDetailsView.Comments)} {this.getRadio(PersonDetailsView.Posts)} @@ -409,22 +410,27 @@ export class Profile extends Component< getRadio(view: PersonDetailsView) { const { view: urlView } = getProfileQueryParams(); const active = view === urlView; + const radioId = randomStr(); return ( - + + ); } diff --git a/src/shared/components/person/registration-applications.tsx b/src/shared/components/person/registration-applications.tsx index a26dd79e..757170f8 100644 --- a/src/shared/components/person/registration-applications.tsx +++ b/src/shared/components/person/registration-applications.tsx @@ -3,7 +3,9 @@ import { myAuthRequired, setIsoData, } from "@utils/app"; +import { randomStr } from "@utils/helpers"; import { RouteDataResponse } from "@utils/types"; +import classNames from "classnames"; import { Component, linkEvent } from "inferno"; import { ApproveRegistrationApplication, @@ -125,34 +127,41 @@ export class RegistrationApplications extends Component< } unreadOrAllRadios() { + const radioId = randomStr(); + return ( -
+
+ + +
diff --git a/src/shared/components/person/reports.tsx b/src/shared/components/person/reports.tsx index c16b17ac..d298930e 100644 --- a/src/shared/components/person/reports.tsx +++ b/src/shared/components/person/reports.tsx @@ -5,8 +5,10 @@ import { myAuthRequired, setIsoData, } from "@utils/app"; +import { randomStr } from "@utils/helpers"; import { amAdmin } from "@utils/roles"; import { RouteDataResponse } from "@utils/types"; +import classNames from "classnames"; import { Component, linkEvent } from "inferno"; import { CommentReportResponse, @@ -187,34 +189,41 @@ export class Reports extends Component { } unreadOrAllRadios() { + const radioId = randomStr(); + return ( -
+
+ + +
@@ -222,70 +231,83 @@ export class Reports extends Component { } messageTypeRadios() { + const radioId = randomStr(); + return ( -
+
+ + + + + + {amAdmin() && ( - + + )}
); diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 3c0015ec..f9d35127 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -19,10 +19,11 @@ import { restoreScrollPosition, saveScrollPosition, } from "@utils/browser"; -import { debounce } from "@utils/helpers"; +import { debounce, randomStr } from "@utils/helpers"; import { isImage } from "@utils/media"; import { RouteDataResponse } from "@utils/types"; import autosize from "autosize"; +import classNames from "classnames"; import { Component, RefObject, createRef, linkEvent } from "inferno"; import { AddAdmin, @@ -430,80 +431,98 @@ export class Post extends Component { } sortRadios() { + const radioId = + this.state.postRes.state === "success" + ? this.state.postRes.data.post_view.post.id + : randomStr(); + return ( <> -
+
+ + + +
-
+
+