diff --git a/src/views/settings/settings.tsx b/src/views/settings/settings.tsx
index ace91782..63100174 100644
--- a/src/views/settings/settings.tsx
+++ b/src/views/settings/settings.tsx
@@ -6,6 +6,7 @@ import AccountSettings from './account-settings';
import AddressSettings from './address-settings';
import useTheme from '../../hooks/use-theme';
import packageJson from '../../../package.json';
+import _ from 'lodash';
const commitRef = process.env.REACT_APP_COMMIT_REF;
const isElectron = window.isElectron === true;
@@ -173,9 +174,10 @@ const Settings = () => {
window.scrollTo(0, 0);
}, []);
+ const documentTitle = `${_.startCase(t('preferences'))} - Seedit`;
useEffect(() => {
- document.title = `${t('preferences')} - seedit`;
- }, [t]);
+ document.title = documentTitle;
+ }, [documentTitle]);
return (
diff --git a/src/views/submit/submit.module.css b/src/views/submit/submit.module.css
index 737b9bc1..6f7eaedf 100644
--- a/src/views/submit/submit.module.css
+++ b/src/views/submit/submit.module.css
@@ -6,6 +6,7 @@
h1 {
font-size: 18px;
font-weight: normal;
+ text-transform: lowercase;
margin: 10px 0 !important;
}
diff --git a/src/views/submit/submit.tsx b/src/views/submit/submit.tsx
index d7d8f1c4..6994b021 100644
--- a/src/views/submit/submit.tsx
+++ b/src/views/submit/submit.tsx
@@ -141,14 +141,6 @@ const Submit = () => {
const { subscriptions } = account || {};
const defaultSubplebbitAddresses = useDefaultSubplebbitAddresses();
- useEffect(() => {
- window.scrollTo(0, 0);
- }, []);
-
- useEffect(() => {
- document.title = t('submit_to_string', { string: subplebbit?.title || subplebbit?.shortAddress || 'seedit', interpolation: { escapeValue: false } });
- }, [subplebbit, t]);
-
const onPublish = () => {
if (!titleRef.current?.value) {
alert(`Missing title`);
@@ -272,6 +264,15 @@ const Submit = () => {
}
}, [paramsSubplebbitAddress, setSubmitStore]);
+ useEffect(() => {
+ window.scrollTo(0, 0);
+ }, []);
+
+ const documentTitle = t('submit_to_string', { string: subplebbit?.title || subplebbit?.shortAddress || 'Seedit', interpolation: { escapeValue: false } });
+ useEffect(() => {
+ document.title = documentTitle;
+ }, [documentTitle]);
+
return (
diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx
index 0c68c85b..f7d3dcba 100644
--- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx
+++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
import { useLocation, useNavigate, useParams } from 'react-router-dom';
import {
deleteSubplebbit,
@@ -19,6 +19,7 @@ import LoadingEllipsis from '../../../components/loading-ellipsis';
import Markdown from '../../../components/markdown';
import Sidebar from '../../../components/sidebar';
import { isCreateSubplebbitView, isSubplebbitSettingsView } from '../../../lib/utils/view-utils';
+import _ from 'lodash';
type SubplebbitSettingsState = {
challenges: any[] | undefined;
@@ -407,10 +408,15 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
if (exIdx === excludeIndex) {
let newEx = { ...ex };
- // Convert empty string to undefined
- const processedValue = value === '' ? undefined : value;
-
switch (type) {
+ case 'rateLimit':
+ case 'postScore':
+ case 'replyScore':
+ const parsedValue = parseInt(value, 10);
+ if (!isNaN(parsedValue)) {
+ newEx[type] = parsedValue;
+ }
+ break;
case 'not post':
newEx.post = value ? undefined : false;
break;
@@ -431,7 +437,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
}
break;
default:
- newEx[type] = processedValue;
+ newEx[type] = value;
}
return newEx;
}
@@ -515,7 +521,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
)}
)}
- {isReadOnly && !exclude?.postScore && !exclude?.postReply ? null : (
+ {isReadOnly && !(exclude?.postScore || exclude?.replyScore) ? null : (
User's karma
{isReadOnly && !exclude?.postScore ? null : (
@@ -524,17 +530,17 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
{isReadOnly ? (
{exclude?.postScore}
) : (
-
handleExcludeChange(excludeIndex, 'postScore', e.target.value)} />
+
handleExcludeChange(excludeIndex, 'postScore', e.target.value)} />
)}
>
)}
- {isReadOnly && !exclude?.postReply ? null : (
+ {isReadOnly && !exclude?.replyScore ? null : (
<>
Comment karma is at least:
{isReadOnly ? (
-
{exclude?.postReply}
+
{exclude?.replyScore}
) : (
-
handleExcludeChange(excludeIndex, 'postReply', e.target.value)} />
+
handleExcludeChange(excludeIndex, 'replyScore', e.target.value)} />
)}
>
)}
@@ -548,7 +554,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
{exclude?.firstCommentTimestamp}
) : (
handleExcludeChange(excludeIndex, 'firstCommentTimestamp', e.target.value)}
/>
@@ -580,7 +586,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
)}
)}
- {isReadOnly && actionsToExclude.some((action) => exclude.hasOwnProperty(action)) ? null : (
+ {isReadOnly && !actionsToExclude.some((action) => exclude[action] === true) ? null : (
User's action
Is all of the following:
@@ -604,7 +610,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
),
)}
{nonActionsToExclude.map((nonAction) =>
- isReadOnly && exclude?.[nonAction.replace('not ', '')] ? null : (
+ isReadOnly && exclude?.[nonAction.replace('not ', '')] !== null ? null : (
{isReadOnly ? (
{nonAction} excluded
@@ -631,7 +637,7 @@ const ChallengeSettings = ({ challenge, index, isReadOnly, setSubplebbitSettings
{isReadOnly ? (
{exclude?.rateLimit}
) : (
-
handleExcludeChange(excludeIndex, 'rateLimit', e.target.value)} />
+
handleExcludeChange(excludeIndex, 'rateLimit', e.target.value)} />
)}
{isReadOnly && !exclude?.rateLimitChallengeSuccess ? null : (
@@ -870,8 +876,8 @@ const SubplebbitSettings = () => {
}
}, [createdSubplebbit, navigate]);
- // set the store with the initial data
useEffect(() => {
+ resetSubplebbitSettingsStore();
if (subplebbitAddress) {
setSubplebbitSettingsStore({
title: title ?? '',
@@ -886,7 +892,7 @@ const SubplebbitSettings = () => {
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [subplebbitAddress]);
+ }, [subplebbitAddress, resetSubplebbitSettingsStore]);
useEffect(() => {
if (isInCreateSubplebbitView) {
@@ -898,9 +904,19 @@ const SubplebbitSettings = () => {
window.scrollTo(0, 0);
}, []);
+ const documentTitle = useMemo(() => {
+ let title;
+ if (isInSubplebbitSettingsView) {
+ title = _.startCase(t('community_settings'));
+ } else if (isInCreateSubplebbitView) {
+ title = _.startCase(t('create_community'));
+ }
+ return `${title} - Seedit`;
+ }, [isInCreateSubplebbitView, isInSubplebbitSettingsView, t]);
+
useEffect(() => {
- document.title = `${t('preferences')} - seedit`;
- }, [t]);
+ document.title = documentTitle;
+ }, [documentTitle]);
return (
diff --git a/src/views/subplebbit/subplebbit.tsx b/src/views/subplebbit/subplebbit.tsx
index 78437643..029fe6b8 100644
--- a/src/views/subplebbit/subplebbit.tsx
+++ b/src/views/subplebbit/subplebbit.tsx
@@ -28,7 +28,7 @@ const Subplebbit = () => {
const loadingString =
{state === 'failed' ? state : }
;
useEffect(() => {
- document.title = (title ? title : shortAddress) + ' - seedit';
+ document.title = title ? title : shortAddress;
}, [title, shortAddress]);
const Footer = () => {
diff --git a/src/views/subplebbits/subplebbits.tsx b/src/views/subplebbits/subplebbits.tsx
index e46dcc8b..2b5054f1 100644
--- a/src/views/subplebbits/subplebbits.tsx
+++ b/src/views/subplebbits/subplebbits.tsx
@@ -19,6 +19,7 @@ import Markdown from '../../components/markdown';
import Label from '../../components/post/label';
import Sidebar from '../../components/sidebar';
import SubscribeButton from '../../components/subscribe-button';
+import _ from 'lodash';
interface SubplebbitProps {
index?: number;
@@ -131,10 +132,6 @@ const Subplebbit = ({ subplebbit }: SubplebbitProps) => {
const { allActiveUserCount } = useSubplebbitStats({ subplebbitAddress: address });
const isOnline = updatedAt && updatedAt > Date.now() / 1000 - 60 * 30;
- useEffect(() => {
- document.title = `${t('communities')} - seedit`;
- }, [t]);
-
return (
@@ -233,6 +230,7 @@ const AllAccountSubplebbits = () => {
};
const Subplebbits = () => {
+ const { t } = useTranslation();
const location = useLocation();
const isInSubplebbitsSubscriberView = isSubplebbitsSubscriberView(location.pathname);
const isInSubplebbitsModeratorView = isSubplebbitsModeratorView(location.pathname);
@@ -256,6 +254,28 @@ const Subplebbits = () => {
viewRole = 'owner';
}
+ const documentTitle = useMemo(() => {
+ let title = _.startCase(t('communities'));
+ if (isInSubplebbitsVoteView) {
+ title += ` - ${_.startCase(t('vote'))}`;
+ } else if (isInSubplebbitsSubscriberView) {
+ title += ` - ${_.startCase(t('subscriber'))}`;
+ } else if (isInSubplebbitsModeratorView) {
+ title += ` - ${_.startCase(t('moderator'))}`;
+ } else if (isInSubplebbitsAdminView) {
+ title += ` - ${_.startCase(t('admin'))}`;
+ } else if (isInSubplebbitsOwnerView) {
+ title += ` - ${_.startCase(t('owner'))}`;
+ } else if (isInSubplebbitsView) {
+ title += ` - ${_.startCase(t('all'))}`;
+ }
+ return `${title} - Seedit`;
+ }, [isInSubplebbitsSubscriberView, isInSubplebbitsModeratorView, isInSubplebbitsAdminView, isInSubplebbitsOwnerView, isInSubplebbitsView, isInSubplebbitsVoteView, t]);
+
+ useEffect(() => {
+ document.title = documentTitle;
+ }, [documentTitle]);
+
return (
diff --git a/yarn.lock b/yarn.lock
index 800411ec..c208dd3a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2748,21 +2748,6 @@
dependencies:
debug "4.3.3"
-"@plebbit/plebbit-react-hooks@https://github.com/plebbit/plebbit-react-hooks.git#a2d2e9d4dd66f71bfd55768fb30e6799a77ee197":
- version "0.0.1"
- resolved "https://github.com/plebbit/plebbit-react-hooks.git#a2d2e9d4dd66f71bfd55768fb30e6799a77ee197"
- dependencies:
- "@plebbit/plebbit-js" "https://github.com/plebbit/plebbit-js.git#70f898084d7ffb4dd6187fcb00bb36b6fa3e9d25"
- "@plebbit/plebbit-logger" "https://github.com/plebbit/plebbit-logger.git"
- assert "2.0.0"
- ethers "5.6.9"
- localforage "1.10.0"
- lodash.isequal "4.5.0"
- memoizee "0.4.15"
- quick-lru "5.1.1"
- uuid "8.3.2"
- zustand "4.0.0"
-
"@plebbit/plebbit-react-hooks@https://github.com/plebbit/plebbit-react-hooks.git#a3163fe6799dd882b9eac439fd5dd71ec7983a00":
version "0.0.1"
resolved "https://github.com/plebbit/plebbit-react-hooks.git#a3163fe6799dd882b9eac439fd5dd71ec7983a00"