mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-01 01:59:56 +00:00
Upgrading deps, running prettier. (#1987)
This commit is contained in:
parent
dd42bc2a3d
commit
9f2289d466
108 changed files with 891 additions and 854 deletions
41
package.json
41
package.json
|
@ -35,16 +35,16 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-proposal-decorators": "^7.21.0",
|
"@babel/plugin-proposal-decorators": "^7.21.0",
|
||||||
"@babel/plugin-transform-runtime": "^7.21.4",
|
"@babel/plugin-transform-runtime": "^7.22.9",
|
||||||
"@babel/plugin-transform-typescript": "^7.21.3",
|
"@babel/plugin-transform-typescript": "^7.22.9",
|
||||||
"@babel/preset-env": "7.21.5",
|
"@babel/preset-env": "7.22.9",
|
||||||
"@babel/preset-typescript": "^7.21.5",
|
"@babel/preset-typescript": "^7.21.5",
|
||||||
"@babel/runtime": "^7.21.5",
|
"@babel/runtime": "^7.21.5",
|
||||||
"@emoji-mart/data": "^1.1.0",
|
"@emoji-mart/data": "^1.1.0",
|
||||||
"autosize": "^6.0.1",
|
"autosize": "^6.0.1",
|
||||||
"babel-loader": "^9.1.2",
|
"babel-loader": "^9.1.2",
|
||||||
"babel-plugin-inferno": "^6.6.0",
|
"babel-plugin-inferno": "^6.6.0",
|
||||||
"bootstrap": "^5.2.3",
|
"bootstrap": "^5.3.1",
|
||||||
"check-password-strength": "^2.0.7",
|
"check-password-strength": "^2.0.7",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"clean-webpack-plugin": "^4.0.0",
|
"clean-webpack-plugin": "^4.0.0",
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
"express": "~4.18.2",
|
"express": "~4.18.2",
|
||||||
"history": "^5.3.0",
|
"history": "^5.3.0",
|
||||||
"html-to-text": "^9.0.5",
|
"html-to-text": "^9.0.5",
|
||||||
"i18next": "^23.2.8",
|
"i18next": "^23.3.0",
|
||||||
"inferno": "^8.2.2",
|
"inferno": "^8.2.2",
|
||||||
"inferno-create-element": "^8.2.2",
|
"inferno-create-element": "^8.2.2",
|
||||||
"inferno-helmet": "^5.2.1",
|
"inferno-helmet": "^5.2.1",
|
||||||
|
@ -81,20 +81,21 @@
|
||||||
"register-service-worker": "^1.7.2",
|
"register-service-worker": "^1.7.2",
|
||||||
"run-node-webpack-plugin": "^1.3.0",
|
"run-node-webpack-plugin": "^1.3.0",
|
||||||
"sanitize-html": "^2.11.0",
|
"sanitize-html": "^2.11.0",
|
||||||
"sass": "^1.63.6",
|
"sass": "^1.64.1",
|
||||||
"sass-loader": "^13.3.2",
|
"sass-loader": "^13.3.2",
|
||||||
"serialize-javascript": "^6.0.1",
|
"serialize-javascript": "^6.0.1",
|
||||||
"service-worker-webpack": "^1.0.0",
|
"service-worker-webpack": "^1.0.0",
|
||||||
"sharp": "^0.32.1",
|
"sharp": "^0.32.4",
|
||||||
"tippy.js": "^6.3.7",
|
"tippy.js": "^6.3.7",
|
||||||
"toastify-js": "^1.12.0",
|
"toastify-js": "^1.12.0",
|
||||||
"tributejs": "^5.1.3",
|
"tributejs": "^5.1.3",
|
||||||
"webpack": "5.88.1",
|
"webpack": "5.88.2",
|
||||||
"webpack-cli": "^5.1.4",
|
"webpack-cli": "^5.1.4",
|
||||||
"webpack-node-externals": "^3.0.0"
|
"webpack-node-externals": "^3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.21.8",
|
"@babel/core": "^7.22.9",
|
||||||
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
||||||
"@types/autosize": "^4.0.0",
|
"@types/autosize": "^4.0.0",
|
||||||
"@types/bootstrap": "^5.2.6",
|
"@types/bootstrap": "^5.2.6",
|
||||||
"@types/cookie": "^0.5.1",
|
"@types/cookie": "^0.5.1",
|
||||||
|
@ -102,29 +103,29 @@
|
||||||
"@types/html-to-text": "^9.0.0",
|
"@types/html-to-text": "^9.0.0",
|
||||||
"@types/lodash.isequal": "^4.5.6",
|
"@types/lodash.isequal": "^4.5.6",
|
||||||
"@types/markdown-it": "^12.2.3",
|
"@types/markdown-it": "^12.2.3",
|
||||||
"@types/markdown-it-container": "^2.0.5",
|
"@types/markdown-it-container": "^2.0.6",
|
||||||
"@types/node": "^20.4.0",
|
"@types/node": "^20.4.5",
|
||||||
"@types/path-browserify": "^1.0.0",
|
"@types/path-browserify": "^1.0.0",
|
||||||
"@types/sanitize-html": "^2.9.0",
|
"@types/sanitize-html": "^2.9.0",
|
||||||
"@types/serialize-javascript": "^5.0.1",
|
"@types/serialize-javascript": "^5.0.1",
|
||||||
"@types/toastify-js": "^1.11.1",
|
"@types/toastify-js": "^1.12.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
||||||
"@typescript-eslint/parser": "^5.61.0",
|
"@typescript-eslint/parser": "^6.2.0",
|
||||||
"eslint": "^8.44.0",
|
"eslint": "^8.45.0",
|
||||||
"eslint-plugin-inferno": "^7.32.2",
|
"eslint-plugin-inferno": "^7.32.2",
|
||||||
"eslint-plugin-jsx-a11y": "^6.7.1",
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^5.0.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"import-sort-style-module": "^6.0.0",
|
"import-sort-style-module": "^6.0.0",
|
||||||
"lint-staged": "^13.2.3",
|
"lint-staged": "^13.2.3",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^3.0.0",
|
||||||
"prettier-plugin-import-sort": "^0.0.7",
|
"prettier-plugin-import-sort": "^0.0.7",
|
||||||
"prettier-plugin-organize-imports": "^3.2.2",
|
"prettier-plugin-organize-imports": "^3.2.3",
|
||||||
"prettier-plugin-packagejson": "^2.4.4",
|
"prettier-plugin-packagejson": "^2.4.5",
|
||||||
"rimraf": "^5.0.0",
|
"rimraf": "^5.0.0",
|
||||||
"sortpack": "^2.3.4",
|
"sortpack": "^2.3.4",
|
||||||
"style-loader": "^3.3.2",
|
"style-loader": "^3.3.2",
|
||||||
"terser": "^5.18.2",
|
"terser": "^5.19.2",
|
||||||
"typescript": "^5.1.6",
|
"typescript": "^5.1.6",
|
||||||
"typescript-language-server": "^3.3.2",
|
"typescript-language-server": "^3.3.2",
|
||||||
"webpack-bundle-analyzer": "^4.9.0",
|
"webpack-bundle-analyzer": "^4.9.0",
|
||||||
|
|
|
@ -30,9 +30,18 @@ $mark-bg: $gray-900;
|
||||||
$text-muted: $gray-600;
|
$text-muted: $gray-600;
|
||||||
$yiq-contrasted-threshold: 175;
|
$yiq-contrasted-threshold: 175;
|
||||||
|
|
||||||
$font-family-sans-serif: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI",
|
$font-family-sans-serif:
|
||||||
Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
|
"Lato",
|
||||||
"Segoe UI Emoji", "Segoe UI Symbol";
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
Roboto,
|
||||||
|
"Helvetica Neue",
|
||||||
|
Arial,
|
||||||
|
sans-serif,
|
||||||
|
"Apple Color Emoji",
|
||||||
|
"Segoe UI Emoji",
|
||||||
|
"Segoe UI Symbol";
|
||||||
$font-size-base: 0.9375rem;
|
$font-size-base: 0.9375rem;
|
||||||
$h1-font-size: 3rem;
|
$h1-font-size: 3rem;
|
||||||
$h2-font-size: 2.5rem;
|
$h2-font-size: 2.5rem;
|
||||||
|
|
|
@ -29,9 +29,18 @@ $mark-bg: #333;
|
||||||
$text-muted: $gray-600;
|
$text-muted: $gray-600;
|
||||||
$yiq-contrasted-threshold: 175;
|
$yiq-contrasted-threshold: 175;
|
||||||
|
|
||||||
$font-family-sans-serif: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI",
|
$font-family-sans-serif:
|
||||||
Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji",
|
"Lato",
|
||||||
"Segoe UI Emoji", "Segoe UI Symbol";
|
-apple-system,
|
||||||
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
Roboto,
|
||||||
|
"Helvetica Neue",
|
||||||
|
Arial,
|
||||||
|
sans-serif,
|
||||||
|
"Apple Color Emoji",
|
||||||
|
"Segoe UI Emoji",
|
||||||
|
"Segoe UI Symbol";
|
||||||
$h1-font-size: 3rem;
|
$h1-font-size: 3rem;
|
||||||
$h2-font-size: 2.5rem;
|
$h2-font-size: 2.5rem;
|
||||||
$h3-font-size: 2rem;
|
$h3-font-size: 2rem;
|
||||||
|
|
|
@ -23,8 +23,11 @@ option:disabled {
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-control::placeholder {
|
.form-control::placeholder {
|
||||||
text-shadow: 0.5px 0.5px 0 $secondary, 0.5px -0.5px 0 $secondary,
|
text-shadow:
|
||||||
-0.5px 0.5px 0 $secondary, -0.5px -0.5px 0 $secondary;
|
0.5px 0.5px 0 $secondary,
|
||||||
|
0.5px -0.5px 0 $secondary,
|
||||||
|
-0.5px 0.5px 0 $secondary,
|
||||||
|
-0.5px -0.5px 0 $secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-group-text {
|
.input-group-text {
|
||||||
|
|
|
@ -35,7 +35,7 @@ export default async (req: Request, res: Response) => {
|
||||||
const headers = setForwardedHeaders(req.headers);
|
const headers = setForwardedHeaders(req.headers);
|
||||||
|
|
||||||
const client = wrapClient(
|
const client = wrapClient(
|
||||||
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers })
|
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { path, url, query } = req;
|
const { path, url, query } = req;
|
||||||
|
@ -50,7 +50,7 @@ export default async (req: Request, res: Response) => {
|
||||||
|
|
||||||
if (try_site.state === "failed" && try_site.msg === "not_logged_in") {
|
if (try_site.state === "failed" && try_site.msg === "not_logged_in") {
|
||||||
console.error(
|
console.error(
|
||||||
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie"
|
"Incorrect JWT token, skipping auth so frontend can remove jwt cookie",
|
||||||
);
|
);
|
||||||
getSiteForm.auth = undefined;
|
getSiteForm.auth = undefined;
|
||||||
auth = undefined;
|
auth = undefined;
|
||||||
|
@ -90,7 +90,7 @@ export default async (req: Request, res: Response) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const error = Object.values(routeData).find(
|
const error = Object.values(routeData).find(
|
||||||
res => res.state === "failed" && res.msg !== "couldnt_find_object" // TODO: find a better way of handling errors
|
res => res.state === "failed" && res.msg !== "couldnt_find_object", // TODO: find a better way of handling errors
|
||||||
) as FailedRequestState | undefined;
|
) as FailedRequestState | undefined;
|
||||||
|
|
||||||
// Redirect to the 404 if there's an API error
|
// Redirect to the 404 if there's an API error
|
||||||
|
@ -127,7 +127,7 @@ export default async (req: Request, res: Response) => {
|
||||||
res.statusCode = 500;
|
res.statusCode = 500;
|
||||||
|
|
||||||
return res.send(
|
return res.send(
|
||||||
process.env.NODE_ENV === "development" ? err.message : "Server error"
|
process.env.NODE_ENV === "development" ? err.message : "Server error",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default async (req: Request, res: Response) => {
|
||||||
if (!manifest || manifest.start_url !== getHttpBaseExternal()) {
|
if (!manifest || manifest.start_url !== getHttpBaseExternal()) {
|
||||||
const headers = setForwardedHeaders(req.headers);
|
const headers = setForwardedHeaders(req.headers);
|
||||||
const client = wrapClient(
|
const client = wrapClient(
|
||||||
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers })
|
new LemmyHttp(getHttpBaseInternal(), { fetchFunction: fetch, headers }),
|
||||||
);
|
);
|
||||||
const site = await client.getSite({});
|
const site = await client.getSite({});
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,6 @@ export default async ({ res }: { res: Response }) => {
|
||||||
process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST +
|
process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST +
|
||||||
`
|
`
|
||||||
Expires: 2024-01-01T04:59:00.000Z
|
Expires: 2024-01-01T04:59:00.000Z
|
||||||
`
|
`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default async ({ res }: { res: Response }) => {
|
||||||
path.resolve(
|
path.resolve(
|
||||||
`./dist/service-worker${
|
`./dist/service-worker${
|
||||||
process.env.NODE_ENV === "development" ? "-development" : ""
|
process.env.NODE_ENV === "development" ? "-development" : ""
|
||||||
}.js`
|
}.js`,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,7 @@ server.use(
|
||||||
express.static(path.resolve("./dist"), {
|
express.static(path.resolve("./dist"), {
|
||||||
maxAge: 24 * 60 * 60 * 1000, // 1 day
|
maxAge: 24 * 60 * 60 * 1000, // 1 day
|
||||||
immutable: true,
|
immutable: true,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
server.use(setCacheControl);
|
server.use(setCacheControl);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function setDefaultCsp({
|
||||||
form-action 'self';
|
form-action 'self';
|
||||||
base-uri 'self';
|
base-uri 'self';
|
||||||
frame-src *;
|
frame-src *;
|
||||||
media-src * data:`.replace(/\s+/g, " ")
|
media-src * data:`.replace(/\s+/g, " "),
|
||||||
);
|
);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
@ -37,7 +37,7 @@ export function setDefaultCsp({
|
||||||
export function setCacheControl(
|
export function setCacheControl(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
next: NextFunction
|
next: NextFunction,
|
||||||
) {
|
) {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (process.env.NODE_ENV !== "production") {
|
||||||
return next();
|
return next();
|
||||||
|
|
|
@ -15,7 +15,7 @@ let appleTouchIcon: string | undefined = undefined;
|
||||||
export async function createSsrHtml(
|
export async function createSsrHtml(
|
||||||
root: string,
|
root: string,
|
||||||
isoData: IsoDataOptionalSite,
|
isoData: IsoDataOptionalSite,
|
||||||
cspNonce: string
|
cspNonce: string,
|
||||||
) {
|
) {
|
||||||
const site = isoData.site_res;
|
const site = isoData.site_res;
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@ export async function createSsrHtml(
|
||||||
const customHtmlHeaderScriptTag = new RegExp("<script", "g");
|
const customHtmlHeaderScriptTag = new RegExp("<script", "g");
|
||||||
const customHtmlHeaderWithNonce = customHtmlHeader.replace(
|
const customHtmlHeaderWithNonce = customHtmlHeader.replace(
|
||||||
customHtmlHeaderScriptTag,
|
customHtmlHeaderScriptTag,
|
||||||
`<script nonce="${cspNonce}"`
|
`<script nonce="${cspNonce}"`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!appleTouchIcon) {
|
if (!appleTouchIcon) {
|
||||||
appleTouchIcon = site?.site_view.site.icon
|
appleTouchIcon = site?.site_view.site.icon
|
||||||
? `data:image/png;base64,${await sharp(
|
? `data:image/png;base64,${await sharp(
|
||||||
await fetchIconPng(site.site_view.site.icon)
|
await fetchIconPng(site.site_view.site.icon),
|
||||||
)
|
)
|
||||||
.resize(180, 180)
|
.resize(180, 180)
|
||||||
.extend({
|
.extend({
|
||||||
|
@ -57,7 +57,7 @@ export async function createSsrHtml(
|
||||||
src="//cdn.jsdelivr.net/npm/eruda"
|
src="//cdn.jsdelivr.net/npm/eruda"
|
||||||
></script>
|
></script>
|
||||||
<script nonce={cspNonce}>eruda.init();</script>
|
<script nonce={cspNonce}>eruda.init();</script>
|
||||||
</>
|
</>,
|
||||||
)
|
)
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ const defaultLogoPathDirectory = path.join(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
"dist",
|
"dist",
|
||||||
"assets",
|
"assets",
|
||||||
"icons"
|
"icons",
|
||||||
);
|
);
|
||||||
|
|
||||||
export default async function ({
|
export default async function ({
|
||||||
|
@ -34,7 +34,7 @@ export default async function ({
|
||||||
icons: await Promise.all(
|
icons: await Promise.all(
|
||||||
iconSizes.map(async size => {
|
iconSizes.map(async size => {
|
||||||
let src = await readFile(
|
let src = await readFile(
|
||||||
path.join(defaultLogoPathDirectory, `icon-${size}x${size}.png`)
|
path.join(defaultLogoPathDirectory, `icon-${size}x${size}.png`),
|
||||||
).then(buf => buf.toString("base64"));
|
).then(buf => buf.toString("base64"));
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
|
@ -51,7 +51,7 @@ export default async function ({
|
||||||
src: `data:image/png;base64,${src}`,
|
src: `data:image/png;base64,${src}`,
|
||||||
purpose: "any maskable",
|
purpose: "any maskable",
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
),
|
),
|
||||||
shortcuts: [
|
shortcuts: [
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ export default async function ({
|
||||||
description: "Create a community",
|
description: "Create a community",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []
|
: [],
|
||||||
),
|
),
|
||||||
related_applications: [
|
related_applications: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,7 +86,7 @@ export class App extends Component<AppProps, any> {
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
<Route component={ErrorPage} />
|
<Route component={ErrorPage} />
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|
|
@ -146,7 +146,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
{
|
{
|
||||||
count: Number(this.unreadApplicationCount),
|
count: Number(this.unreadApplicationCount),
|
||||||
formattedCount: numToSI(this.unreadApplicationCount),
|
formattedCount: numToSI(this.unreadApplicationCount),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
onMouseUp={linkEvent(this, handleCollapseClick)}
|
onMouseUp={linkEvent(this, handleCollapseClick)}
|
||||||
>
|
>
|
||||||
|
@ -323,9 +323,9 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
{
|
{
|
||||||
count: Number(this.unreadApplicationCount),
|
count: Number(this.unreadApplicationCount),
|
||||||
formattedCount: numToSI(
|
formattedCount: numToSI(
|
||||||
this.unreadApplicationCount
|
this.unreadApplicationCount,
|
||||||
),
|
),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
onMouseUp={linkEvent(this, handleCollapseClick)}
|
onMouseUp={linkEvent(this, handleCollapseClick)}
|
||||||
>
|
>
|
||||||
|
@ -336,9 +336,9 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
{
|
{
|
||||||
count: Number(this.unreadApplicationCount),
|
count: Number(this.unreadApplicationCount),
|
||||||
formattedCount: numToSI(
|
formattedCount: numToSI(
|
||||||
this.unreadApplicationCount
|
this.unreadApplicationCount,
|
||||||
),
|
),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
{this.unreadApplicationCount > 0 && (
|
{this.unreadApplicationCount > 0 && (
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class CommentForm extends Component<CommentFormProps, any> {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={["comment-form", "mb-3", this.props.containerClass].join(
|
className={["comment-form", "mb-3", this.props.containerClass].join(
|
||||||
" "
|
" ",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{UserService.Instance.myUserInfo ? (
|
{UserService.Instance.myUserInfo ? (
|
||||||
|
|
|
@ -198,7 +198,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & CommentNodeProps>
|
nextProps: Readonly<{ children?: InfernoNode } & CommentNodeProps>,
|
||||||
): void {
|
): void {
|
||||||
if (!deepEqual(this.props, nextProps)) {
|
if (!deepEqual(this.props, nextProps)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -250,27 +250,27 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
const canMod_ = canMod(
|
const canMod_ = canMod(
|
||||||
cv.creator.id,
|
cv.creator.id,
|
||||||
this.props.moderators,
|
this.props.moderators,
|
||||||
this.props.admins
|
this.props.admins,
|
||||||
);
|
);
|
||||||
const canModOnSelf = canMod(
|
const canModOnSelf = canMod(
|
||||||
cv.creator.id,
|
cv.creator.id,
|
||||||
this.props.moderators,
|
this.props.moderators,
|
||||||
this.props.admins,
|
this.props.admins,
|
||||||
UserService.Instance.myUserInfo,
|
UserService.Instance.myUserInfo,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
const canAdmin_ = canAdmin(cv.creator.id, this.props.admins);
|
const canAdmin_ = canAdmin(cv.creator.id, this.props.admins);
|
||||||
const canAdminOnSelf = canAdmin(
|
const canAdminOnSelf = canAdmin(
|
||||||
cv.creator.id,
|
cv.creator.id,
|
||||||
this.props.admins,
|
this.props.admins,
|
||||||
UserService.Instance.myUserInfo,
|
UserService.Instance.myUserInfo,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
const isMod_ = isMod(cv.creator.id, this.props.moderators);
|
const isMod_ = isMod(cv.creator.id, this.props.moderators);
|
||||||
const isAdmin_ = isAdmin(cv.creator.id, this.props.admins);
|
const isAdmin_ = isAdmin(cv.creator.id, this.props.admins);
|
||||||
const amCommunityCreator_ = amCommunityCreator(
|
const amCommunityCreator_ = amCommunityCreator(
|
||||||
cv.creator.id,
|
cv.creator.id,
|
||||||
this.props.moderators
|
this.props.moderators,
|
||||||
);
|
);
|
||||||
|
|
||||||
const moreRepliesBorderColor = this.props.node.depth
|
const moreRepliesBorderColor = this.props.node.depth
|
||||||
|
@ -337,7 +337,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
<span className="badge text-bg-light d-none d-sm-inline me-2">
|
<span className="badge text-bg-light d-none d-sm-inline me-2">
|
||||||
{
|
{
|
||||||
this.props.allLanguages.find(
|
this.props.allLanguages.find(
|
||||||
lang => lang.id === cv.comment.language_id
|
lang => lang.id === cv.comment.language_id,
|
||||||
)?.name
|
)?.name
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
|
@ -374,7 +374,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
onReplyCancel={this.handleReplyCancel}
|
onReplyCancel={this.handleReplyCancel}
|
||||||
disabled={this.props.locked}
|
disabled={this.props.locked}
|
||||||
finished={this.props.finished.get(
|
finished={this.props.finished.get(
|
||||||
this.props.node.comment_view.comment.id
|
this.props.node.comment_view.comment.id,
|
||||||
)}
|
)}
|
||||||
focus
|
focus
|
||||||
allLanguages={this.props.allLanguages}
|
allLanguages={this.props.allLanguages}
|
||||||
|
@ -472,13 +472,13 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleShowReportDialog
|
this.handleShowReportDialog,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"show_report_dialog"
|
"show_report_dialog",
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"show_report_dialog"
|
"show_report_dialog",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon icon="flag" />
|
<Icon icon="flag" />
|
||||||
|
@ -487,10 +487,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleBlockPerson
|
this.handleBlockPerson,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"block_user"
|
"block_user",
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("block_user")}
|
aria-label={I18NextService.i18n.t("block_user")}
|
||||||
>
|
>
|
||||||
|
@ -531,7 +531,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(this, this.handleViewSource)}
|
onClick={linkEvent(this, this.handleViewSource)}
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"view_source"
|
"view_source",
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("view_source")}
|
aria-label={I18NextService.i18n.t("view_source")}
|
||||||
>
|
>
|
||||||
|
@ -548,7 +548,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(this, this.handleEditClick)}
|
onClick={linkEvent(this, this.handleEditClick)}
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"edit"
|
"edit",
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("edit")}
|
aria-label={I18NextService.i18n.t("edit")}
|
||||||
>
|
>
|
||||||
|
@ -558,7 +558,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleDeleteComment
|
this.handleDeleteComment,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={
|
data-tippy-content={
|
||||||
!cv.comment.deleted
|
!cv.comment.deleted
|
||||||
|
@ -588,7 +588,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleDistinguishComment
|
this.handleDistinguishComment,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={
|
data-tippy-content={
|
||||||
!cv.comment.distinguished
|
!cv.comment.distinguished
|
||||||
|
@ -619,7 +619,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleModRemoveShow
|
this.handleModRemoveShow,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("remove")}
|
aria-label={I18NextService.i18n.t("remove")}
|
||||||
>
|
>
|
||||||
|
@ -630,7 +630,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleRemoveComment
|
this.handleRemoveComment,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("restore")}
|
aria-label={I18NextService.i18n.t("restore")}
|
||||||
>
|
>
|
||||||
|
@ -652,14 +652,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleModBanFromCommunityShow
|
this.handleModBanFromCommunityShow,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"ban_from_community"
|
"ban_from_community",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t(
|
{I18NextService.i18n.t(
|
||||||
"ban_from_community"
|
"ban_from_community",
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
|
@ -667,7 +667,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleBanPersonFromCommunity
|
this.handleBanPersonFromCommunity,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("unban")}
|
aria-label={I18NextService.i18n.t("unban")}
|
||||||
>
|
>
|
||||||
|
@ -684,13 +684,13 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleShowConfirmAppointAsMod
|
this.handleShowConfirmAppointAsMod,
|
||||||
)}
|
)}
|
||||||
aria-label={
|
aria-label={
|
||||||
isMod_
|
isMod_
|
||||||
? I18NextService.i18n.t("remove_as_mod")
|
? I18NextService.i18n.t("remove_as_mod")
|
||||||
: I18NextService.i18n.t(
|
: I18NextService.i18n.t(
|
||||||
"appoint_as_mod"
|
"appoint_as_mod",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
@ -703,7 +703,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"are_you_sure"
|
"are_you_sure",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("are_you_sure")}
|
{I18NextService.i18n.t("are_you_sure")}
|
||||||
|
@ -712,7 +712,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleAddModToCommunity
|
this.handleAddModToCommunity,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("yes")}
|
aria-label={I18NextService.i18n.t("yes")}
|
||||||
>
|
>
|
||||||
|
@ -726,7 +726,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleCancelConfirmAppointAsMod
|
this.handleCancelConfirmAppointAsMod,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("no")}
|
aria-label={I18NextService.i18n.t("no")}
|
||||||
>
|
>
|
||||||
|
@ -745,10 +745,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleShowConfirmTransferCommunity
|
this.handleShowConfirmTransferCommunity,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"transfer_community"
|
"transfer_community",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("transfer_community")}
|
{I18NextService.i18n.t("transfer_community")}
|
||||||
|
@ -758,7 +758,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"are_you_sure"
|
"are_you_sure",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("are_you_sure")}
|
{I18NextService.i18n.t("are_you_sure")}
|
||||||
|
@ -767,7 +767,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleTransferCommunity
|
this.handleTransferCommunity,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("yes")}
|
aria-label={I18NextService.i18n.t("yes")}
|
||||||
>
|
>
|
||||||
|
@ -782,7 +782,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this
|
this
|
||||||
.handleCancelShowConfirmTransferCommunity
|
.handleCancelShowConfirmTransferCommunity,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("no")}
|
aria-label={I18NextService.i18n.t("no")}
|
||||||
>
|
>
|
||||||
|
@ -799,10 +799,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handlePurgePersonShow
|
this.handlePurgePersonShow,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"purge_user"
|
"purge_user",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("purge_user")}
|
{I18NextService.i18n.t("purge_user")}
|
||||||
|
@ -811,10 +811,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handlePurgeCommentShow
|
this.handlePurgeCommentShow,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"purge_comment"
|
"purge_comment",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("purge_comment")}
|
{I18NextService.i18n.t("purge_comment")}
|
||||||
|
@ -825,10 +825,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleModBanShow
|
this.handleModBanShow,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"ban_from_site"
|
"ban_from_site",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("ban_from_site")}
|
{I18NextService.i18n.t("ban_from_site")}
|
||||||
|
@ -838,10 +838,10 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleBanPerson
|
this.handleBanPerson,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
"unban_from_site"
|
"unban_from_site",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{this.state.banLoading ? (
|
{this.state.banLoading ? (
|
||||||
|
@ -860,22 +860,22 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleShowConfirmAppointAsAdmin
|
this.handleShowConfirmAppointAsAdmin,
|
||||||
)}
|
)}
|
||||||
aria-label={
|
aria-label={
|
||||||
isAdmin_
|
isAdmin_
|
||||||
? I18NextService.i18n.t(
|
? I18NextService.i18n.t(
|
||||||
"remove_as_admin"
|
"remove_as_admin",
|
||||||
)
|
)
|
||||||
: I18NextService.i18n.t(
|
: I18NextService.i18n.t(
|
||||||
"appoint_as_admin"
|
"appoint_as_admin",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isAdmin_
|
{isAdmin_
|
||||||
? I18NextService.i18n.t("remove_as_admin")
|
? I18NextService.i18n.t("remove_as_admin")
|
||||||
: I18NextService.i18n.t(
|
: I18NextService.i18n.t(
|
||||||
"appoint_as_admin"
|
"appoint_as_admin",
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
|
@ -887,7 +887,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleAddAdmin
|
this.handleAddAdmin,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("yes")}
|
aria-label={I18NextService.i18n.t("yes")}
|
||||||
>
|
>
|
||||||
|
@ -901,7 +901,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleCancelConfirmAppointAsAdmin
|
this.handleCancelConfirmAppointAsAdmin,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("no")}
|
aria-label={I18NextService.i18n.t("no")}
|
||||||
>
|
>
|
||||||
|
@ -939,7 +939,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
{I18NextService.i18n.t("x_more_replies", {
|
{I18NextService.i18n.t("x_more_replies", {
|
||||||
count: node.comment_view.counts.child_count,
|
count: node.comment_view.counts.child_count,
|
||||||
formattedCount: numToSI(
|
formattedCount: numToSI(
|
||||||
node.comment_view.counts.child_count
|
node.comment_view.counts.child_count,
|
||||||
),
|
),
|
||||||
})}{" "}
|
})}{" "}
|
||||||
➔
|
➔
|
||||||
|
@ -1114,7 +1114,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
onReplyCancel={this.handleReplyCancel}
|
onReplyCancel={this.handleReplyCancel}
|
||||||
disabled={this.props.locked}
|
disabled={this.props.locked}
|
||||||
finished={this.props.finished.get(
|
finished={this.props.finished.get(
|
||||||
this.props.node.comment_view.comment.id
|
this.props.node.comment_view.comment.id,
|
||||||
)}
|
)}
|
||||||
focus
|
focus
|
||||||
allLanguages={this.props.allLanguages}
|
allLanguages={this.props.allLanguages}
|
||||||
|
@ -1299,13 +1299,13 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
isPersonMentionType(
|
isPersonMentionType(
|
||||||
item: CommentView | PersonMentionView | CommentReplyView
|
item: CommentView | PersonMentionView | CommentReplyView,
|
||||||
): item is PersonMentionView {
|
): item is PersonMentionView {
|
||||||
return (item as PersonMentionView).person_mention?.id !== undefined;
|
return (item as PersonMentionView).person_mention?.id !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
isCommentReplyType(
|
isCommentReplyType(
|
||||||
item: CommentView | PersonMentionView | CommentReplyView
|
item: CommentView | PersonMentionView | CommentReplyView,
|
||||||
): item is CommentReplyView {
|
): item is CommentReplyView {
|
||||||
return (item as CommentReplyView).comment_reply?.id !== undefined;
|
return (item as CommentReplyView).comment_reply?.id !== undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ export class CommentReport extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>
|
nextProps: Readonly<{ children?: InfernoNode } & CommentReportProps>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props !== nextProps) {
|
if (this.props !== nextProps) {
|
||||||
this.setState({ loading: false });
|
this.setState({ loading: false });
|
||||||
|
@ -44,7 +44,7 @@ export class CommentReport extends Component<
|
||||||
const r = this.props.report;
|
const r = this.props.report;
|
||||||
const comment = r.comment;
|
const comment = r.comment;
|
||||||
const tippyContent = I18NextService.i18n.t(
|
const tippyContent = I18NextService.i18n.t(
|
||||||
r.comment_report.resolved ? "unresolve_report" : "resolve_report"
|
r.comment_report.resolved ? "unresolve_report" : "resolve_report",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set the original post data ( a troll could change it )
|
// Set the original post data ( a troll could change it )
|
||||||
|
|
|
@ -13,13 +13,13 @@ interface BadgesProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCommunityAggregates = (
|
const isCommunityAggregates = (
|
||||||
counts: CommunityAggregates | SiteAggregates
|
counts: CommunityAggregates | SiteAggregates,
|
||||||
): counts is CommunityAggregates => {
|
): counts is CommunityAggregates => {
|
||||||
return "subscribers" in counts;
|
return "subscribers" in counts;
|
||||||
};
|
};
|
||||||
|
|
||||||
const isSiteAggregates = (
|
const isSiteAggregates = (
|
||||||
counts: CommunityAggregates | SiteAggregates
|
counts: CommunityAggregates | SiteAggregates,
|
||||||
): counts is SiteAggregates => {
|
): counts is SiteAggregates => {
|
||||||
return "communities" in counts;
|
return "communities" in counts;
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
|
||||||
{
|
{
|
||||||
count: Number(counts.users_active_day),
|
count: Number(counts.users_active_day),
|
||||||
formattedCount: numToSI(counts.users_active_day),
|
formattedCount: numToSI(counts.users_active_day),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("number_of_users", {
|
{I18NextService.i18n.t("number_of_users", {
|
||||||
|
@ -50,7 +50,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
|
||||||
{
|
{
|
||||||
count: Number(counts.users_active_week),
|
count: Number(counts.users_active_week),
|
||||||
formattedCount: numToSI(counts.users_active_week),
|
formattedCount: numToSI(counts.users_active_week),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("number_of_users", {
|
{I18NextService.i18n.t("number_of_users", {
|
||||||
|
@ -66,7 +66,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
|
||||||
{
|
{
|
||||||
count: Number(counts.users_active_month),
|
count: Number(counts.users_active_month),
|
||||||
formattedCount: numToSI(counts.users_active_month),
|
formattedCount: numToSI(counts.users_active_month),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("number_of_users", {
|
{I18NextService.i18n.t("number_of_users", {
|
||||||
|
@ -82,7 +82,7 @@ export const Badges = ({ counts, communityId }: BadgesProps) => {
|
||||||
{
|
{
|
||||||
count: Number(counts.users_active_half_year),
|
count: Number(counts.users_active_half_year),
|
||||||
formattedCount: numToSI(counts.users_active_half_year),
|
formattedCount: numToSI(counts.users_active_half_year),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("number_of_users", {
|
{I18NextService.i18n.t("number_of_users", {
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class EmojiMart extends Component<EmojiMartProps> {
|
||||||
const div: any = document.getElementById("emoji-picker");
|
const div: any = document.getElementById("emoji-picker");
|
||||||
if (div) {
|
if (div) {
|
||||||
div.appendChild(
|
div.appendChild(
|
||||||
getEmojiMart(this.handleEmojiClick, this.props.pickerOptions)
|
getEmojiMart(this.handleEmojiClick, this.props.pickerOptions),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,10 @@ export class HtmlTags extends Component<HtmlTagsProps, any> {
|
||||||
name={n}
|
name={n}
|
||||||
content={htmlToText(md.renderInline(desc))}
|
content={htmlToText(md.renderInline(desc))}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
{["og:image", "twitter:image"].map(
|
{["og:image", "twitter:image"].map(
|
||||||
p => image && <meta key={p} property={p} content={image} />
|
p => image && <meta key={p} property={p} content={image} />,
|
||||||
)}
|
)}
|
||||||
</Helmet>
|
</Helmet>
|
||||||
);
|
);
|
||||||
|
|
|
@ -53,12 +53,12 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
|
||||||
<label
|
<label
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"col-form-label",
|
"col-form-label",
|
||||||
`col-sm-${this.props.multiple ? 3 : 2}`
|
`col-sm-${this.props.multiple ? 3 : 2}`,
|
||||||
)}
|
)}
|
||||||
htmlFor={this.id}
|
htmlFor={this.id}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t(
|
{I18NextService.i18n.t(
|
||||||
this.props.multiple ? "language_plural" : "language"
|
this.props.multiple ? "language_plural" : "language",
|
||||||
)}
|
)}
|
||||||
</label>
|
</label>
|
||||||
{this.props.multiple && this.props.showLanguageWarning && (
|
{this.props.multiple && this.props.showLanguageWarning && (
|
||||||
|
@ -97,7 +97,7 @@ export class LanguageSelect extends Component<LanguageSelectProps, any> {
|
||||||
this.props.siteLanguages,
|
this.props.siteLanguages,
|
||||||
this.props.showAll,
|
this.props.showAll,
|
||||||
this.props.showSite,
|
this.props.showSite,
|
||||||
UserService.Instance.myUserInfo
|
UserService.Instance.myUserInfo,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class ListingTypeSelect extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromProps(
|
static getDerivedStateFromProps(
|
||||||
props: ListingTypeSelectProps
|
props: ListingTypeSelectProps,
|
||||||
): ListingTypeSelectState {
|
): ListingTypeSelectState {
|
||||||
return {
|
return {
|
||||||
type_: props.type_,
|
type_: props.type_,
|
||||||
|
|
|
@ -201,7 +201,7 @@ export class MarkdownTextArea extends Component<
|
||||||
{this.getFormatButton("header", this.handleInsertHeader)}
|
{this.getFormatButton("header", this.handleInsertHeader)}
|
||||||
{this.getFormatButton(
|
{this.getFormatButton(
|
||||||
"strikethrough",
|
"strikethrough",
|
||||||
this.handleInsertStrikethrough
|
this.handleInsertStrikethrough,
|
||||||
)}
|
)}
|
||||||
{this.getFormatButton("quote", this.handleInsertQuote)}
|
{this.getFormatButton("quote", this.handleInsertQuote)}
|
||||||
{this.getFormatButton("list", this.handleInsertList)}
|
{this.getFormatButton("list", this.handleInsertList)}
|
||||||
|
@ -209,7 +209,7 @@ export class MarkdownTextArea extends Component<
|
||||||
{this.getFormatButton("subscript", this.handleInsertSubscript)}
|
{this.getFormatButton("subscript", this.handleInsertSubscript)}
|
||||||
{this.getFormatButton(
|
{this.getFormatButton(
|
||||||
"superscript",
|
"superscript",
|
||||||
this.handleInsertSuperscript
|
this.handleInsertSuperscript,
|
||||||
)}
|
)}
|
||||||
{this.getFormatButton("spoiler", this.handleInsertSpoiler)}
|
{this.getFormatButton("spoiler", this.handleInsertSpoiler)}
|
||||||
<a
|
<a
|
||||||
|
@ -229,7 +229,7 @@ export class MarkdownTextArea extends Component<
|
||||||
"form-control border-0 rounded-top-0 rounded-bottom",
|
"form-control border-0 rounded-top-0 rounded-bottom",
|
||||||
{
|
{
|
||||||
"d-none": this.state.previewMode,
|
"d-none": this.state.previewMode,
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
value={this.state.content}
|
value={this.state.content}
|
||||||
onInput={linkEvent(this, this.handleContentChange)}
|
onInput={linkEvent(this, this.handleContentChange)}
|
||||||
|
@ -328,7 +328,7 @@ export class MarkdownTextArea extends Component<
|
||||||
|
|
||||||
getFormatButton(
|
getFormatButton(
|
||||||
type: NoOptionI18nKeys,
|
type: NoOptionI18nKeys,
|
||||||
handleClick: (i: MarkdownTextArea, event: any) => void
|
handleClick: (i: MarkdownTextArea, event: any) => void,
|
||||||
) {
|
) {
|
||||||
let iconType: string;
|
let iconType: string;
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ export class MarkdownTextArea extends Component<
|
||||||
count: Number(maxUploadImages),
|
count: Number(maxUploadImages),
|
||||||
formattedCount: numToSI(maxUploadImages),
|
formattedCount: numToSI(maxUploadImages),
|
||||||
}),
|
}),
|
||||||
"danger"
|
"danger",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
i.setState({
|
i.setState({
|
||||||
|
@ -424,7 +424,7 @@ export class MarkdownTextArea extends Component<
|
||||||
uploaded: (imageUploadStatus?.uploaded ?? 0) + 1,
|
uploaded: (imageUploadStatus?.uploaded ?? 0) + 1,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errorOccurred = true;
|
errorOccurred = true;
|
||||||
|
@ -560,7 +560,7 @@ export class MarkdownTextArea extends Component<
|
||||||
i.setState({
|
i.setState({
|
||||||
content: `${content?.substring(
|
content: `${content?.substring(
|
||||||
0,
|
0,
|
||||||
start
|
start,
|
||||||
)}[${selectedText}]()${content?.substring(end)}`,
|
)}[${selectedText}]()${content?.substring(end)}`,
|
||||||
});
|
});
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
|
@ -584,7 +584,7 @@ export class MarkdownTextArea extends Component<
|
||||||
simpleSurroundBeforeAfter(
|
simpleSurroundBeforeAfter(
|
||||||
beforeChars: string,
|
beforeChars: string,
|
||||||
afterChars: string,
|
afterChars: string,
|
||||||
emptyChars = "___"
|
emptyChars = "___",
|
||||||
) {
|
) {
|
||||||
const content = this.state.content ?? "";
|
const content = this.state.content ?? "";
|
||||||
if (!this.state.content) {
|
if (!this.state.content) {
|
||||||
|
@ -599,7 +599,7 @@ export class MarkdownTextArea extends Component<
|
||||||
this.setState({
|
this.setState({
|
||||||
content: `${content?.substring(
|
content: `${content?.substring(
|
||||||
0,
|
0,
|
||||||
start
|
start,
|
||||||
)}${beforeChars}${selectedText}${afterChars}${content?.substring(end)}`,
|
)}${beforeChars}${selectedText}${afterChars}${content?.substring(end)}`,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -614,12 +614,12 @@ export class MarkdownTextArea extends Component<
|
||||||
if (start !== end) {
|
if (start !== end) {
|
||||||
textarea.setSelectionRange(
|
textarea.setSelectionRange(
|
||||||
start + beforeChars.length,
|
start + beforeChars.length,
|
||||||
end + afterChars.length
|
end + afterChars.length,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
textarea.setSelectionRange(
|
textarea.setSelectionRange(
|
||||||
start + beforeChars.length,
|
start + beforeChars.length,
|
||||||
end + emptyChars.length + afterChars.length
|
end + emptyChars.length + afterChars.length,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,11 @@ export class MomentTime extends Component<MomentTimeProps, any> {
|
||||||
createdAndModifiedTimes() {
|
createdAndModifiedTimes() {
|
||||||
const updated = this.props.updated;
|
const updated = this.props.updated;
|
||||||
let line = `${capitalizeFirstLetter(
|
let line = `${capitalizeFirstLetter(
|
||||||
I18NextService.i18n.t("created")
|
I18NextService.i18n.t("created"),
|
||||||
)}: ${formatDate(this.props.published)}`;
|
)}: ${formatDate(this.props.published)}`;
|
||||||
if (updated) {
|
if (updated) {
|
||||||
line += `\n\n\n${capitalizeFirstLetter(
|
line += `\n\n\n${capitalizeFirstLetter(
|
||||||
I18NextService.i18n.t("modified")
|
I18NextService.i18n.t("modified"),
|
||||||
)} ${formatDate(updated)}`;
|
)} ${formatDate(updated)}`;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
|
|
|
@ -104,10 +104,10 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> {
|
||||||
id={id}
|
id={id}
|
||||||
onClick={linkEvent(this, handleToggleShow)}
|
onClick={linkEvent(this, handleToggleShow)}
|
||||||
aria-label={I18NextService.i18n.t(
|
aria-label={I18NextService.i18n.t(
|
||||||
`${show ? "show" : "hide"}_password`
|
`${show ? "show" : "hide"}_password`,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
`${show ? "show" : "hide"}_password`
|
`${show ? "show" : "hide"}_password`,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon icon={`eye${show ? "-slash" : ""}`} inline />
|
<Icon icon={`eye${show ? "-slash" : ""}`} inline />
|
||||||
|
@ -116,7 +116,7 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> {
|
||||||
{showStrength && value && (
|
{showStrength && value && (
|
||||||
<div className={this.passwordColorClass}>
|
<div className={this.passwordColorClass}>
|
||||||
{I18NextService.i18n.t(
|
{I18NextService.i18n.t(
|
||||||
this.passwordStrength as NoOptionI18nKeys
|
this.passwordStrength as NoOptionI18nKeys,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -42,7 +42,7 @@ export class RegistrationApplication extends Component<
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<
|
nextProps: Readonly<
|
||||||
{ children?: InfernoNode } & RegistrationApplicationProps
|
{ children?: InfernoNode } & RegistrationApplicationProps
|
||||||
>
|
>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props !== nextProps) {
|
if (this.props !== nextProps) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
|
@ -83,7 +83,7 @@ export class SearchableSelect extends Component<
|
||||||
|
|
||||||
if (props.value) {
|
if (props.value) {
|
||||||
let selectedIndex = props.options.findIndex(
|
let selectedIndex = props.options.findIndex(
|
||||||
({ value }) => value === props.value?.toString()
|
({ value }) => value === props.value?.toString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (selectedIndex < 0) {
|
if (selectedIndex < 0) {
|
||||||
|
@ -140,7 +140,7 @@ export class SearchableSelect extends Component<
|
||||||
(onSearch || searchText.length === 0
|
(onSearch || searchText.length === 0
|
||||||
? options
|
? options
|
||||||
: options.filter(({ label }) =>
|
: options.filter(({ label }) =>
|
||||||
label.toLowerCase().includes(searchText.toLowerCase())
|
label.toLowerCase().includes(searchText.toLowerCase()),
|
||||||
)
|
)
|
||||||
).map((option, index) => (
|
).map((option, index) => (
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -45,7 +45,7 @@ export class UserBadges extends Component<UserBadgesProps> {
|
||||||
<span
|
<span
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"row d-inline-flex gx-1",
|
"row d-inline-flex gx-1",
|
||||||
this.props.classNames
|
this.props.classNames,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{this.props.isBanned && (
|
{this.props.isBanned && (
|
||||||
|
|
|
@ -181,7 +181,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
communityId: cv.community.id,
|
communityId: cv.community.id,
|
||||||
follow: false,
|
follow: false,
|
||||||
},
|
},
|
||||||
this.handleFollow
|
this.handleFollow,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("unsubscribe")}
|
{I18NextService.i18n.t("unsubscribe")}
|
||||||
|
@ -196,7 +196,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
communityId: cv.community.id,
|
communityId: cv.community.id,
|
||||||
follow: true,
|
follow: true,
|
||||||
},
|
},
|
||||||
this.handleFollow
|
this.handleFollow,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("subscribe")}
|
{I18NextService.i18n.t("subscribe")}
|
||||||
|
@ -209,7 +209,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -301,7 +301,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const searchParamEncoded = encodeURIComponent(i.state.searchText);
|
const searchParamEncoded = encodeURIComponent(i.state.searchText);
|
||||||
i.context.router.history.push(
|
i.context.router.history.push(
|
||||||
`/search?q=${searchParamEncoded}&type=Communities`
|
`/search?q=${searchParamEncoded}&type=Communities`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listCommunitiesResponse: await client.listCommunities(
|
listCommunitiesResponse: await client.listCommunities(
|
||||||
listCommunitiesForm
|
listCommunitiesForm,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
) {
|
) {
|
||||||
s.listCommunitiesResponse.data.communities = editCommunity(
|
s.listCommunitiesResponse.data.communities = editCommunity(
|
||||||
res.data.community_view,
|
res.data.community_view,
|
||||||
s.listCommunitiesResponse.data.communities
|
s.listCommunitiesResponse.data.communities,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -231,7 +231,7 @@ export class CommunityForm extends Component<
|
||||||
checked={this.state.form.posting_restricted_to_mods}
|
checked={this.state.form.posting_restricted_to_mods}
|
||||||
onChange={linkEvent(
|
onChange={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleCommunityPostingRestrictedToMods
|
this.handleCommunityPostingRestrictedToMods,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -330,7 +330,7 @@ export class CommunityForm extends Component<
|
||||||
|
|
||||||
handleCommunityPostingRestrictedToMods(i: CommunityForm, event: any) {
|
handleCommunityPostingRestrictedToMods(i: CommunityForm, event: any) {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.form.posting_restricted_to_mods = event.target.checked), s)
|
s => ((s.form.posting_restricted_to_mods = event.target.checked), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -570,7 +570,7 @@ export class Community extends Component<
|
||||||
};
|
};
|
||||||
|
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
`/c/${this.props.match.params.name}${getQueryString(queryParams)}`
|
`/c/${this.props.match.params.name}${getQueryString(queryParams)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.fetchData();
|
await this.fetchData();
|
||||||
|
@ -785,7 +785,7 @@ export class Community extends Component<
|
||||||
|
|
||||||
async handleTransferCommunity(form: TransferCommunity) {
|
async handleTransferCommunity(form: TransferCommunity) {
|
||||||
const transferCommunityRes = await HttpService.client.transferCommunity(
|
const transferCommunityRes = await HttpService.client.transferCommunity(
|
||||||
form
|
form,
|
||||||
);
|
);
|
||||||
toast(I18NextService.i18n.t("transfer_community"));
|
toast(I18NextService.i18n.t("transfer_community"));
|
||||||
this.updateCommunityFull(transferCommunityRes);
|
this.updateCommunityFull(transferCommunityRes);
|
||||||
|
@ -819,14 +819,14 @@ export class Community extends Component<
|
||||||
s.postsRes.data.posts
|
s.postsRes.data.posts
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (s.commentsRes.state === "success") {
|
if (s.commentsRes.state === "success") {
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -886,7 +886,7 @@ export class Community extends Component<
|
||||||
if (s.commentsRes.state === "success" && res.state === "success") {
|
if (s.commentsRes.state === "success" && res.state === "success") {
|
||||||
s.commentsRes.data.comments = editComment(
|
s.commentsRes.data.comments = editComment(
|
||||||
res.data.comment_view,
|
res.data.comment_view,
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments,
|
||||||
);
|
);
|
||||||
s.finished.set(res.data.comment_view.comment.id, true);
|
s.finished.set(res.data.comment_view.comment.id, true);
|
||||||
}
|
}
|
||||||
|
@ -902,7 +902,7 @@ export class Community extends Component<
|
||||||
// Set finished for the parent
|
// Set finished for the parent
|
||||||
s.finished.set(
|
s.finished.set(
|
||||||
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -914,7 +914,7 @@ export class Community extends Component<
|
||||||
if (s.commentsRes.state === "success" && res.state === "success") {
|
if (s.commentsRes.state === "success" && res.state === "success") {
|
||||||
s.commentsRes.data.comments = editWith(
|
s.commentsRes.data.comments = editWith(
|
||||||
res.data.comment_reply_view,
|
res.data.comment_reply_view,
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -926,7 +926,7 @@ export class Community extends Component<
|
||||||
if (s.postsRes.state === "success" && res.state === "success") {
|
if (s.postsRes.state === "success" && res.state === "success") {
|
||||||
s.postsRes.data.posts = editPost(
|
s.postsRes.data.posts = editPost(
|
||||||
res.data.post_view,
|
res.data.post_view,
|
||||||
s.postsRes.data.posts
|
s.postsRes.data.posts,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -79,7 +79,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & SidebarProps>
|
nextProps: Readonly<{ children?: InfernoNode } & SidebarProps>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props.moderators !== nextProps.moderators) {
|
if (this.props.moderators !== nextProps.moderators) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -292,7 +292,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
onClick={linkEvent(this, this.handleBlockCommunity)}
|
onClick={linkEvent(this, this.handleBlockCommunity)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t(
|
{I18NextService.i18n.t(
|
||||||
blocked ? "unblock_community" : "block_community"
|
blocked ? "unblock_community" : "block_community",
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
@ -332,7 +332,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
className="btn btn-link text-muted d-inline-block"
|
className="btn btn-link text-muted d-inline-block"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleShowConfirmLeaveModTeamClick
|
this.handleShowConfirmLeaveModTeamClick,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("leave_mod_team")}
|
{I18NextService.i18n.t("leave_mod_team")}
|
||||||
|
@ -356,7 +356,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
className="btn btn-link text-muted d-inline-block"
|
className="btn btn-link text-muted d-inline-block"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleCancelLeaveModTeamClick
|
this.handleCancelLeaveModTeamClick,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("no")}
|
{I18NextService.i18n.t("no")}
|
||||||
|
|
|
@ -118,8 +118,8 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
Number((this.state.page - 1) * this.itemsPerPage),
|
Number((this.state.page - 1) * this.itemsPerPage),
|
||||||
Number(
|
Number(
|
||||||
(this.state.page - 1) * this.itemsPerPage +
|
(this.state.page - 1) * this.itemsPerPage +
|
||||||
this.itemsPerPage
|
this.itemsPerPage,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.map((cv, index) => (
|
.map((cv, index) => (
|
||||||
<tr key={index} ref={e => (this.scrollRef[cv.shortcode] = e)}>
|
<tr key={index} ref={e => (this.scrollRef[cv.shortcode] = e)}>
|
||||||
|
@ -139,11 +139,11 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
className="btn btn-sm btn-secondary pointer"
|
className="btn btn-sm btn-secondary pointer"
|
||||||
htmlFor={`file-uploader-${index}`}
|
htmlFor={`file-uploader-${index}`}
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"upload_image"
|
"upload_image",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{capitalizeFirstLetter(
|
{capitalizeFirstLetter(
|
||||||
I18NextService.i18n.t("upload")
|
I18NextService.i18n.t("upload"),
|
||||||
)}
|
)}
|
||||||
<input
|
<input
|
||||||
name={`file-uploader-${index}`}
|
name={`file-uploader-${index}`}
|
||||||
|
@ -153,7 +153,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
className="d-none"
|
className="d-none"
|
||||||
onChange={linkEvent(
|
onChange={linkEvent(
|
||||||
{ form: this, index: index },
|
{ form: this, index: index },
|
||||||
this.handleImageUpload
|
this.handleImageUpload,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
@ -168,7 +168,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
value={cv.shortcode}
|
value={cv.shortcode}
|
||||||
onInput={linkEvent(
|
onInput={linkEvent(
|
||||||
{ form: this, index: index },
|
{ form: this, index: index },
|
||||||
this.handleEmojiShortCodeChange
|
this.handleEmojiShortCodeChange,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -180,7 +180,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
value={cv.category}
|
value={cv.category}
|
||||||
onInput={linkEvent(
|
onInput={linkEvent(
|
||||||
{ form: this, index: index },
|
{ form: this, index: index },
|
||||||
this.handleEmojiCategoryChange
|
this.handleEmojiCategoryChange,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -192,7 +192,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
value={cv.image_url}
|
value={cv.image_url}
|
||||||
onInput={linkEvent(
|
onInput={linkEvent(
|
||||||
{ form: this, index: index, overrideValue: null },
|
{ form: this, index: index, overrideValue: null },
|
||||||
this.handleEmojiImageUrlChange
|
this.handleEmojiImageUrlChange,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -204,7 +204,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
value={cv.alt_text}
|
value={cv.alt_text}
|
||||||
onInput={linkEvent(
|
onInput={linkEvent(
|
||||||
{ form: this, index: index },
|
{ form: this, index: index },
|
||||||
this.handleEmojiAltTextChange
|
this.handleEmojiAltTextChange,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -216,7 +216,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
value={cv.keywords}
|
value={cv.keywords}
|
||||||
onInput={linkEvent(
|
onInput={linkEvent(
|
||||||
{ form: this, index: index },
|
{ form: this, index: index },
|
||||||
this.handleEmojiKeywordChange
|
this.handleEmojiKeywordChange,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
@ -231,7 +231,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
}
|
}
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ i: this, cv: cv },
|
{ i: this, cv: cv },
|
||||||
this.handleEditEmojiClick
|
this.handleEditEmojiClick,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t("save")}
|
data-tippy-content={I18NextService.i18n.t("save")}
|
||||||
aria-label={I18NextService.i18n.t("save")}
|
aria-label={I18NextService.i18n.t("save")}
|
||||||
|
@ -241,7 +241,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
capitalizeFirstLetter(
|
capitalizeFirstLetter(
|
||||||
I18NextService.i18n.t("save")
|
I18NextService.i18n.t("save"),
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
@ -250,7 +250,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ i: this, index: index, cv: cv },
|
{ i: this, index: index, cv: cv },
|
||||||
this.handleDeleteEmojiClick
|
this.handleDeleteEmojiClick,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t("delete")}
|
data-tippy-content={I18NextService.i18n.t("delete")}
|
||||||
aria-label={I18NextService.i18n.t("delete")}
|
aria-label={I18NextService.i18n.t("delete")}
|
||||||
|
@ -290,7 +290,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
cv.shortcode.length > 0;
|
cv.shortcode.length > 0;
|
||||||
const noDuplicateShortCodes =
|
const noDuplicateShortCodes =
|
||||||
this.state.customEmojis.filter(
|
this.state.customEmojis.filter(
|
||||||
x => x.shortcode === cv.shortcode && x.id !== cv.id
|
x => x.shortcode === cv.shortcode && x.id !== cv.id,
|
||||||
).length === 0;
|
).length === 0;
|
||||||
return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed;
|
return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
const view = customEmojisLookup.get(e.id);
|
const view = customEmojisLookup.get(e.id);
|
||||||
if (view) {
|
if (view) {
|
||||||
const page = this.state.customEmojis.find(
|
const page = this.state.customEmojis.find(
|
||||||
x => x.id === view.custom_emoji.id
|
x => x.id === view.custom_emoji.id,
|
||||||
)?.page;
|
)?.page;
|
||||||
if (page) {
|
if (page) {
|
||||||
this.setState({ page: page });
|
this.setState({ page: page });
|
||||||
|
@ -319,7 +319,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
|
|
||||||
handleEmojiCategoryChange(
|
handleEmojiCategoryChange(
|
||||||
props: { form: EmojiForm; index: number },
|
props: { form: EmojiForm; index: number },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
const custom_emojis = [...props.form.state.customEmojis];
|
const custom_emojis = [...props.form.state.customEmojis];
|
||||||
const pagedIndex =
|
const pagedIndex =
|
||||||
|
@ -335,7 +335,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
|
|
||||||
handleEmojiShortCodeChange(
|
handleEmojiShortCodeChange(
|
||||||
props: { form: EmojiForm; index: number },
|
props: { form: EmojiForm; index: number },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
const custom_emojis = [...props.form.state.customEmojis];
|
const custom_emojis = [...props.form.state.customEmojis];
|
||||||
const pagedIndex =
|
const pagedIndex =
|
||||||
|
@ -355,7 +355,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
index,
|
index,
|
||||||
overrideValue,
|
overrideValue,
|
||||||
}: { form: EmojiForm; index: number; overrideValue: string | null },
|
}: { form: EmojiForm; index: number; overrideValue: string | null },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
form.setState(prevState => {
|
form.setState(prevState => {
|
||||||
const custom_emojis = [...form.state.customEmojis];
|
const custom_emojis = [...form.state.customEmojis];
|
||||||
|
@ -376,7 +376,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
changed: true,
|
changed: true,
|
||||||
loading: false,
|
loading: false,
|
||||||
}
|
}
|
||||||
: ce
|
: ce,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -384,7 +384,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
|
|
||||||
handleEmojiAltTextChange(
|
handleEmojiAltTextChange(
|
||||||
props: { form: EmojiForm; index: number },
|
props: { form: EmojiForm; index: number },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
const custom_emojis = [...props.form.state.customEmojis];
|
const custom_emojis = [...props.form.state.customEmojis];
|
||||||
const pagedIndex =
|
const pagedIndex =
|
||||||
|
@ -400,7 +400,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
|
|
||||||
handleEmojiKeywordChange(
|
handleEmojiKeywordChange(
|
||||||
props: { form: EmojiForm; index: number },
|
props: { form: EmojiForm; index: number },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
const custom_emojis = [...props.form.state.customEmojis];
|
const custom_emojis = [...props.form.state.customEmojis];
|
||||||
const pagedIndex =
|
const pagedIndex =
|
||||||
|
@ -485,7 +485,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
|
|
||||||
handleImageUpload(
|
handleImageUpload(
|
||||||
{ form, index }: { form: EmojiForm; index: number },
|
{ form, index }: { form: EmojiForm; index: number },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
let file: any;
|
let file: any;
|
||||||
if (event.target) {
|
if (event.target) {
|
||||||
|
@ -498,7 +498,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
form.setState(prevState => ({
|
form.setState(prevState => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
customEmojis: prevState.customEmojis.map((cv, i) =>
|
customEmojis: prevState.customEmojis.map((cv, i) =>
|
||||||
i === index ? { ...cv, loading: true } : cv
|
i === index ? { ...cv, loading: true } : cv,
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
pictrsDeleteToast(file.name, res.data.delete_url as string);
|
pictrsDeleteToast(file.name, res.data.delete_url as string);
|
||||||
form.handleEmojiImageUrlChange(
|
form.handleEmojiImageUrlChange(
|
||||||
{ form: form, index: index, overrideValue: res.data.url as string },
|
{ form: form, index: index, overrideValue: res.data.url as string },
|
||||||
event
|
event,
|
||||||
);
|
);
|
||||||
} else if (res.data.msg === "too_large") {
|
} else if (res.data.msg === "too_large") {
|
||||||
toast(I18NextService.i18n.t("upload_too_large"), "danger");
|
toast(I18NextService.i18n.t("upload_too_large"), "danger");
|
||||||
|
|
|
@ -285,9 +285,8 @@ export class Home extends Component<any, HomeState> {
|
||||||
HomeCacheService.postsRes = postsRes;
|
HomeCacheService.postsRes = postsRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state.tagline = getRandomFromList(
|
this.state.tagline = getRandomFromList(this.state?.siteRes?.taglines ?? [])
|
||||||
this.state?.siteRes?.taglines ?? []
|
?.content;
|
||||||
)?.content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -298,7 +297,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
if (
|
if (
|
||||||
!this.state.isIsomorphic ||
|
!this.state.isIsomorphic ||
|
||||||
!Object.values(this.isoData.routeData).some(
|
!Object.values(this.isoData.routeData).some(
|
||||||
res => res.state === "success" || res.state === "failed"
|
res => res.state === "success" || res.state === "failed",
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
|
await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
|
||||||
|
@ -359,7 +358,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
trendingCommunitiesRes: await client.listCommunities(
|
trendingCommunitiesRes: await client.listCommunities(
|
||||||
trendingCommunitiesForm
|
trendingCommunitiesForm,
|
||||||
),
|
),
|
||||||
commentsRes,
|
commentsRes,
|
||||||
postsRes,
|
postsRes,
|
||||||
|
@ -777,7 +776,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
<div className="col-auto ps-0">
|
<div className="col-auto ps-0">
|
||||||
{getRss(
|
{getRss(
|
||||||
listingType ??
|
listingType ??
|
||||||
this.state.siteRes.site_view.local_site.default_post_listing_type
|
this.state.siteRes.site_view.local_site.default_post_listing_type,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1034,14 +1033,14 @@ export class Home extends Component<any, HomeState> {
|
||||||
s.postsRes.data.posts
|
s.postsRes.data.posts
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (s.commentsRes.state === "success") {
|
if (s.commentsRes.state === "success") {
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1080,7 +1079,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
if (s.commentsRes.state === "success" && res.state === "success") {
|
if (s.commentsRes.state === "success" && res.state === "success") {
|
||||||
s.commentsRes.data.comments = editComment(
|
s.commentsRes.data.comments = editComment(
|
||||||
res.data.comment_view,
|
res.data.comment_view,
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments,
|
||||||
);
|
);
|
||||||
s.finished.set(res.data.comment_view.comment.id, true);
|
s.finished.set(res.data.comment_view.comment.id, true);
|
||||||
}
|
}
|
||||||
|
@ -1096,7 +1095,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
// Set finished for the parent
|
// Set finished for the parent
|
||||||
s.finished.set(
|
s.finished.set(
|
||||||
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1108,7 +1107,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
if (s.commentsRes.state === "success" && res.state === "success") {
|
if (s.commentsRes.state === "success" && res.state === "success") {
|
||||||
s.commentsRes.data.comments = editWith(
|
s.commentsRes.data.comments = editWith(
|
||||||
res.data.comment_reply_view,
|
res.data.comment_reply_view,
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1120,7 +1119,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
if (s.postsRes.state === "success" && res.state === "success") {
|
if (s.postsRes.state === "success" && res.state === "success") {
|
||||||
s.postsRes.data.posts = editPost(
|
s.postsRes.data.posts = editPost(
|
||||||
res.data.post_view,
|
res.data.post_view,
|
||||||
s.postsRes.data.posts
|
s.postsRes.data.posts,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class LoginReset extends Component<any, State> {
|
||||||
|
|
||||||
get documentTitle(): string {
|
get documentTitle(): string {
|
||||||
return `${capitalizeFirstLetter(
|
return `${capitalizeFirstLetter(
|
||||||
I18NextService.i18n.t("forgot_password")
|
I18NextService.i18n.t("forgot_password"),
|
||||||
)} - ${this.state.siteRes.site_view.site.name}`;
|
)} - ${this.state.siteRes.site_view.site.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ function RateLimits({
|
||||||
|
|
||||||
function handleRateLimitChange(
|
function handleRateLimitChange(
|
||||||
{ rateLimitType, ctx }: { rateLimitType: string; ctx: RateLimitsForm },
|
{ rateLimitType, ctx }: { rateLimitType: string; ctx: RateLimitsForm },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
ctx.setState(prev => ({
|
ctx.setState(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
|
@ -101,7 +101,7 @@ function handleRateLimitChange(
|
||||||
|
|
||||||
function handlePerSecondChange(
|
function handlePerSecondChange(
|
||||||
{ rateLimitType, ctx }: { rateLimitType: string; ctx: RateLimitsForm },
|
{ rateLimitType, ctx }: { rateLimitType: string; ctx: RateLimitsForm },
|
||||||
event: any
|
event: any,
|
||||||
) {
|
) {
|
||||||
ctx.setState(prev => ({
|
ctx.setState(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
|
@ -122,7 +122,7 @@ function submitRateLimitForm(i: RateLimitsForm, event: any) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
auth,
|
auth,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
i.props.onSaveSite(form);
|
i.props.onSaveSite(form);
|
||||||
|
@ -159,11 +159,11 @@ export default class RateLimitsForm extends Component<
|
||||||
})}
|
})}
|
||||||
handleRateLimit={linkEvent(
|
handleRateLimit={linkEvent(
|
||||||
{ rateLimitType, ctx: this },
|
{ rateLimitType, ctx: this },
|
||||||
handleRateLimitChange
|
handleRateLimitChange,
|
||||||
)}
|
)}
|
||||||
handleRateLimitPerSecond={linkEvent(
|
handleRateLimitPerSecond={linkEvent(
|
||||||
{ rateLimitType, ctx: this },
|
{ rateLimitType, ctx: this },
|
||||||
handlePerSecondChange
|
handlePerSecondChange,
|
||||||
)}
|
)}
|
||||||
rateLimitValue={this.state.form[rateLimitType]}
|
rateLimitValue={this.state.form[rateLimitType]}
|
||||||
rateLimitPerSecondValue={
|
rateLimitPerSecondValue={
|
||||||
|
|
|
@ -85,7 +85,7 @@ export class Signup extends Component<any, State> {
|
||||||
|
|
||||||
titleName(siteView: SiteView): string {
|
titleName(siteView: SiteView): string {
|
||||||
return I18NextService.i18n.t(
|
return I18NextService.i18n.t(
|
||||||
siteView.local_site.private_instance ? "apply_to_join" : "sign_up"
|
siteView.local_site.private_instance ? "apply_to_join" : "sign_up",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ export class Signup extends Component<any, State> {
|
||||||
<div
|
<div
|
||||||
className="md-div"
|
className="md-div"
|
||||||
dangerouslySetInnerHTML={mdToHtml(
|
dangerouslySetInnerHTML={mdToHtml(
|
||||||
siteView.local_site.application_question
|
siteView.local_site.application_question,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -311,7 +311,7 @@ export class Signup extends Component<any, State> {
|
||||||
value={this.state.form.captcha_answer}
|
value={this.state.form.captcha_answer}
|
||||||
onInput={linkEvent(
|
onInput={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleRegisterCaptchaAnswerChange
|
this.handleRegisterCaptchaAnswerChange,
|
||||||
)}
|
)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -319,7 +319,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
checked={this.state.siteForm.community_creation_admin_only}
|
checked={this.state.siteForm.community_creation_admin_only}
|
||||||
onChange={linkEvent(
|
onChange={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleSiteCommunityCreationAdminOnly
|
this.handleSiteCommunityCreationAdminOnly,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
|
@ -341,7 +341,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
checked={this.state.siteForm.require_email_verification}
|
checked={this.state.siteForm.require_email_verification}
|
||||||
onChange={linkEvent(
|
onChange={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleSiteRequireEmailVerification
|
this.handleSiteRequireEmailVerification,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
|
@ -363,7 +363,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
checked={this.state.siteForm.application_email_admins}
|
checked={this.state.siteForm.application_email_admins}
|
||||||
onChange={linkEvent(
|
onChange={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleSiteApplicationEmailAdmins
|
this.handleSiteApplicationEmailAdmins,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
|
@ -631,7 +631,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(
|
componentDidUpdate(
|
||||||
prevProps: Readonly<{ children?: InfernoNode } & SiteFormProps>
|
prevProps: Readonly<{ children?: InfernoNode } & SiteFormProps>,
|
||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
|
@ -694,7 +694,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
className="btn btn-sm bg-danger"
|
className="btn btn-sm bg-danger"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ key, instance },
|
{ key, instance },
|
||||||
this.handleRemoveInstance
|
this.handleRemoveInstance,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
|
@ -722,7 +722,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
|
|
||||||
handleInstanceEnterPress(
|
handleInstanceEnterPress(
|
||||||
key: InstanceKey,
|
key: InstanceKey,
|
||||||
event: InfernoKeyboardEvent<HTMLInputElement>
|
event: InfernoKeyboardEvent<HTMLInputElement>,
|
||||||
) {
|
) {
|
||||||
if (event.code.toLowerCase() === "enter") {
|
if (event.code.toLowerCase() === "enter") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -863,7 +863,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
handleDeleteTaglineClick(
|
handleDeleteTaglineClick(
|
||||||
i: SiteForm,
|
i: SiteForm,
|
||||||
index: number,
|
index: number,
|
||||||
event: InfernoMouseEvent<HTMLButtonElement>
|
event: InfernoMouseEvent<HTMLButtonElement>,
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const taglines = i.state.siteForm.taglines;
|
const taglines = i.state.siteForm.taglines;
|
||||||
|
@ -878,7 +878,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
|
|
||||||
handleAddTaglineClick(
|
handleAddTaglineClick(
|
||||||
i: SiteForm,
|
i: SiteForm,
|
||||||
event: InfernoMouseEvent<HTMLButtonElement>
|
event: InfernoMouseEvent<HTMLButtonElement>,
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!i.state.siteForm.taglines) {
|
if (!i.state.siteForm.taglines) {
|
||||||
|
@ -969,7 +969,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
|
|
||||||
handleSiteActorNameMaxLength(i: SiteForm, event: any) {
|
handleSiteActorNameMaxLength(i: SiteForm, event: any) {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.siteForm.actor_name_max_length = Number(event.target.value)), s)
|
s => ((s.siteForm.actor_name_max_length = Number(event.target.value)), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ i: this, index: index },
|
{ i: this, index: index },
|
||||||
this.handleEditTaglineClick
|
this.handleEditTaglineClick,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t("edit")}
|
data-tippy-content={I18NextService.i18n.t("edit")}
|
||||||
aria-label={I18NextService.i18n.t("edit")}
|
aria-label={I18NextService.i18n.t("edit")}
|
||||||
|
@ -78,7 +78,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
|
||||||
className="btn btn-link btn-animate text-muted"
|
className="btn btn-link btn-animate text-muted"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ i: this, index: index },
|
{ i: this, index: index },
|
||||||
this.handleDeleteTaglineClick
|
this.handleDeleteTaglineClick,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t("delete")}
|
data-tippy-content={I18NextService.i18n.t("delete")}
|
||||||
aria-label={I18NextService.i18n.t("delete")}
|
aria-label={I18NextService.i18n.t("delete")}
|
||||||
|
@ -157,7 +157,7 @@ export class TaglineForm extends Component<TaglineFormProps, TaglineFormState> {
|
||||||
|
|
||||||
handleAddTaglineClick(
|
handleAddTaglineClick(
|
||||||
i: TaglineForm,
|
i: TaglineForm,
|
||||||
event: InfernoMouseEvent<HTMLButtonElement>
|
event: InfernoMouseEvent<HTMLButtonElement>,
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const newTaglines = [...i.state.taglines];
|
const newTaglines = [...i.state.taglines];
|
||||||
|
|
|
@ -121,7 +121,7 @@ function getActionFromString(action?: string): ModlogActionType {
|
||||||
const getModlogActionMapper =
|
const getModlogActionMapper =
|
||||||
(
|
(
|
||||||
actionType: ModlogActionType,
|
actionType: ModlogActionType,
|
||||||
getAction: (view: View) => { id: number; when_: string }
|
getAction: (view: View) => { id: number; when_: string },
|
||||||
) =>
|
) =>
|
||||||
(view: View & { moderator?: Person; admin?: Person }): ModlogType => {
|
(view: View & { moderator?: Person; admin?: Person }): ModlogType => {
|
||||||
const { id, when_ } = getAction(view);
|
const { id, when_ } = getAction(view);
|
||||||
|
@ -155,111 +155,111 @@ function buildCombined({
|
||||||
.map(
|
.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModRemovePost",
|
"ModRemovePost",
|
||||||
({ mod_remove_post }: ModRemovePostView) => mod_remove_post
|
({ mod_remove_post }: ModRemovePostView) => mod_remove_post,
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
locked_posts.map(
|
locked_posts.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModLockPost",
|
"ModLockPost",
|
||||||
({ mod_lock_post }: ModLockPostView) => mod_lock_post
|
({ mod_lock_post }: ModLockPostView) => mod_lock_post,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
featured_posts.map(
|
featured_posts.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModFeaturePost",
|
"ModFeaturePost",
|
||||||
({ mod_feature_post }: ModFeaturePostView) => mod_feature_post
|
({ mod_feature_post }: ModFeaturePostView) => mod_feature_post,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
removed_comments.map(
|
removed_comments.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModRemoveComment",
|
"ModRemoveComment",
|
||||||
({ mod_remove_comment }: ModRemoveCommentView) => mod_remove_comment
|
({ mod_remove_comment }: ModRemoveCommentView) => mod_remove_comment,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
removed_communities.map(
|
removed_communities.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModRemoveCommunity",
|
"ModRemoveCommunity",
|
||||||
({ mod_remove_community }: ModRemoveCommunityView) =>
|
({ mod_remove_community }: ModRemoveCommunityView) =>
|
||||||
mod_remove_community
|
mod_remove_community,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
banned_from_community.map(
|
banned_from_community.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModBanFromCommunity",
|
"ModBanFromCommunity",
|
||||||
({ mod_ban_from_community }: ModBanFromCommunityView) =>
|
({ mod_ban_from_community }: ModBanFromCommunityView) =>
|
||||||
mod_ban_from_community
|
mod_ban_from_community,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
added_to_community.map(
|
added_to_community.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModAddCommunity",
|
"ModAddCommunity",
|
||||||
({ mod_add_community }: ModAddCommunityView) => mod_add_community
|
({ mod_add_community }: ModAddCommunityView) => mod_add_community,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
transferred_to_community.map(
|
transferred_to_community.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"ModTransferCommunity",
|
"ModTransferCommunity",
|
||||||
({ mod_transfer_community }: ModTransferCommunityView) =>
|
({ mod_transfer_community }: ModTransferCommunityView) =>
|
||||||
mod_transfer_community
|
mod_transfer_community,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
added.map(
|
added.map(
|
||||||
getModlogActionMapper("ModAdd", ({ mod_add }: ModAddView) => mod_add)
|
getModlogActionMapper("ModAdd", ({ mod_add }: ModAddView) => mod_add),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
banned.map(
|
banned.map(
|
||||||
getModlogActionMapper("ModBan", ({ mod_ban }: ModBanView) => mod_ban)
|
getModlogActionMapper("ModBan", ({ mod_ban }: ModBanView) => mod_ban),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
admin_purged_persons.map(
|
admin_purged_persons.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"AdminPurgePerson",
|
"AdminPurgePerson",
|
||||||
({ admin_purge_person }: AdminPurgePersonView) => admin_purge_person
|
({ admin_purge_person }: AdminPurgePersonView) => admin_purge_person,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
admin_purged_communities.map(
|
admin_purged_communities.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"AdminPurgeCommunity",
|
"AdminPurgeCommunity",
|
||||||
({ admin_purge_community }: AdminPurgeCommunityView) =>
|
({ admin_purge_community }: AdminPurgeCommunityView) =>
|
||||||
admin_purge_community
|
admin_purge_community,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
admin_purged_posts.map(
|
admin_purged_posts.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"AdminPurgePost",
|
"AdminPurgePost",
|
||||||
({ admin_purge_post }: AdminPurgePostView) => admin_purge_post
|
({ admin_purge_post }: AdminPurgePostView) => admin_purge_post,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
admin_purged_comments.map(
|
admin_purged_comments.map(
|
||||||
getModlogActionMapper(
|
getModlogActionMapper(
|
||||||
"AdminPurgeComment",
|
"AdminPurgeComment",
|
||||||
({ admin_purge_comment }: AdminPurgeCommentView) =>
|
({ admin_purge_comment }: AdminPurgeCommentView) =>
|
||||||
admin_purge_comment
|
admin_purge_comment,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Sort them by time
|
// Sort them by time
|
||||||
|
@ -622,7 +622,7 @@ async function createNewOptions({
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
const selectedUser = oldOptions.find(
|
const selectedUser = oldOptions.find(
|
||||||
({ value }) => value === id.toString()
|
({ value }) => value === id.toString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (selectedUser) {
|
if (selectedUser) {
|
||||||
|
@ -634,7 +634,7 @@ async function createNewOptions({
|
||||||
newOptions.push(
|
newOptions.push(
|
||||||
...(await fetchUsers(text))
|
...(await fetchUsers(text))
|
||||||
.slice(0, Number(fetchLimit))
|
.slice(0, Number(fetchLimit))
|
||||||
.map<Choice>(personToChoice)
|
.map<Choice>(personToChoice),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ export class Modlog extends Component<
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
props: RouteComponentProps<{ communityId?: string }>,
|
props: RouteComponentProps<{ communityId?: string }>,
|
||||||
context: any
|
context: any,
|
||||||
) {
|
) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
this.handlePageChange = this.handlePageChange.bind(this);
|
this.handlePageChange = this.handlePageChange.bind(this);
|
||||||
|
@ -731,7 +731,7 @@ export class Modlog extends Component<
|
||||||
modOrAdminText(person?: Person): string {
|
modOrAdminText(person?: Person): string {
|
||||||
return person &&
|
return person &&
|
||||||
this.isoData.site_res.admins.some(
|
this.isoData.site_res.admins.some(
|
||||||
({ person: { id } }) => id === person.id
|
({ person: { id } }) => id === person.id,
|
||||||
)
|
)
|
||||||
? I18NextService.i18n.t("admin")
|
? I18NextService.i18n.t("admin")
|
||||||
: I18NextService.i18n.t("mod");
|
: I18NextService.i18n.t("mod");
|
||||||
|
@ -939,8 +939,8 @@ export class Modlog extends Component<
|
||||||
|
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
`/modlog${communityId ? `/${communityId}` : ""}${getQueryString(
|
`/modlog${communityId ? `/${communityId}` : ""}${getQueryString(
|
||||||
queryParams
|
queryParams,
|
||||||
)}`
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.refetch();
|
await this.refetch();
|
||||||
|
|
|
@ -188,7 +188,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
const mui = UserService.Instance.myUserInfo;
|
const mui = UserService.Instance.myUserInfo;
|
||||||
return mui
|
return mui
|
||||||
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
|
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
|
||||||
"inbox"
|
"inbox",
|
||||||
)} - ${this.state.siteRes.site_view.site.name}`
|
)} - ${this.state.siteRes.site_view.site.name}`
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
capitalizeFirstLetter(
|
capitalizeFirstLetter(
|
||||||
I18NextService.i18n.t("mark_all_as_read")
|
I18NextService.i18n.t("mark_all_as_read"),
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
@ -455,12 +455,12 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
const messages: ReplyType[] =
|
const messages: ReplyType[] =
|
||||||
this.state.messagesRes.state === "success"
|
this.state.messagesRes.state === "success"
|
||||||
? this.state.messagesRes.data.private_messages.map(
|
? this.state.messagesRes.data.private_messages.map(
|
||||||
this.messageToReplyType
|
this.messageToReplyType,
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
return [...replies, ...mentions, ...messages].sort((a, b) =>
|
return [...replies, ...mentions, ...messages].sort((a, b) =>
|
||||||
b.published.localeCompare(a.published)
|
b.published.localeCompare(a.published),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,7 +960,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
this.setState(s => {
|
this.setState(s => {
|
||||||
if (s.messagesRes.state === "success" && res.state === "success") {
|
if (s.messagesRes.state === "success" && res.state === "success") {
|
||||||
s.messagesRes.data.private_messages.unshift(
|
s.messagesRes.data.private_messages.unshift(
|
||||||
res.data.private_message_view
|
res.data.private_message_view,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -973,7 +973,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
if (s.messagesRes.state === "success" && res.state === "success") {
|
if (s.messagesRes.state === "success" && res.state === "success") {
|
||||||
s.messagesRes.data.private_messages = editPrivateMessage(
|
s.messagesRes.data.private_messages = editPrivateMessage(
|
||||||
res.data.private_message_view,
|
res.data.private_message_view,
|
||||||
s.messagesRes.data.private_messages
|
s.messagesRes.data.private_messages,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -988,14 +988,14 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
s.repliesRes.data.replies
|
s.repliesRes.data.replies
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (s.mentionsRes.state === "success") {
|
if (s.mentionsRes.state === "success") {
|
||||||
s.mentionsRes.data.mentions
|
s.mentionsRes.data.mentions
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1030,7 +1030,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
reportToast(
|
reportToast(
|
||||||
res: RequestState<PrivateMessageReportResponse | CommentReportResponse>
|
res: RequestState<PrivateMessageReportResponse | CommentReportResponse>,
|
||||||
) {
|
) {
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
toast(I18NextService.i18n.t("report_created"));
|
toast(I18NextService.i18n.t("report_created"));
|
||||||
|
@ -1044,19 +1044,19 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
if (s.repliesRes.state === "success") {
|
if (s.repliesRes.state === "success") {
|
||||||
s.repliesRes.data.replies = editWith(
|
s.repliesRes.data.replies = editWith(
|
||||||
res.data.comment_view,
|
res.data.comment_view,
|
||||||
s.repliesRes.data.replies
|
s.repliesRes.data.replies,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (s.mentionsRes.state === "success") {
|
if (s.mentionsRes.state === "success") {
|
||||||
s.mentionsRes.data.mentions = editWith(
|
s.mentionsRes.data.mentions = editWith(
|
||||||
res.data.comment_view,
|
res.data.comment_view,
|
||||||
s.mentionsRes.data.mentions
|
s.mentionsRes.data.mentions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Set finished for the parent
|
// Set finished for the parent
|
||||||
s.finished.set(
|
s.finished.set(
|
||||||
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
return s;
|
return s;
|
||||||
});
|
});
|
||||||
|
@ -1068,7 +1068,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
if (s.repliesRes.state === "success" && res.state === "success") {
|
if (s.repliesRes.state === "success" && res.state === "success") {
|
||||||
s.repliesRes.data.replies = editCommentReply(
|
s.repliesRes.data.replies = editCommentReply(
|
||||||
res.data.comment_reply_view,
|
res.data.comment_reply_view,
|
||||||
s.repliesRes.data.replies
|
s.repliesRes.data.replies,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1080,7 +1080,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
if (s.mentionsRes.state === "success" && res.state === "success") {
|
if (s.mentionsRes.state === "success" && res.state === "success") {
|
||||||
s.mentionsRes.data.mentions = editMention(
|
s.mentionsRes.data.mentions = editMention(
|
||||||
res.data.person_mention_view,
|
res.data.person_mention_view,
|
||||||
s.mentionsRes.data.mentions
|
s.mentionsRes.data.mentions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -57,7 +57,7 @@ export class PersonListing extends Component<PersonListingProps, any> {
|
||||||
{
|
{
|
||||||
"text-muted": this.props.muted,
|
"text-muted": this.props.muted,
|
||||||
"text-info": !this.props.muted,
|
"text-info": !this.props.muted,
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
to={link}
|
to={link}
|
||||||
>
|
>
|
||||||
|
|
|
@ -132,7 +132,7 @@ function getViewFromProps(view?: string): PersonDetailsView {
|
||||||
|
|
||||||
const getCommunitiesListing = (
|
const getCommunitiesListing = (
|
||||||
translationKey: NoOptionI18nKeys,
|
translationKey: NoOptionI18nKeys,
|
||||||
communityViews?: { community: Community }[]
|
communityViews?: { community: Community }[],
|
||||||
) =>
|
) =>
|
||||||
communityViews &&
|
communityViews &&
|
||||||
communityViews.length > 0 && (
|
communityViews.length > 0 && (
|
||||||
|
@ -266,7 +266,7 @@ export class Profile extends Component<
|
||||||
if (mui && res.state === "success") {
|
if (mui && res.state === "success") {
|
||||||
this.setState({
|
this.setState({
|
||||||
personBlocked: mui.person_blocks.some(
|
personBlocked: mui.person_blocks.some(
|
||||||
({ target: { id } }) => id === res.data.person_view.person.id
|
({ target: { id } }) => id === res.data.person_view.person.id,
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ export class Profile extends Component<
|
||||||
}
|
}
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
pv.person.id,
|
pv.person.id,
|
||||||
this.handleUnblockPerson
|
this.handleUnblockPerson,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("unblock_user")}
|
{I18NextService.i18n.t("unblock_user")}
|
||||||
|
@ -542,7 +542,7 @@ export class Profile extends Component<
|
||||||
}
|
}
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
pv.person.id,
|
pv.person.id,
|
||||||
this.handleBlockPerson
|
this.handleBlockPerson,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("block_user")}
|
{I18NextService.i18n.t("block_user")}
|
||||||
|
@ -962,13 +962,13 @@ export class Profile extends Component<
|
||||||
s.personRes.data.posts
|
s.personRes.data.posts
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
|
|
||||||
s.personRes.data.comments
|
s.personRes.data.comments
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1006,7 +1006,7 @@ export class Profile extends Component<
|
||||||
if (s.personRes.state === "success" && res.state === "success") {
|
if (s.personRes.state === "success" && res.state === "success") {
|
||||||
s.personRes.data.comments = editComment(
|
s.personRes.data.comments = editComment(
|
||||||
res.data.comment_view,
|
res.data.comment_view,
|
||||||
s.personRes.data.comments
|
s.personRes.data.comments,
|
||||||
);
|
);
|
||||||
s.finished.set(res.data.comment_view.comment.id, true);
|
s.finished.set(res.data.comment_view.comment.id, true);
|
||||||
}
|
}
|
||||||
|
@ -1021,7 +1021,7 @@ export class Profile extends Component<
|
||||||
// Set finished for the parent
|
// Set finished for the parent
|
||||||
s.finished.set(
|
s.finished.set(
|
||||||
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1033,7 +1033,7 @@ export class Profile extends Component<
|
||||||
if (s.personRes.state === "success" && res.state === "success") {
|
if (s.personRes.state === "success" && res.state === "success") {
|
||||||
s.personRes.data.comments = editWith(
|
s.personRes.data.comments = editWith(
|
||||||
res.data.comment_reply_view,
|
res.data.comment_reply_view,
|
||||||
s.personRes.data.comments
|
s.personRes.data.comments,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1045,7 +1045,7 @@ export class Profile extends Component<
|
||||||
if (s.personRes.state === "success" && res.state === "success") {
|
if (s.personRes.state === "success" && res.state === "success") {
|
||||||
s.personRes.data.posts = editPost(
|
s.personRes.data.posts = editPost(
|
||||||
res.data.post_view,
|
res.data.post_view,
|
||||||
s.personRes.data.posts
|
s.personRes.data.posts,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -80,7 +80,7 @@ export class RegistrationApplications extends Component<
|
||||||
const mui = UserService.Instance.myUserInfo;
|
const mui = UserService.Instance.myUserInfo;
|
||||||
return mui
|
return mui
|
||||||
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
|
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
|
||||||
"registration_applications"
|
"registration_applications",
|
||||||
)} - ${this.state.siteRes.site_view.site.name}`
|
)} - ${this.state.siteRes.site_view.site.name}`
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
@ -236,13 +236,13 @@ export class RegistrationApplications extends Component<
|
||||||
|
|
||||||
async handleApproveApplication(form: ApproveRegistrationApplication) {
|
async handleApproveApplication(form: ApproveRegistrationApplication) {
|
||||||
const approveRes = await HttpService.client.approveRegistrationApplication(
|
const approveRes = await HttpService.client.approveRegistrationApplication(
|
||||||
form
|
form,
|
||||||
);
|
);
|
||||||
this.setState(s => {
|
this.setState(s => {
|
||||||
if (s.appsRes.state === "success" && approveRes.state === "success") {
|
if (s.appsRes.state === "success" && approveRes.state === "success") {
|
||||||
s.appsRes.data.registration_applications = editRegistrationApplication(
|
s.appsRes.data.registration_applications = editRegistrationApplication(
|
||||||
approveRes.data.registration_application,
|
approveRes.data.registration_application,
|
||||||
s.appsRes.data.registration_applications
|
s.appsRes.data.registration_applications,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -140,7 +140,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
const mui = UserService.Instance.myUserInfo;
|
const mui = UserService.Instance.myUserInfo;
|
||||||
return mui
|
return mui
|
||||||
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
|
? `@${mui.local_user_view.person.name} ${I18NextService.i18n.t(
|
||||||
"reports"
|
"reports",
|
||||||
)} - ${this.state.siteRes.site_view.site.name}`
|
)} - ${this.state.siteRes.site_view.site.name}`
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
@ -365,12 +365,12 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
const privateMessages =
|
const privateMessages =
|
||||||
pmRes.state === "success"
|
pmRes.state === "success"
|
||||||
? pmRes.data.private_message_reports.map(
|
? pmRes.data.private_message_reports.map(
|
||||||
this.privateMessageReportToItemType
|
this.privateMessageReportToItemType,
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
return [...comments, ...posts, ...privateMessages].sort((a, b) =>
|
return [...comments, ...posts, ...privateMessages].sort((a, b) =>
|
||||||
b.published.localeCompare(a.published)
|
b.published.localeCompare(a.published),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
data.messageReportsRes = await client.listPrivateMessageReports(
|
data.messageReportsRes = await client.listPrivateMessageReports(
|
||||||
privateMessageReportsForm
|
privateMessageReportsForm,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,7 +594,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
if (amAdmin()) {
|
if (amAdmin()) {
|
||||||
this.setState({
|
this.setState({
|
||||||
messageReportsRes: await HttpService.client.listPrivateMessageReports(
|
messageReportsRes: await HttpService.client.listPrivateMessageReports(
|
||||||
form
|
form,
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -620,7 +620,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
if (s.commentReportsRes.state === "success" && res.state === "success") {
|
if (s.commentReportsRes.state === "success" && res.state === "success") {
|
||||||
s.commentReportsRes.data.comment_reports = editCommentReport(
|
s.commentReportsRes.data.comment_reports = editCommentReport(
|
||||||
res.data.comment_report_view,
|
res.data.comment_report_view,
|
||||||
s.commentReportsRes.data.comment_reports
|
s.commentReportsRes.data.comment_reports,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -632,7 +632,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
if (s.postReportsRes.state === "success" && res.state === "success") {
|
if (s.postReportsRes.state === "success" && res.state === "success") {
|
||||||
s.postReportsRes.data.post_reports = editPostReport(
|
s.postReportsRes.data.post_reports = editPostReport(
|
||||||
res.data.post_report_view,
|
res.data.post_report_view,
|
||||||
s.postReportsRes.data.post_reports
|
s.postReportsRes.data.post_reports,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -640,14 +640,14 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
findAndUpdatePrivateMessageReport(
|
findAndUpdatePrivateMessageReport(
|
||||||
res: RequestState<PrivateMessageReportResponse>
|
res: RequestState<PrivateMessageReportResponse>,
|
||||||
) {
|
) {
|
||||||
this.setState(s => {
|
this.setState(s => {
|
||||||
if (s.messageReportsRes.state === "success" && res.state === "success") {
|
if (s.messageReportsRes.state === "success" && res.state === "success") {
|
||||||
s.messageReportsRes.data.private_message_reports =
|
s.messageReportsRes.data.private_message_reports =
|
||||||
editPrivateMessageReport(
|
editPrivateMessageReport(
|
||||||
res.data.private_message_report_view,
|
res.data.private_message_report_view,
|
||||||
s.messageReportsRes.data.private_message_reports
|
s.messageReportsRes.data.private_message_reports,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -391,7 +391,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
className="btn btn-sm"
|
className="btn btn-sm"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ ctx: this, recipientId: pb.target.id },
|
{ ctx: this, recipientId: pb.target.id },
|
||||||
this.handleUnblockPerson
|
this.handleUnblockPerson,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t("unblock_user")}
|
data-tippy-content={I18NextService.i18n.t("unblock_user")}
|
||||||
>
|
>
|
||||||
|
@ -435,10 +435,10 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
className="btn btn-sm"
|
className="btn btn-sm"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ ctx: this, communityId: cb.community.id },
|
{ ctx: this, communityId: cb.community.id },
|
||||||
this.handleUnblockCommunity
|
this.handleUnblockCommunity,
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"unblock_community"
|
"unblock_community",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon icon="x" classes="icon-inline" />
|
<Icon icon="x" classes="icon-inline" />
|
||||||
|
@ -767,7 +767,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
}
|
}
|
||||||
onChange={linkEvent(
|
onChange={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleSendNotificationsToEmailChange
|
this.handleSendNotificationsToEmailChange,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
|
@ -798,7 +798,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
className="btn d-block btn-danger"
|
className="btn d-block btn-danger"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleDeleteAccountShowConfirmToggle
|
this.handleDeleteAccountShowConfirmToggle,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("delete_account")}
|
{I18NextService.i18n.t("delete_account")}
|
||||||
|
@ -817,7 +817,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
value={this.state.deleteAccountForm.password}
|
value={this.state.deleteAccountForm.password}
|
||||||
onInput={linkEvent(
|
onInput={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleDeleteAccountPasswordChange
|
this.handleDeleteAccountPasswordChange,
|
||||||
)}
|
)}
|
||||||
className="my-2"
|
className="my-2"
|
||||||
/>
|
/>
|
||||||
|
@ -837,7 +837,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
type="button"
|
type="button"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleDeleteAccountShowConfirmToggle
|
this.handleDeleteAccountShowConfirmToggle,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("cancel")}
|
{I18NextService.i18n.t("cancel")}
|
||||||
|
@ -924,7 +924,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
|
|
||||||
if (text.length > 0) {
|
if (text.length > 0) {
|
||||||
searchCommunityOptions.push(
|
searchCommunityOptions.push(
|
||||||
...(await fetchCommunities(text)).map(communityToChoice)
|
...(await fetchCommunities(text)).map(communityToChoice),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
|
|
||||||
handleShowNsfwChange(i: Settings, event: any) {
|
handleShowNsfwChange(i: Settings, event: any) {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.show_nsfw = event.target.checked), s)
|
s => ((s.saveUserSettingsForm.show_nsfw = event.target.checked), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -995,13 +995,13 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
mui.local_user_view.local_user.show_avatars = event.target.checked;
|
mui.local_user_view.local_user.show_avatars = event.target.checked;
|
||||||
}
|
}
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.show_avatars = event.target.checked), s)
|
s => ((s.saveUserSettingsForm.show_avatars = event.target.checked), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBotAccount(i: Settings, event: any) {
|
handleBotAccount(i: Settings, event: any) {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.bot_account = event.target.checked), s)
|
s => ((s.saveUserSettingsForm.bot_account = event.target.checked), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1009,13 +1009,13 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => (
|
s => (
|
||||||
(s.saveUserSettingsForm.show_bot_accounts = event.target.checked), s
|
(s.saveUserSettingsForm.show_bot_accounts = event.target.checked), s
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleReadPosts(i: Settings, event: any) {
|
handleReadPosts(i: Settings, event: any) {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.show_read_posts = event.target.checked), s)
|
s => ((s.saveUserSettingsForm.show_read_posts = event.target.checked), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,7 +1023,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => (
|
s => (
|
||||||
(s.saveUserSettingsForm.show_new_post_notifs = event.target.checked), s
|
(s.saveUserSettingsForm.show_new_post_notifs = event.target.checked), s
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,7 +1033,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
mui.local_user_view.local_user.show_scores = event.target.checked;
|
mui.local_user_view.local_user.show_scores = event.target.checked;
|
||||||
}
|
}
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.show_scores = event.target.checked), s)
|
s => ((s.saveUserSettingsForm.show_scores = event.target.checked), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,7 +1058,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
(s.saveUserSettingsForm.send_notifications_to_email =
|
(s.saveUserSettingsForm.send_notifications_to_email =
|
||||||
event.target.checked),
|
event.target.checked),
|
||||||
s
|
s
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1070,17 +1070,19 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
handleInterfaceLangChange(i: Settings, event: any) {
|
handleInterfaceLangChange(i: Settings, event: any) {
|
||||||
const newLang = event.target.value ?? "browser";
|
const newLang = event.target.value ?? "browser";
|
||||||
I18NextService.i18n.changeLanguage(
|
I18NextService.i18n.changeLanguage(
|
||||||
newLang === "browser" ? navigator.languages : newLang
|
newLang === "browser" ? navigator.languages : newLang,
|
||||||
);
|
);
|
||||||
|
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.interface_language = event.target.value), s)
|
s => (
|
||||||
|
(s.saveUserSettingsForm.interface_language = event.target.value), s
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDiscussionLanguageChange(val: number[]) {
|
handleDiscussionLanguageChange(val: number[]) {
|
||||||
this.setState(
|
this.setState(
|
||||||
s => ((s.saveUserSettingsForm.discussion_languages = val), s)
|
s => ((s.saveUserSettingsForm.discussion_languages = val), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,7 +1092,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
|
|
||||||
handleListingTypeChange(val: ListingType) {
|
handleListingTypeChange(val: ListingType) {
|
||||||
this.setState(
|
this.setState(
|
||||||
s => ((s.saveUserSettingsForm.default_listing_type = val), s)
|
s => ((s.saveUserSettingsForm.default_listing_type = val), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,13 +1122,13 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
|
|
||||||
handleDisplayNameChange(i: Settings, event: any) {
|
handleDisplayNameChange(i: Settings, event: any) {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.display_name = event.target.value), s)
|
s => ((s.saveUserSettingsForm.display_name = event.target.value), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMatrixUserIdChange(i: Settings, event: any) {
|
handleMatrixUserIdChange(i: Settings, event: any) {
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.saveUserSettingsForm.matrix_user_id = event.target.value), s)
|
s => ((s.saveUserSettingsForm.matrix_user_id = event.target.value), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1140,7 +1142,7 @@ export class Settings extends Component<any, SettingsState> {
|
||||||
const newPassVerify: string | undefined =
|
const newPassVerify: string | undefined =
|
||||||
event.target.value === "" ? undefined : event.target.value;
|
event.target.value === "" ? undefined : event.target.value;
|
||||||
i.setState(
|
i.setState(
|
||||||
s => ((s.changePasswordForm.new_password_verify = newPassVerify), s)
|
s => ((s.changePasswordForm.new_password_verify = newPassVerify), s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ export class CreatePost extends Component<
|
||||||
const { communityId } = getCreatePostQueryParams();
|
const { communityId } = getCreatePostQueryParams();
|
||||||
|
|
||||||
const initialCommunitiesRes = await fetchCommunitiesForOptions(
|
const initialCommunitiesRes = await fetchCommunitiesForOptions(
|
||||||
HttpService.client
|
HttpService.client,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
|
@ -122,7 +122,7 @@ function copySuggestedTitle(d: { i: PostForm; suggestedTitle?: string }) {
|
||||||
const sTitle = d.suggestedTitle;
|
const sTitle = d.suggestedTitle;
|
||||||
if (sTitle) {
|
if (sTitle) {
|
||||||
d.i.setState(
|
d.i.setState(
|
||||||
s => ((s.form.name = sTitle?.substring(0, MAX_POST_TITLE_LENGTH)), s)
|
s => ((s.form.name = sTitle?.substring(0, MAX_POST_TITLE_LENGTH)), s),
|
||||||
);
|
);
|
||||||
d.i.setState({ suggestedPostsRes: { state: "empty" } });
|
d.i.setState({ suggestedPostsRes: { state: "empty" } });
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -271,9 +271,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
({ community: { id, title } }) => ({
|
({ community: { id, title } }) => ({
|
||||||
label: title,
|
label: title,
|
||||||
value: id.toString(),
|
value: id.toString(),
|
||||||
})
|
}),
|
||||||
) ?? []
|
) ?? []
|
||||||
).filter(option => option.value !== selectedCommunityChoice.value)
|
).filter(option => option.value !== selectedCommunityChoice.value),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -284,7 +284,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
({ community: { id, title } }) => ({
|
({ community: { id, title } }) => ({
|
||||||
label: title,
|
label: title,
|
||||||
value: id.toString(),
|
value: id.toString(),
|
||||||
})
|
}),
|
||||||
) ?? [],
|
) ?? [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -310,16 +310,16 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & PostFormProps>
|
nextProps: Readonly<{ children?: InfernoNode } & PostFormProps>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props !== nextProps) {
|
if (this.props !== nextProps) {
|
||||||
this.setState(
|
this.setState(
|
||||||
s => (
|
s => (
|
||||||
(s.form.community_id = getIdFromString(
|
(s.form.community_id = getIdFromString(
|
||||||
nextProps.selectedCommunityChoice?.value
|
nextProps.selectedCommunityChoice?.value,
|
||||||
)),
|
)),
|
||||||
s
|
s
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href={`${ghostArchiveUrl}/search?term=${encodeURIComponent(
|
href={`${ghostArchiveUrl}/search?term=${encodeURIComponent(
|
||||||
url
|
url,
|
||||||
)}`}
|
)}`}
|
||||||
className="me-2 d-inline-block float-right text-muted small fw-bold"
|
className="me-2 d-inline-block float-right text-muted small fw-bold"
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
|
@ -376,7 +376,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href={`${archiveTodayUrl}/?run=1&url=${encodeURIComponent(
|
href={`${archiveTodayUrl}/?run=1&url=${encodeURIComponent(
|
||||||
url
|
url,
|
||||||
)}`}
|
)}`}
|
||||||
className="me-2 d-inline-block float-right text-muted small fw-bold"
|
className="me-2 d-inline-block float-right text-muted small fw-bold"
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
|
@ -590,7 +590,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
className="mt-1 small border-0 bg-transparent p-0 d-block text-muted fw-bold pointer"
|
className="mt-1 small border-0 bg-transparent p-0 d-block text-muted fw-bold pointer"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ i: this, suggestedTitle },
|
{ i: this, suggestedTitle },
|
||||||
copySuggestedTitle
|
copySuggestedTitle,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("copy_suggested_title", { title: "" })}{" "}
|
{I18NextService.i18n.t("copy_suggested_title", { title: "" })}{" "}
|
||||||
|
|
|
@ -419,7 +419,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
<span className="mx-1 badge text-bg-light">
|
<span className="mx-1 badge text-bg-light">
|
||||||
{
|
{
|
||||||
this.props.allLanguages.find(
|
this.props.allLanguages.find(
|
||||||
lang => lang.id === post_view.post.language_id
|
lang => lang.id === post_view.post.language_id,
|
||||||
)?.name
|
)?.name
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
|
@ -515,7 +515,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
<small
|
<small
|
||||||
className="unselectable pointer ms-2 text-muted fst-italic"
|
className="unselectable pointer ms-2 text-muted fst-italic"
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"featured_in_community"
|
"featured_in_community",
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("featured_in_community")}
|
aria-label={I18NextService.i18n.t("featured_in_community")}
|
||||||
>
|
>
|
||||||
|
@ -1115,7 +1115,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
!removed ? this.handleModRemoveShow : this.handleModRemoveSubmit
|
!removed ? this.handleModRemoveShow : this.handleModRemoveSubmit,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/* TODO: Find an icon for this. */}
|
{/* TODO: Find an icon for this. */}
|
||||||
|
@ -1188,7 +1188,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
className="btn btn-link btn-animate text-muted py-0 d-inline-block"
|
className="btn btn-link btn-animate text-muted py-0 d-inline-block"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
this,
|
this,
|
||||||
this.handleCancelShowConfirmTransferCommunity
|
this.handleCancelShowConfirmTransferCommunity,
|
||||||
)}
|
)}
|
||||||
aria-label={I18NextService.i18n.t("no")}
|
aria-label={I18NextService.i18n.t("no")}
|
||||||
>
|
>
|
||||||
|
@ -1772,7 +1772,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
this.props.moderators,
|
this.props.moderators,
|
||||||
this.props.admins,
|
this.props.admins,
|
||||||
undefined,
|
undefined,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1780,7 +1780,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
return canMod(
|
return canMod(
|
||||||
this.postView.creator.id,
|
this.postView.creator.id,
|
||||||
this.props.moderators,
|
this.props.moderators,
|
||||||
this.props.admins
|
this.props.admins,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ export class PostReport extends Component<PostReportProps, PostReportState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & PostReportProps>
|
nextProps: Readonly<{ children?: InfernoNode } & PostReportProps>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props !== nextProps) {
|
if (this.props !== nextProps) {
|
||||||
this.setState({ loading: false });
|
this.setState({ loading: false });
|
||||||
|
@ -38,7 +38,7 @@ export class PostReport extends Component<PostReportProps, PostReportState> {
|
||||||
const resolver = r.resolver;
|
const resolver = r.resolver;
|
||||||
const post = r.post;
|
const post = r.post;
|
||||||
const tippyContent = I18NextService.i18n.t(
|
const tippyContent = I18NextService.i18n.t(
|
||||||
r.post_report.resolved ? "unresolve_report" : "resolve_report"
|
r.post_report.resolved ? "unresolve_report" : "resolve_report",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set the original post data ( a troll could change it )
|
// Set the original post data ( a troll could change it )
|
||||||
|
|
|
@ -290,7 +290,7 @@ export class Post extends Component<any, PostState> {
|
||||||
|
|
||||||
get checkScrollIntoCommentsParam() {
|
get checkScrollIntoCommentsParam() {
|
||||||
return Boolean(
|
return Boolean(
|
||||||
new URLSearchParams(this.props.location.search).get("scrollToComments")
|
new URLSearchParams(this.props.location.search).get("scrollToComments"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ export class Post extends Component<any, PostState> {
|
||||||
if (this.state.commentsRes.state === "success") {
|
if (this.state.commentsRes.state === "success") {
|
||||||
return buildCommentsTree(
|
return buildCommentsTree(
|
||||||
this.state.commentsRes.data.comments,
|
this.state.commentsRes.data.comments,
|
||||||
!!this.state.commentId
|
!!this.state.commentId,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
|
@ -705,7 +705,7 @@ export class Post extends Component<any, PostState> {
|
||||||
handleViewContext(i: Post) {
|
handleViewContext(i: Post) {
|
||||||
if (i.state.commentsRes.state === "success") {
|
if (i.state.commentsRes.state === "success") {
|
||||||
const parentId = getCommentParentId(
|
const parentId = getCommentParentId(
|
||||||
i.state.commentsRes.data.comments.at(0)?.comment
|
i.state.commentsRes.data.comments.at(0)?.comment,
|
||||||
);
|
);
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
i.context.router.history.push(`/comment/${parentId}`);
|
i.context.router.history.push(`/comment/${parentId}`);
|
||||||
|
@ -887,7 +887,7 @@ export class Post extends Component<any, PostState> {
|
||||||
|
|
||||||
async handleTransferCommunity(form: TransferCommunity) {
|
async handleTransferCommunity(form: TransferCommunity) {
|
||||||
const transferCommunityRes = await HttpService.client.transferCommunity(
|
const transferCommunityRes = await HttpService.client.transferCommunity(
|
||||||
form
|
form,
|
||||||
);
|
);
|
||||||
this.updateCommunityFull(transferCommunityRes);
|
this.updateCommunityFull(transferCommunityRes);
|
||||||
}
|
}
|
||||||
|
@ -943,7 +943,7 @@ export class Post extends Component<any, PostState> {
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments
|
||||||
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
.filter(c => c.creator.id === banRes.data.person_view.person.id)
|
||||||
.forEach(
|
.forEach(
|
||||||
c => (c.creator_banned_from_community = banRes.data.banned)
|
c => (c.creator_banned_from_community = banRes.data.banned),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1015,7 +1015,7 @@ export class Post extends Component<any, PostState> {
|
||||||
// Set finished for the parent
|
// Set finished for the parent
|
||||||
s.finished.set(
|
s.finished.set(
|
||||||
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
getCommentParentId(res.data.comment_view.comment) ?? 0,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
@ -1027,7 +1027,7 @@ export class Post extends Component<any, PostState> {
|
||||||
if (s.commentsRes.state === "success" && res.state === "success") {
|
if (s.commentsRes.state === "success" && res.state === "success") {
|
||||||
s.commentsRes.data.comments = editComment(
|
s.commentsRes.data.comments = editComment(
|
||||||
res.data.comment_view,
|
res.data.comment_view,
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments,
|
||||||
);
|
);
|
||||||
s.finished.set(res.data.comment_view.comment.id, true);
|
s.finished.set(res.data.comment_view.comment.id, true);
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1040,7 @@ export class Post extends Component<any, PostState> {
|
||||||
if (s.commentsRes.state === "success" && res.state === "success") {
|
if (s.commentsRes.state === "success" && res.state === "success") {
|
||||||
s.commentsRes.data.comments = editWith(
|
s.commentsRes.data.comments = editWith(
|
||||||
res.data.comment_reply_view,
|
res.data.comment_reply_view,
|
||||||
s.commentsRes.data.comments
|
s.commentsRes.data.comments,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -56,7 +56,7 @@ export class PrivateMessageForm extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageFormProps>
|
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageFormProps>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props !== nextProps) {
|
if (this.props !== nextProps) {
|
||||||
this.setState({ loading: false, content: undefined, previewMode: false });
|
this.setState({ loading: false, content: undefined, previewMode: false });
|
||||||
|
|
|
@ -29,7 +29,7 @@ export class PrivateMessageReport extends Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & Props>
|
nextProps: Readonly<{ children?: InfernoNode } & Props>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props !== nextProps) {
|
if (this.props !== nextProps) {
|
||||||
this.setState({ loading: false });
|
this.setState({ loading: false });
|
||||||
|
@ -40,7 +40,7 @@ export class PrivateMessageReport extends Component<Props, State> {
|
||||||
const r = this.props.report;
|
const r = this.props.report;
|
||||||
const pmr = r.private_message_report;
|
const pmr = r.private_message_report;
|
||||||
const tippyContent = I18NextService.i18n.t(
|
const tippyContent = I18NextService.i18n.t(
|
||||||
r.private_message_report.resolved ? "unresolve_report" : "resolve_report"
|
r.private_message_report.resolved ? "unresolve_report" : "resolve_report",
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -65,7 +65,7 @@ export class PrivateMessage extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps>
|
nextProps: Readonly<{ children?: InfernoNode } & PrivateMessageProps>,
|
||||||
): void {
|
): void {
|
||||||
if (this.props !== nextProps) {
|
if (this.props !== nextProps) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
|
@ -209,20 +209,20 @@ const communityListing = ({
|
||||||
getListing(
|
getListing(
|
||||||
<CommunityLink community={community} />,
|
<CommunityLink community={community} />,
|
||||||
subscribers,
|
subscribers,
|
||||||
"number_of_subscribers"
|
"number_of_subscribers",
|
||||||
);
|
);
|
||||||
|
|
||||||
const personListing = ({ person, counts: { comment_count } }: PersonView) =>
|
const personListing = ({ person, counts: { comment_count } }: PersonView) =>
|
||||||
getListing(
|
getListing(
|
||||||
<PersonListing person={person} showApubName />,
|
<PersonListing person={person} showApubName />,
|
||||||
comment_count,
|
comment_count,
|
||||||
"number_of_comments"
|
"number_of_comments",
|
||||||
);
|
);
|
||||||
|
|
||||||
function getListing(
|
function getListing(
|
||||||
listing: JSX.ElementClass,
|
listing: JSX.ElementClass,
|
||||||
count: number,
|
count: number,
|
||||||
translationKey: "number_of_comments" | "number_of_subscribers"
|
translationKey: "number_of_comments" | "number_of_subscribers",
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -386,7 +386,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
listCommunitiesResponse = await client.listCommunities(
|
listCommunitiesResponse = await client.listCommunities(
|
||||||
listCommunitiesForm
|
listCommunitiesForm,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
auth,
|
auth,
|
||||||
};
|
};
|
||||||
resolveObjectResponse = await HttpService.silent_client.resolveObject(
|
resolveObjectResponse = await HttpService.silent_client.resolveObject(
|
||||||
resolveObjectForm
|
resolveObjectForm,
|
||||||
);
|
);
|
||||||
|
|
||||||
// If we return this object with a state of failed, the catch-all-handler will redirect
|
// If we return this object with a state of failed, the catch-all-handler will redirect
|
||||||
|
@ -564,7 +564,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
{searchTypes.map(option => (
|
{searchTypes.map(option => (
|
||||||
<option value={option} key={option}>
|
<option value={option} key={option}>
|
||||||
{I18NextService.i18n.t(
|
{I18NextService.i18n.t(
|
||||||
option.toString().toLowerCase() as NoOptionI18nKeys
|
option.toString().toLowerCase() as NoOptionI18nKeys,
|
||||||
)}
|
)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
|
@ -646,7 +646,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
...(posts?.map(postViewToCombined) ?? []),
|
...(posts?.map(postViewToCombined) ?? []),
|
||||||
...(communities?.map(communityViewToCombined) ?? []),
|
...(communities?.map(communityViewToCombined) ?? []),
|
||||||
...(users?.map(personViewSafeToCombined) ?? []),
|
...(users?.map(personViewSafeToCombined) ?? []),
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,8 +663,8 @@ export class Search extends Component<any, SearchState> {
|
||||||
(b.data as PersonView).counts.comment_score) -
|
(b.data as PersonView).counts.comment_score) -
|
||||||
((a.data as CommentView | PostView).counts.score |
|
((a.data as CommentView | PostView).counts.score |
|
||||||
(a.data as CommunityView).counts.subscribers |
|
(a.data as CommunityView).counts.subscribers |
|
||||||
(a.data as PersonView).counts.comment_score)
|
(a.data as PersonView).counts.comment_score),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,7 +984,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
this.setState({ searchCreatorLoading: true });
|
this.setState({ searchCreatorLoading: true });
|
||||||
|
|
||||||
const selectedChoice = creatorSearchOptions.find(
|
const selectedChoice = creatorSearchOptions.find(
|
||||||
choice => getIdFromString(choice.value) === creatorId
|
choice => getIdFromString(choice.value) === creatorId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (selectedChoice) {
|
if (selectedChoice) {
|
||||||
|
@ -1011,7 +1011,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
const newOptions: Choice[] = [];
|
const newOptions: Choice[] = [];
|
||||||
|
|
||||||
const selectedChoice = communitySearchOptions.find(
|
const selectedChoice = communitySearchOptions.find(
|
||||||
choice => getIdFromString(choice.value) === communityId
|
choice => getIdFromString(choice.value) === communityId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (selectedChoice) {
|
if (selectedChoice) {
|
||||||
|
|
|
@ -191,7 +191,7 @@ export function setupMarkdown() {
|
||||||
idx: number,
|
idx: number,
|
||||||
options: MarkdownIt.Options,
|
options: MarkdownIt.Options,
|
||||||
env: any,
|
env: any,
|
||||||
self: Renderer
|
self: Renderer,
|
||||||
) {
|
) {
|
||||||
//Provide custom renderer for our emojis to allow us to add a css class and force size dimensions on them.
|
//Provide custom renderer for our emojis to allow us to add a css class and force size dimensions on them.
|
||||||
const item = tokens[idx] as any;
|
const item = tokens[idx] as any;
|
||||||
|
@ -215,7 +215,7 @@ export function setupMarkdown() {
|
||||||
export function setupEmojiDataModel(custom_emoji_views: CustomEmojiView[]) {
|
export function setupEmojiDataModel(custom_emoji_views: CustomEmojiView[]) {
|
||||||
const groupedEmojis = groupBy(
|
const groupedEmojis = groupBy(
|
||||||
custom_emoji_views,
|
custom_emoji_views,
|
||||||
x => x.custom_emoji.category
|
x => x.custom_emoji.category,
|
||||||
);
|
);
|
||||||
for (const [category, emojis] of Object.entries(groupedEmojis)) {
|
for (const [category, emojis] of Object.entries(groupedEmojis)) {
|
||||||
customEmojis.push({
|
customEmojis.push({
|
||||||
|
@ -230,7 +230,7 @@ export function setupEmojiDataModel(custom_emoji_views: CustomEmojiView[]) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
customEmojisLookup = new Map(
|
customEmojisLookup = new Map(
|
||||||
custom_emoji_views.map(view => [view.custom_emoji.shortcode, view])
|
custom_emoji_views.map(view => [view.custom_emoji.shortcode, view]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
|
||||||
skins: [{ src: custom_emoji_view.custom_emoji.image_url }],
|
skins: [{ src: custom_emoji_view.custom_emoji.image_url }],
|
||||||
};
|
};
|
||||||
const categoryIndex = customEmojis.findIndex(
|
const categoryIndex = customEmojis.findIndex(
|
||||||
x => x.id === custom_emoji_view.custom_emoji.category
|
x => x.id === custom_emoji_view.custom_emoji.category,
|
||||||
);
|
);
|
||||||
if (categoryIndex === -1) {
|
if (categoryIndex === -1) {
|
||||||
customEmojis.push({
|
customEmojis.push({
|
||||||
|
@ -252,7 +252,7 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
|
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
|
||||||
x => x.id === custom_emoji_view.custom_emoji.shortcode
|
x => x.id === custom_emoji_view.custom_emoji.shortcode,
|
||||||
);
|
);
|
||||||
if (emojiIndex === -1) {
|
if (emojiIndex === -1) {
|
||||||
customEmojis[categoryIndex].emojis.push(emoji);
|
customEmojis[categoryIndex].emojis.push(emoji);
|
||||||
|
@ -262,7 +262,7 @@ export function updateEmojiDataModel(custom_emoji_view: CustomEmojiView) {
|
||||||
}
|
}
|
||||||
customEmojisLookup.set(
|
customEmojisLookup.set(
|
||||||
custom_emoji_view.custom_emoji.shortcode,
|
custom_emoji_view.custom_emoji.shortcode,
|
||||||
custom_emoji_view
|
custom_emoji_view,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,10 +276,10 @@ export function removeFromEmojiDataModel(id: number) {
|
||||||
}
|
}
|
||||||
if (!view) return;
|
if (!view) return;
|
||||||
const categoryIndex = customEmojis.findIndex(
|
const categoryIndex = customEmojis.findIndex(
|
||||||
x => x.id === view?.custom_emoji.category
|
x => x.id === view?.custom_emoji.category,
|
||||||
);
|
);
|
||||||
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
|
const emojiIndex = customEmojis[categoryIndex].emojis.findIndex(
|
||||||
x => x.id === view?.custom_emoji.shortcode
|
x => x.id === view?.custom_emoji.shortcode,
|
||||||
);
|
);
|
||||||
customEmojis[categoryIndex].emojis = customEmojis[
|
customEmojis[categoryIndex].emojis = customEmojis[
|
||||||
categoryIndex
|
categoryIndex
|
||||||
|
@ -290,7 +290,7 @@ export function removeFromEmojiDataModel(id: number) {
|
||||||
|
|
||||||
export function getEmojiMart(
|
export function getEmojiMart(
|
||||||
onEmojiSelect: (e: any) => void,
|
onEmojiSelect: (e: any) => void,
|
||||||
customPickerOptions: any = {}
|
customPickerOptions: any = {},
|
||||||
) {
|
) {
|
||||||
const pickerOptions = {
|
const pickerOptions = {
|
||||||
...customPickerOptions,
|
...customPickerOptions,
|
||||||
|
@ -314,9 +314,8 @@ export function setupTribute() {
|
||||||
return `${item.original.val} ${shortName}`;
|
return `${item.original.val} ${shortName}`;
|
||||||
},
|
},
|
||||||
selectTemplate: (item: any) => {
|
selectTemplate: (item: any) => {
|
||||||
const customEmoji = customEmojisLookup.get(
|
const customEmoji = customEmojisLookup.get(item.original.key)
|
||||||
item.original.key
|
?.custom_emoji;
|
||||||
)?.custom_emoji;
|
|
||||||
if (customEmoji === undefined) return `${item.original.val}`;
|
if (customEmoji === undefined) return `${item.original.val}`;
|
||||||
else
|
else
|
||||||
return `![${customEmoji.alt_text}](${customEmoji.image_url} "${customEmoji.shortcode}")`;
|
return `![${customEmoji.alt_text}](${customEmoji.image_url} "${customEmoji.shortcode}")`;
|
||||||
|
@ -329,7 +328,7 @@ export function setupTribute() {
|
||||||
Array.from(customEmojisLookup.entries()).map(k => ({
|
Array.from(customEmojisLookup.entries()).map(k => ({
|
||||||
key: k[0],
|
key: k[0],
|
||||||
val: `<img class="icon icon-emoji" src="${k[1].custom_emoji.image_url}" title="${k[1].custom_emoji.shortcode}" alt="${k[1].custom_emoji.alt_text}" />`,
|
val: `<img class="icon icon-emoji" src="${k[1].custom_emoji.image_url}" title="${k[1].custom_emoji.shortcode}" alt="${k[1].custom_emoji.alt_text}" />`,
|
||||||
}))
|
})),
|
||||||
),
|
),
|
||||||
allowSpaces: false,
|
allowSpaces: false,
|
||||||
autocompleteMode: true,
|
autocompleteMode: true,
|
||||||
|
|
|
@ -49,7 +49,7 @@ class WrappedLemmyHttpClient {
|
||||||
this.#client = client;
|
this.#client = client;
|
||||||
|
|
||||||
for (const key of Object.getOwnPropertyNames(
|
for (const key of Object.getOwnPropertyNames(
|
||||||
Object.getPrototypeOf(this.#client)
|
Object.getPrototypeOf(this.#client),
|
||||||
)) {
|
)) {
|
||||||
if (key !== "constructor") {
|
if (key !== "constructor") {
|
||||||
WrappedLemmyHttpClient.prototype[key] = async (...args) => {
|
WrappedLemmyHttpClient.prototype[key] = async (...args) => {
|
||||||
|
@ -80,7 +80,7 @@ export function wrapClient(client: LemmyHttp, silent = false) {
|
||||||
// unfortunately, this verbose cast is necessary
|
// unfortunately, this verbose cast is necessary
|
||||||
return new WrappedLemmyHttpClient(
|
return new WrappedLemmyHttpClient(
|
||||||
client,
|
client,
|
||||||
silent
|
silent,
|
||||||
) as unknown as WrappedLemmyHttp;
|
) as unknown as WrappedLemmyHttp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ export function pictrsDeleteToast(filename: string, deleteUrl: string) {
|
||||||
"failed_to_delete_picture",
|
"failed_to_delete_picture",
|
||||||
{
|
{
|
||||||
filename,
|
filename,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const backgroundColor = `var(--bs-light)`;
|
const backgroundColor = `var(--bs-light)`;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { CommentNodeI } from "../../interfaces";
|
||||||
|
|
||||||
export default function buildCommentsTree(
|
export default function buildCommentsTree(
|
||||||
comments: CommentView[],
|
comments: CommentView[],
|
||||||
parentComment: boolean
|
parentComment: boolean,
|
||||||
): CommentNodeI[] {
|
): CommentNodeI[] {
|
||||||
const map = new Map<number, CommentNodeI>();
|
const map = new Map<number, CommentNodeI>();
|
||||||
const depthOffset = !parentComment
|
const depthOffset = !parentComment
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { CommentView } from "lemmy-js-client";
|
||||||
import { CommentNodeI } from "../../interfaces";
|
import { CommentNodeI } from "../../interfaces";
|
||||||
|
|
||||||
export default function commentsToFlatNodes(
|
export default function commentsToFlatNodes(
|
||||||
comments: CommentView[]
|
comments: CommentView[],
|
||||||
): CommentNodeI[] {
|
): CommentNodeI[] {
|
||||||
const nodes: CommentNodeI[] = [];
|
const nodes: CommentNodeI[] = [];
|
||||||
for (const comment of comments) {
|
for (const comment of comments) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { hostname } from "@utils/helpers";
|
||||||
import { CommunityTribute } from "@utils/types";
|
import { CommunityTribute } from "@utils/types";
|
||||||
|
|
||||||
export default async function communitySearch(
|
export default async function communitySearch(
|
||||||
text: string
|
text: string,
|
||||||
): Promise<CommunityTribute[]> {
|
): Promise<CommunityTribute[]> {
|
||||||
const communitiesResponse = await fetchCommunities(text);
|
const communitiesResponse = await fetchCommunities(text);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { CommentSortType, SortType } from "lemmy-js-client";
|
import { CommentSortType, SortType } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function convertCommentSortType(
|
export default function convertCommentSortType(
|
||||||
sort: SortType
|
sort: SortType,
|
||||||
): CommentSortType {
|
): CommentSortType {
|
||||||
switch (sort) {
|
switch (sort) {
|
||||||
case "TopAll":
|
case "TopAll":
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { CommentReplyView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editCommentReply(
|
export default function editCommentReply(
|
||||||
data: CommentReplyView,
|
data: CommentReplyView,
|
||||||
replies: CommentReplyView[]
|
replies: CommentReplyView[],
|
||||||
): CommentReplyView[] {
|
): CommentReplyView[] {
|
||||||
return editListImmutable("comment_reply", data, replies);
|
return editListImmutable("comment_reply", data, replies);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { CommentReportView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editCommentReport(
|
export default function editCommentReport(
|
||||||
data: CommentReportView,
|
data: CommentReportView,
|
||||||
reports: CommentReportView[]
|
reports: CommentReportView[],
|
||||||
): CommentReportView[] {
|
): CommentReportView[] {
|
||||||
return editListImmutable("comment_report", data, reports);
|
return editListImmutable("comment_report", data, reports);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { CommentView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editComment(
|
export default function editComment(
|
||||||
data: CommentView,
|
data: CommentView,
|
||||||
comments: CommentView[]
|
comments: CommentView[],
|
||||||
): CommentView[] {
|
): CommentView[] {
|
||||||
return editListImmutable("comment", data, comments);
|
return editListImmutable("comment", data, comments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { CommunityView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editCommunity(
|
export default function editCommunity(
|
||||||
data: CommunityView,
|
data: CommunityView,
|
||||||
communities: CommunityView[]
|
communities: CommunityView[],
|
||||||
): CommunityView[] {
|
): CommunityView[] {
|
||||||
return editListImmutable("community", data, communities);
|
return editListImmutable("community", data, communities);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PersonMentionView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editMention(
|
export default function editMention(
|
||||||
data: PersonMentionView,
|
data: PersonMentionView,
|
||||||
comments: PersonMentionView[]
|
comments: PersonMentionView[],
|
||||||
): PersonMentionView[] {
|
): PersonMentionView[] {
|
||||||
return editListImmutable("person_mention", data, comments);
|
return editListImmutable("person_mention", data, comments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PostReportView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editPostReport(
|
export default function editPostReport(
|
||||||
data: PostReportView,
|
data: PostReportView,
|
||||||
reports: PostReportView[]
|
reports: PostReportView[],
|
||||||
) {
|
) {
|
||||||
return editListImmutable("post_report", data, reports);
|
return editListImmutable("post_report", data, reports);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PostView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editPost(
|
export default function editPost(
|
||||||
data: PostView,
|
data: PostView,
|
||||||
posts: PostView[]
|
posts: PostView[],
|
||||||
): PostView[] {
|
): PostView[] {
|
||||||
return editListImmutable("post", data, posts);
|
return editListImmutable("post", data, posts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PrivateMessageReportView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editPrivateMessageReport(
|
export default function editPrivateMessageReport(
|
||||||
data: PrivateMessageReportView,
|
data: PrivateMessageReportView,
|
||||||
reports: PrivateMessageReportView[]
|
reports: PrivateMessageReportView[],
|
||||||
): PrivateMessageReportView[] {
|
): PrivateMessageReportView[] {
|
||||||
return editListImmutable("private_message_report", data, reports);
|
return editListImmutable("private_message_report", data, reports);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PrivateMessageView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editPrivateMessage(
|
export default function editPrivateMessage(
|
||||||
data: PrivateMessageView,
|
data: PrivateMessageView,
|
||||||
messages: PrivateMessageView[]
|
messages: PrivateMessageView[],
|
||||||
): PrivateMessageView[] {
|
): PrivateMessageView[] {
|
||||||
return editListImmutable("private_message", data, messages);
|
return editListImmutable("private_message", data, messages);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { RegistrationApplicationView } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function editRegistrationApplication(
|
export default function editRegistrationApplication(
|
||||||
data: RegistrationApplicationView,
|
data: RegistrationApplicationView,
|
||||||
apps: RegistrationApplicationView[]
|
apps: RegistrationApplicationView[],
|
||||||
): RegistrationApplicationView[] {
|
): RegistrationApplicationView[] {
|
||||||
return editListImmutable("registration_application", data, apps);
|
return editListImmutable("registration_application", data, apps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ import { WithComment } from "@utils/types";
|
||||||
|
|
||||||
export default function editWith<D extends WithComment, L extends WithComment>(
|
export default function editWith<D extends WithComment, L extends WithComment>(
|
||||||
{ comment, counts, saved, my_vote }: D,
|
{ comment, counts, saved, my_vote }: D,
|
||||||
list: L[]
|
list: L[],
|
||||||
) {
|
) {
|
||||||
return [
|
return [
|
||||||
...list.map(c =>
|
...list.map(c =>
|
||||||
c.comment.id === comment.id
|
c.comment.id === comment.id
|
||||||
? { ...c, comment, counts, saved, my_vote }
|
? { ...c, comment, counts, saved, my_vote }
|
||||||
: c
|
: c,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Comment } from "lemmy-js-client";
|
import { Comment } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function getCommentParentId(
|
export default function getCommentParentId(
|
||||||
comment?: Comment
|
comment?: Comment,
|
||||||
): number | undefined {
|
): number | undefined {
|
||||||
const split = comment?.path.split(".");
|
const split = comment?.path.split(".");
|
||||||
// remove the 0
|
// remove the 0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Comment } from "lemmy-js-client";
|
import { Comment } from "lemmy-js-client";
|
||||||
|
|
||||||
export default function getDepthFromComment(
|
export default function getDepthFromComment(
|
||||||
comment?: Comment
|
comment?: Comment,
|
||||||
): number | undefined {
|
): number | undefined {
|
||||||
const len = comment?.path.split(".").length;
|
const len = comment?.path.split(".").length;
|
||||||
return len ? len - 2 : undefined;
|
return len ? len - 2 : undefined;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export default function getUpdatedSearchId(
|
export default function getUpdatedSearchId(
|
||||||
id?: number | null,
|
id?: number | null,
|
||||||
urlId?: number | null
|
urlId?: number | null,
|
||||||
) {
|
) {
|
||||||
return id === null
|
return id === null
|
||||||
? undefined
|
? undefined
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { CommentNodeI } from "../../interfaces";
|
||||||
export default function insertCommentIntoTree(
|
export default function insertCommentIntoTree(
|
||||||
tree: CommentNodeI[],
|
tree: CommentNodeI[],
|
||||||
cv: CommentView,
|
cv: CommentView,
|
||||||
parentComment: boolean
|
parentComment: boolean,
|
||||||
) {
|
) {
|
||||||
// Building a fake node to be used for later
|
// Building a fake node to be used for later
|
||||||
const node: CommentNodeI = {
|
const node: CommentNodeI = {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export default function isAuthPath(pathname: string) {
|
export default function isAuthPath(pathname: string) {
|
||||||
return /^\/(create_.*?|inbox|settings|admin|reports|registration_applications)\b/g.test(
|
return /^\/(create_.*?|inbox|settings|admin|reports|registration_applications)\b/g.test(
|
||||||
pathname
|
pathname,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { UserService } from "../../services";
|
||||||
|
|
||||||
export default function isPostBlocked(
|
export default function isPostBlocked(
|
||||||
pv: PostView,
|
pv: PostView,
|
||||||
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo
|
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo,
|
||||||
): boolean {
|
): boolean {
|
||||||
return (
|
return (
|
||||||
(myUserInfo?.community_blocks
|
(myUserInfo?.community_blocks
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { UserService } from "../../services";
|
||||||
|
|
||||||
export default function nsfwCheck(
|
export default function nsfwCheck(
|
||||||
pv: PostView,
|
pv: PostView,
|
||||||
myUserInfo = UserService.Instance.myUserInfo
|
myUserInfo = UserService.Instance.myUserInfo,
|
||||||
): boolean {
|
): boolean {
|
||||||
const nsfw = pv.post.nsfw || pv.community.nsfw;
|
const nsfw = pv.post.nsfw || pv.community.nsfw;
|
||||||
const myShowNsfw = myUserInfo?.local_user_view.local_user.show_nsfw ?? false;
|
const myShowNsfw = myUserInfo?.local_user_view.local_user.show_nsfw ?? false;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { hostname } from "@utils/helpers";
|
||||||
import { PersonTribute } from "@utils/types";
|
import { PersonTribute } from "@utils/types";
|
||||||
|
|
||||||
export default async function personSearch(
|
export default async function personSearch(
|
||||||
text: string
|
text: string,
|
||||||
): Promise<PersonTribute[]> {
|
): Promise<PersonTribute[]> {
|
||||||
const usersResponse = await fetchUsers(text);
|
const usersResponse = await fetchUsers(text);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { CommentNodeI } from "../../interfaces";
|
||||||
|
|
||||||
export default function searchCommentTree(
|
export default function searchCommentTree(
|
||||||
tree: CommentNodeI[],
|
tree: CommentNodeI[],
|
||||||
id: number
|
id: number,
|
||||||
): CommentNodeI | undefined {
|
): CommentNodeI | undefined {
|
||||||
for (const node of tree) {
|
for (const node of tree) {
|
||||||
if (node.comment_view.comment.id === id) {
|
if (node.comment_view.comment.id === id) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default function selectableLanguages(
|
||||||
siteLanguages: number[],
|
siteLanguages: number[],
|
||||||
showAll?: boolean,
|
showAll?: boolean,
|
||||||
showSite?: boolean,
|
showSite?: boolean,
|
||||||
myUserInfo = UserService.Instance.myUserInfo
|
myUserInfo = UserService.Instance.myUserInfo,
|
||||||
): Language[] {
|
): Language[] {
|
||||||
const allLangIds = allLanguages.map(l => l.id);
|
const allLangIds = allLanguages.map(l => l.id);
|
||||||
let myLangs = myUserInfo?.discussion_languages ?? allLangIds;
|
let myLangs = myUserInfo?.discussion_languages ?? allLangIds;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { isBrowser } from "@utils/browser";
|
||||||
import { IsoData, RouteData } from "../../interfaces";
|
import { IsoData, RouteData } from "../../interfaces";
|
||||||
|
|
||||||
export default function setIsoData<T extends RouteData>(
|
export default function setIsoData<T extends RouteData>(
|
||||||
context: any
|
context: any,
|
||||||
): IsoData<T> {
|
): IsoData<T> {
|
||||||
// If its the browser, you need to deserialize the data from the window
|
// If its the browser, you need to deserialize the data from the window
|
||||||
if (isBrowser()) {
|
if (isBrowser()) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default async function () {
|
||||||
).default;
|
).default;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(
|
console.log(
|
||||||
`Could not load locale ${lang} from date-fns, falling back to ${EN_US}`
|
`Could not load locale ${lang} from date-fns, falling back to ${EN_US}`,
|
||||||
);
|
);
|
||||||
locale = (
|
locale = (
|
||||||
await import(
|
await import(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { UserService } from "../../services";
|
import { UserService } from "../../services";
|
||||||
|
|
||||||
export default function showAvatars(
|
export default function showAvatars(
|
||||||
myUserInfo = UserService.Instance.myUserInfo
|
myUserInfo = UserService.Instance.myUserInfo,
|
||||||
): boolean {
|
): boolean {
|
||||||
return myUserInfo?.local_user_view.local_user.show_avatars ?? true;
|
return myUserInfo?.local_user_view.local_user.show_avatars ?? true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { UserService } from "../../services";
|
import { UserService } from "../../services";
|
||||||
|
|
||||||
export default function showScores(
|
export default function showScores(
|
||||||
myUserInfo = UserService.Instance.myUserInfo
|
myUserInfo = UserService.Instance.myUserInfo,
|
||||||
): boolean {
|
): boolean {
|
||||||
return myUserInfo?.local_user_view.local_user.show_scores ?? true;
|
return myUserInfo?.local_user_view.local_user.show_scores ?? true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { toast } from "../../toast";
|
||||||
|
|
||||||
export default function updateCommunityBlock(
|
export default function updateCommunityBlock(
|
||||||
data: BlockCommunityResponse,
|
data: BlockCommunityResponse,
|
||||||
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo
|
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo,
|
||||||
) {
|
) {
|
||||||
if (myUserInfo) {
|
if (myUserInfo) {
|
||||||
if (data.blocked) {
|
if (data.blocked) {
|
||||||
|
@ -15,16 +15,16 @@ export default function updateCommunityBlock(
|
||||||
toast(
|
toast(
|
||||||
`${I18NextService.i18n.t("blocked")} ${
|
`${I18NextService.i18n.t("blocked")} ${
|
||||||
data.community_view.community.name
|
data.community_view.community.name
|
||||||
}`
|
}`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
myUserInfo.community_blocks = myUserInfo.community_blocks.filter(
|
myUserInfo.community_blocks = myUserInfo.community_blocks.filter(
|
||||||
i => i.community.id !== data.community_view.community.id
|
i => i.community.id !== data.community_view.community.id,
|
||||||
);
|
);
|
||||||
toast(
|
toast(
|
||||||
`${I18NextService.i18n.t("unblocked")} ${
|
`${I18NextService.i18n.t("unblocked")} ${
|
||||||
data.community_view.community.name
|
data.community_view.community.name
|
||||||
}`
|
}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { toast } from "../../toast";
|
||||||
|
|
||||||
export default function updatePersonBlock(
|
export default function updatePersonBlock(
|
||||||
data: BlockPersonResponse,
|
data: BlockPersonResponse,
|
||||||
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo
|
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo,
|
||||||
) {
|
) {
|
||||||
if (myUserInfo) {
|
if (myUserInfo) {
|
||||||
if (data.blocked) {
|
if (data.blocked) {
|
||||||
|
@ -13,14 +13,14 @@ export default function updatePersonBlock(
|
||||||
target: data.person_view.person,
|
target: data.person_view.person,
|
||||||
});
|
});
|
||||||
toast(
|
toast(
|
||||||
`${I18NextService.i18n.t("blocked")} ${data.person_view.person.name}`
|
`${I18NextService.i18n.t("blocked")} ${data.person_view.person.name}`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
myUserInfo.person_blocks = myUserInfo.person_blocks.filter(
|
myUserInfo.person_blocks = myUserInfo.person_blocks.filter(
|
||||||
i => i.target.id !== data.person_view.person.id
|
i => i.target.id !== data.person_view.person.id,
|
||||||
);
|
);
|
||||||
toast(
|
toast(
|
||||||
`${I18NextService.i18n.t("unblocked")} ${data.person_view.person.name}`
|
`${I18NextService.i18n.t("unblocked")} ${data.person_view.person.name}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
src/shared/utils/env/http-external-path.ts
vendored
2
src/shared/utils/env/http-external-path.ts
vendored
|
@ -4,6 +4,6 @@ import { getExternalHost, getSecure } from "@utils/env";
|
||||||
export default function httpExternalPath(path: string) {
|
export default function httpExternalPath(path: string) {
|
||||||
return `http${getSecure()}://${getExternalHost().replace(
|
return `http${getSecure()}://${getExternalHost().replace(
|
||||||
/:\d+/g,
|
/:\d+/g,
|
||||||
""
|
"",
|
||||||
)}${path}`;
|
)}${path}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export default function debounce<T extends any[], R>(
|
export default function debounce<T extends any[], R>(
|
||||||
func: (...e: T) => R,
|
func: (...e: T) => R,
|
||||||
wait = 1000,
|
wait = 1000,
|
||||||
immediate = false
|
immediate = false,
|
||||||
) {
|
) {
|
||||||
let timeout: NodeJS.Timeout | null;
|
let timeout: NodeJS.Timeout | null;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ type ImmutableListKey =
|
||||||
|
|
||||||
export default function editListImmutable<
|
export default function editListImmutable<
|
||||||
T extends { [key in F]: { id: number } },
|
T extends { [key in F]: { id: number } },
|
||||||
F extends ImmutableListKey
|
F extends ImmutableListKey,
|
||||||
>(fieldName: F, data: T, list: T[]): T[] {
|
>(fieldName: F, data: T, list: T[]): T[] {
|
||||||
return [
|
return [
|
||||||
...list.map(c => (c[fieldName].id === data[fieldName].id ? data : c)),
|
...list.map(c => (c[fieldName].id === data[fieldName].id ? data : c)),
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
export default function futureDaysToUnixTime(
|
export default function futureDaysToUnixTime(
|
||||||
days?: number
|
days?: number,
|
||||||
): number | undefined {
|
): number | undefined {
|
||||||
return days
|
return days
|
||||||
? Math.trunc(
|
? Math.trunc(
|
||||||
new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000
|
new Date(Date.now() + 1000 * 60 * 60 * 24 * days).getTime() / 1000,
|
||||||
)
|
)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { isBrowser } from "@utils/browser";
|
import { isBrowser } from "@utils/browser";
|
||||||
|
|
||||||
export default function getQueryParams<
|
export default function getQueryParams<
|
||||||
T extends Record<string, any>
|
T extends Record<string, any>,
|
||||||
>(processors: {
|
>(processors: {
|
||||||
[K in keyof T]: (param: string) => T[K];
|
[K in keyof T]: (param: string) => T[K];
|
||||||
}): T {
|
}): T {
|
||||||
|
@ -13,7 +13,7 @@ export default function getQueryParams<
|
||||||
...acc,
|
...acc,
|
||||||
[key]: process(searchParams.get(key)),
|
[key]: process(searchParams.get(key)),
|
||||||
}),
|
}),
|
||||||
{} as T
|
{} as T,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
export default function getQueryString<
|
export default function getQueryString<
|
||||||
T extends Record<string, string | undefined>
|
T extends Record<string, string | undefined>,
|
||||||
>(obj: T) {
|
>(obj: T) {
|
||||||
return Object.entries(obj)
|
return Object.entries(obj)
|
||||||
.filter(([, val]) => val !== undefined && val !== null)
|
.filter(([, val]) => val !== undefined && val !== null)
|
||||||
.reduce(
|
.reduce(
|
||||||
(acc, [key, val], index) => `${acc}${index > 0 ? "&" : ""}${key}=${val}`,
|
(acc, [key, val], index) => `${acc}${index > 0 ? "&" : ""}${key}=${val}`,
|
||||||
"?"
|
"?",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
export const groupBy = <T>(
|
export const groupBy = <T>(
|
||||||
array: T[],
|
array: T[],
|
||||||
predicate: (value: T, index: number, array: T[]) => string
|
predicate: (value: T, index: number, array: T[]) => string,
|
||||||
) =>
|
) =>
|
||||||
array.reduce((acc, value, index, array) => {
|
array.reduce(
|
||||||
|
(acc, value, index, array) => {
|
||||||
(acc[predicate(value, index, array)] ||= []).push(value);
|
(acc[predicate(value, index, array)] ||= []).push(value);
|
||||||
return acc;
|
return acc;
|
||||||
}, {} as { [key: string]: T[] });
|
},
|
||||||
|
{} as { [key: string]: T[] },
|
||||||
|
);
|
||||||
|
|
|
@ -5,7 +5,7 @@ const DEFAULT_ALPHABET =
|
||||||
|
|
||||||
export default function randomStr(
|
export default function randomStr(
|
||||||
idDesiredLength = 20,
|
idDesiredLength = 20,
|
||||||
alphabet = DEFAULT_ALPHABET
|
alphabet = DEFAULT_ALPHABET,
|
||||||
): string {
|
): string {
|
||||||
/**
|
/**
|
||||||
* Create n-long array and map it to random chars from given alphabet.
|
* Create n-long array and map it to random chars from given alphabet.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { UserService } from "../../services";
|
import { UserService } from "../../services";
|
||||||
|
|
||||||
export default function amAdmin(
|
export default function amAdmin(
|
||||||
myUserInfo = UserService.Instance.myUserInfo
|
myUserInfo = UserService.Instance.myUserInfo,
|
||||||
): boolean {
|
): boolean {
|
||||||
return myUserInfo?.local_user_view.person.admin ?? false;
|
return myUserInfo?.local_user_view.person.admin ?? false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { UserService } from "../../services";
|
||||||
export default function amCommunityCreator(
|
export default function amCommunityCreator(
|
||||||
creator_id: number,
|
creator_id: number,
|
||||||
mods?: CommunityModeratorView[],
|
mods?: CommunityModeratorView[],
|
||||||
myUserInfo = UserService.Instance.myUserInfo
|
myUserInfo = UserService.Instance.myUserInfo,
|
||||||
): boolean {
|
): boolean {
|
||||||
const myId = myUserInfo?.local_user_view.person.id;
|
const myId = myUserInfo?.local_user_view.person.id;
|
||||||
// Don't allow mod actions on yourself
|
// Don't allow mod actions on yourself
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { UserService } from "../../services";
|
||||||
|
|
||||||
export default function amMod(
|
export default function amMod(
|
||||||
mods?: CommunityModeratorView[],
|
mods?: CommunityModeratorView[],
|
||||||
myUserInfo = UserService.Instance.myUserInfo
|
myUserInfo = UserService.Instance.myUserInfo,
|
||||||
): boolean {
|
): boolean {
|
||||||
return myUserInfo ? isMod(myUserInfo.local_user_view.person.id, mods) : false;
|
return myUserInfo ? isMod(myUserInfo.local_user_view.person.id, mods) : false;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue