Challenge #{index + 1}
@@ -533,7 +533,7 @@ const Challenges = ({
challengesSettings={challengesSettings || {}}
index={index}
isReadOnly={isReadOnly}
- setSubplebbitSettingsStore={setSubplebbitSettingsStore}
+ setCommunitySettingsStore={setCommunitySettingsStore}
settings={settings}
showSettings={showSettings[index]}
/>
diff --git a/src/views/subplebbit-settings/challenge-settings/index.ts b/src/views/community-settings/challenge-settings/index.ts
similarity index 100%
rename from src/views/subplebbit-settings/challenge-settings/index.ts
rename to src/views/community-settings/challenge-settings/index.ts
diff --git a/src/views/subplebbit-settings/subplebbit-data-editor/subplebbit-data-editor.tsx b/src/views/community-settings/community-data-editor/community-data-editor.tsx
similarity index 82%
rename from src/views/subplebbit-settings/subplebbit-data-editor/subplebbit-data-editor.tsx
rename to src/views/community-settings/community-data-editor/community-data-editor.tsx
index cf376030..be0ca6d6 100644
--- a/src/views/subplebbit-settings/subplebbit-data-editor/subplebbit-data-editor.tsx
+++ b/src/views/community-settings/community-data-editor/community-data-editor.tsx
@@ -1,11 +1,11 @@
import React, { useEffect, useMemo, useState, useRef, lazy, Suspense, Component } from 'react';
import { Trans, useTranslation } from 'react-i18next';
-import { usePublishSubplebbitEdit, useSubplebbit } from '@bitsocial/bitsocial-react-hooks';
+import { usePublishCommunityEdit, useCommunity } from '@bitsocial/bitsocial-react-hooks';
import useTheme from '../../../stores/use-theme-store';
import styles from '../../settings/account-data-editor/account-data-editor.module.css';
import useIsMobile from '../../../hooks/use-is-mobile';
import LoadingEllipsis from '../../../components/loading-ellipsis';
-import useSubplebbitSettingsStore from '../../../stores/use-subplebbit-settings-store';
+import useCommunitySettingsStore from '../../../stores/use-community-settings-store';
import { useNavigate, useParams } from 'react-router-dom';
import ErrorDisplay from '../../../components/error-display';
import useStateString from '../../../hooks/use-state-string';
@@ -51,22 +51,22 @@ const FallbackEditor = ({ value, onChange, height, disabled }: { value: string;
);
};
-const SubplebbitDataEditor = () => {
+const CommunityDataEditor = () => {
const { t } = useTranslation();
const isMobile = useIsMobile();
const navigate = useNavigate();
const theme = useTheme((state) => state.theme);
const [text, setText] = useState('');
- const { subplebbitAddress } = useParams<{ subplebbitAddress: string }>();
- const subplebbit = useSubplebbit({ subplebbitAddress });
+ const { communityAddress: subplebbitAddress } = useParams<{ communityAddress: string }>();
+ const subplebbit = useCommunity(subplebbitAddress ? { community: { name: subplebbitAddress } } : undefined);
const { address, createdAt, description, error, rules, settings, suggested, roles, title } = subplebbit || {};
const hasLoaded = !!createdAt;
const {
- publishSubplebbitEditOptions,
- setSubplebbitSettingsStore,
- resetSubplebbitSettingsStore,
+ publishCommunityEditOptions,
+ setCommunitySettingsStore,
+ resetCommunitySettingsStore,
title: storeTitle,
description: storeDescription,
address: storeAddress,
@@ -74,14 +74,14 @@ const SubplebbitDataEditor = () => {
rules: storeRules,
roles: storeRoles,
settings: storeSettings,
- subplebbitAddress: storeSubplebbitAddress,
- } = useSubplebbitSettingsStore();
+ communityAddress: storeCommunityAddress,
+ } = useCommunitySettingsStore();
- const { error: publishSubplebbitEditError, publishSubplebbitEdit } = usePublishSubplebbitEdit(publishSubplebbitEditOptions);
+ const { error: publishCommunityEditError, publishCommunityEdit: publishSubplebbitEdit } = usePublishCommunityEdit(publishCommunityEditOptions);
// Use store state if available, otherwise fall back to original subplebbit data
const currentSettings = useMemo(() => {
- const { subplebbitAddress: storeAddr } = useSubplebbitSettingsStore.getState();
+ const { communityAddress: storeAddr } = useCommunitySettingsStore.getState();
const hasStoreData = storeAddr === subplebbitAddress;
return {
@@ -92,7 +92,7 @@ const SubplebbitDataEditor = () => {
rules: hasStoreData ? storeRules : rules,
roles: hasStoreData ? storeRoles : roles,
settings: hasStoreData ? storeSettings : settings,
- subplebbitAddress: hasStoreData ? storeSubplebbitAddress : subplebbitAddress,
+ communityAddress: hasStoreData ? storeCommunityAddress : subplebbitAddress,
};
}, [
storeTitle,
@@ -102,7 +102,7 @@ const SubplebbitDataEditor = () => {
storeRules,
storeRoles,
storeSettings,
- storeSubplebbitAddress,
+ storeCommunityAddress,
title,
description,
address,
@@ -142,7 +142,7 @@ const SubplebbitDataEditor = () => {
// Try to sync immediately if JSON is valid
try {
const parsedSettings = JSON.parse(newText);
- setSubplebbitSettingsStore({
+ setCommunitySettingsStore({
title: parsedSettings.title ?? '',
description: parsedSettings.description ?? '',
address: parsedSettings.address,
@@ -150,7 +150,7 @@ const SubplebbitDataEditor = () => {
rules: parsedSettings.rules ?? [],
roles: parsedSettings.roles ?? {},
settings: parsedSettings.settings ?? {},
- subplebbitAddress: parsedSettings.subplebbitAddress,
+ communityAddress: parsedSettings.communityAddress,
});
} catch {
// Invalid JSON - don't spam console during active typing
@@ -167,14 +167,14 @@ const SubplebbitDataEditor = () => {
if (triggerSave) {
const performSave = async () => {
try {
- console.log('Performing save with options:', publishSubplebbitEditOptions);
+ console.log('Performing save with options:', publishCommunityEditOptions);
await publishSubplebbitEdit();
setShowSaving(false);
setTriggerSave(false);
- if (publishSubplebbitEditError) {
- setCurrentError(publishSubplebbitEditError);
- alert(publishSubplebbitEditError.message || 'Error: ' + publishSubplebbitEditError);
+ if (publishCommunityEditError) {
+ setCurrentError(publishCommunityEditError);
+ alert(publishCommunityEditError.message || 'Error: ' + publishCommunityEditError);
} else {
alert(t('settings_saved', { subplebbitAddress }));
}
@@ -192,11 +192,11 @@ const SubplebbitDataEditor = () => {
};
performSave();
}
- // Intentionally only depend on triggerSave to prevent multiple executions when publishSubplebbitEditOptions changes during save
+ // Intentionally only depend on triggerSave to prevent multiple executions when publishCommunityEditOptions changes during save
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [triggerSave]);
- const saveSubplebbitSettings = () => {
+ const saveCommunitySettings = () => {
try {
setShowSaving(true);
setCurrentError(undefined);
@@ -231,12 +231,12 @@ const SubplebbitDataEditor = () => {
useEffect(() => {
if (hasLoaded) {
// Only reset if we're switching to a different subplebbit or if store is uninitialized
- const { subplebbitAddress: storeSubplebbitAddress } = useSubplebbitSettingsStore.getState();
- const shouldReset = !storeSubplebbitAddress || storeSubplebbitAddress !== subplebbitAddress;
+ const { communityAddress: storeCommunityAddress } = useCommunitySettingsStore.getState();
+ const shouldReset = !storeCommunityAddress || storeCommunityAddress !== subplebbitAddress;
if (shouldReset) {
- resetSubplebbitSettingsStore();
- setSubplebbitSettingsStore({
+ resetCommunitySettingsStore();
+ setCommunitySettingsStore({
title: title ?? '',
description: description ?? '',
address,
@@ -244,11 +244,11 @@ const SubplebbitDataEditor = () => {
rules: rules ?? [],
roles: roles ?? {},
settings: settings ?? {},
- subplebbitAddress,
+ communityAddress: subplebbitAddress,
});
}
}
- }, [hasLoaded, resetSubplebbitSettingsStore, setSubplebbitSettingsStore, title, description, address, suggested, rules, roles, settings, subplebbitAddress]);
+ }, [hasLoaded, resetCommunitySettingsStore, setCommunitySettingsStore, title, description, address, suggested, rules, roles, settings, subplebbitAddress]);
const loadingStateString = useStateString(subplebbit);
@@ -319,7 +319,7 @@ const SubplebbitDataEditor = () => {
,
+ 1:
,
2:
@@ -123,7 +123,7 @@ const Address = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const Logo = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const { t } = useTranslation();
- const { suggested, setSubplebbitSettingsStore } = useSubplebbitSettingsStore();
+ const { suggested, setCommunitySettingsStore } = useCommunitySettingsStore();
const [logoUrl, setLogoUrl] = useState(suggested?.avatarUrl);
const [imageError, setImageError] = useState(false);
@@ -147,7 +147,7 @@ const Logo = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
onChange={(e) => {
setLogoUrl(e.target.value.trim());
setImageError(false);
- setSubplebbitSettingsStore({ suggested: { ...suggested, avatarUrl: e.target.value.trim() || undefined } });
+ setCommunitySettingsStore({ suggested: { ...suggested, avatarUrl: e.target.value.trim() || undefined } });
}}
/>
)}
@@ -164,20 +164,20 @@ const Logo = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const Rules = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const { t } = useTranslation();
- const { rules, setSubplebbitSettingsStore } = useSubplebbitSettingsStore();
+ const { rules, setCommunitySettingsStore } = useCommunitySettingsStore();
const lastRuleRef = useRef(null);
const handleRuleChange = (index: number, newRule: string) => {
if (!rules) return;
const updatedRules = [...(rules ?? [])];
updatedRules[index] = newRule;
- setSubplebbitSettingsStore({ rules: updatedRules });
+ setCommunitySettingsStore({ rules: updatedRules });
};
const addedRuleRef = useRef(false);
const addRule = () => {
const newRules = rules ? [...rules, ''] : [''];
- setSubplebbitSettingsStore({ rules: newRules });
+ setCommunitySettingsStore({ rules: newRules });
addedRuleRef.current = true;
};
@@ -191,7 +191,7 @@ const Rules = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const deleteRule = (index: number) => {
if (rules) {
const filteredRules = rules.filter((_, i) => i !== index);
- setSubplebbitSettingsStore({ rules: filteredRules });
+ setCommunitySettingsStore({ rules: filteredRules });
}
};
@@ -224,17 +224,17 @@ const Rules = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const Moderators = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const { t } = useTranslation();
- const { roles, setSubplebbitSettingsStore } = useSubplebbitSettingsStore();
+ const { roles, setCommunitySettingsStore } = useCommunitySettingsStore();
const lastModeratorRef = useRef(null);
const addedModeratorRef = useRef(false);
const handleAddModerator = () => {
if (roles) {
const newRoles: Roles = { ...roles, '': { role: 'moderator' } };
- setSubplebbitSettingsStore({ roles: newRoles });
+ setCommunitySettingsStore({ roles: newRoles });
addedModeratorRef.current = true;
} else {
- setSubplebbitSettingsStore({ roles: { '': { role: 'moderator' } } });
+ setCommunitySettingsStore({ roles: { '': { role: 'moderator' } } });
addedModeratorRef.current = true;
}
};
@@ -250,14 +250,14 @@ const Moderators = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
if (roles) {
const updatedRole: Role = { role: newRole };
const updatedRoles: Roles = { ...roles, [address]: updatedRole };
- setSubplebbitSettingsStore({ roles: updatedRoles });
+ setCommunitySettingsStore({ roles: updatedRoles });
}
};
const handleDeleteModerator = (address: string) => {
if (roles) {
const { [address]: _, ...remainingRoles } = roles;
- setSubplebbitSettingsStore({ roles: remainingRoles });
+ setCommunitySettingsStore({ roles: remainingRoles });
}
};
@@ -265,7 +265,7 @@ const Moderators = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const rolesArray = Object.entries(roles || {});
rolesArray[index] = [newAddress, rolesArray[index][1]];
const updatedRoles = Object.fromEntries(rolesArray);
- setSubplebbitSettingsStore({ roles: updatedRoles });
+ setCommunitySettingsStore({ roles: updatedRoles });
};
return (
@@ -325,7 +325,7 @@ const Moderators = ({ isReadOnly = false }: { isReadOnly?: boolean }) => {
const JSONSettings = ({ isReadOnly: _isReadOnly = false }: { isReadOnly?: boolean }) => {
const { t } = useTranslation();
const navigate = useNavigate();
- const { subplebbitAddress } = useParams<{ subplebbitAddress: string }>();
+ const { communityAddress: subplebbitAddress } = useParams<{ communityAddress: string }>();
return (
@@ -338,63 +338,63 @@ const JSONSettings = ({ isReadOnly: _isReadOnly = false }: { isReadOnly?: boolea
);
};
-const SubplebbitSettings = () => {
+const CommunitySettings = () => {
const { t } = useTranslation();
- const { subplebbitAddress } = useParams<{ subplebbitAddress: string }>();
- const subplebbit = useSubplebbit({ subplebbitAddress });
+ const { communityAddress: subplebbitAddress } = useParams<{ communityAddress: string }>();
+ const subplebbit = useCommunity(subplebbitAddress ? { community: { name: subplebbitAddress } } : undefined);
const { address, challenges, createdAt, description, error, rules, shortAddress, settings, suggested, roles, title } = subplebbit || {};
const hasLoaded = !!createdAt;
- const { challenges: rpcChallenges } = usePlebbitRpcSettings().plebbitRpcSettings || {};
+ const { challenges: rpcChallenges } = usePkcRpcSettings().pkcRpcSettings || {};
const challengeNames = Object.keys(rpcChallenges || {});
const account = useAccount();
const location = useLocation();
const navigate = useNavigate();
const params = useParams();
- const isInCreateSubplebbitView = isCreateSubplebbitView(location.pathname);
- const isInSubplebbitSettingsView = isSubplebbitSettingsView(location.pathname, params);
- const isConnectedToRpc = usePlebbitRpcSettings()?.state === 'connected';
+ const isInCreateCommunityView = isCreateCommunityView(location.pathname);
+ const isInCommunitySettingsView = isCommunitySettingsView(location.pathname, params);
+ const isConnectedToRpc = usePkcRpcSettings()?.state === 'connected';
- if (isInCreateSubplebbitView && !isConnectedToRpc) {
+ if (isInCreateCommunityView && !isConnectedToRpc) {
navigate('/', { replace: true });
}
const userAddress = account?.author?.address;
const userIsOwnerOrAdmin = isUserOwnerOrAdmin(roles, userAddress);
- const { isOffline, offlineTitle } = useIsSubplebbitOffline(subplebbit || {});
+ const { isOffline, offlineTitle } = useIsCommunityOffline(subplebbit || {});
// General fields can be edited by owners/admins even without RPC connection
- const isReadOnly = (!settings && isInSubplebbitSettingsView && !userIsOwnerOrAdmin) || (!isConnectedToRpc && isInCreateSubplebbitView && !userIsOwnerOrAdmin);
+ const isReadOnly = (!settings && isInCommunitySettingsView && !userIsOwnerOrAdmin) || (!isConnectedToRpc && isInCreateCommunityView && !userIsOwnerOrAdmin);
// Challenges are always read-only when not connected to RPC
- const isChallengesReadOnly = (!isConnectedToRpc || !settings) && !isInCreateSubplebbitView;
+ const isChallengesReadOnly = (!isConnectedToRpc || !settings) && !isInCreateCommunityView;
- const { publishSubplebbitEditOptions, resetSubplebbitSettingsStore, setSubplebbitSettingsStore, title: storeTitle } = useSubplebbitSettingsStore();
- const { error: publishSubplebbitEditError, publishSubplebbitEdit } = usePublishSubplebbitEdit(publishSubplebbitEditOptions);
- const { error: createSubplebbitError, createdSubplebbit, createSubplebbit } = useCreateSubplebbit(publishSubplebbitEditOptions);
+ const { publishCommunityEditOptions, resetCommunitySettingsStore, setCommunitySettingsStore, title: storeTitle } = useCommunitySettingsStore();
+ const { error: publishCommunityEditError, publishCommunityEdit: publishSubplebbitEdit } = usePublishCommunityEdit(publishCommunityEditOptions);
+ const { error: createCommunityError, createdCommunity, createCommunity: createSubplebbit } = useCreateCommunity(publishCommunityEditOptions);
const [showSaving, setShowSaving] = useState(false);
const [currentError, setCurrentError] = useState
(undefined);
useEffect(() => {
- if (publishSubplebbitEditError || createSubplebbitError) {
- setCurrentError(publishSubplebbitEditError || createSubplebbitError);
+ if (publishCommunityEditError || createCommunityError) {
+ setCurrentError(publishCommunityEditError || createCommunityError);
}
- }, [publishSubplebbitEditError, createSubplebbitError]);
+ }, [publishCommunityEditError, createCommunityError]);
const saveSubplebbit = async () => {
try {
setShowSaving(true);
setCurrentError(undefined);
- console.log('Saving subplebbit with options:', publishSubplebbitEditOptions);
+ console.log('Saving subplebbit with options:', publishCommunityEditOptions);
await publishSubplebbitEdit();
setShowSaving(false);
- if (publishSubplebbitEditError) {
- setCurrentError(publishSubplebbitEditError);
- alert(publishSubplebbitEditError.message || 'Error: ' + publishSubplebbitEditError);
+ if (publishCommunityEditError) {
+ setCurrentError(publishCommunityEditError);
+ alert(publishCommunityEditError.message || 'Error: ' + publishCommunityEditError);
} else {
alert(t('settings_saved', { subplebbitAddress }));
}
@@ -411,12 +411,12 @@ const SubplebbitSettings = () => {
};
const [showDeleting, setShowDeleting] = useState(false);
- const _deleteSubplebbit = async () => {
+ const _deleteCommunity = async () => {
if (subplebbitAddress && window.confirm(t('delete_confirm', { value: `s/${shortAddress}`, interpolation: { escapeValue: false } }))) {
if (window.confirm(t('double_confirm'))) {
try {
setShowDeleting(true);
- await deleteSubplebbit(subplebbitAddress);
+ await deleteCommunity(subplebbitAddress);
setShowDeleting(false);
alert(t('community_deleted'));
navigate('/', { replace: true });
@@ -432,17 +432,17 @@ const SubplebbitSettings = () => {
}
};
- const _createSubplebbit = async () => {
+ const _createCommunity = async () => {
try {
setShowSaving(true);
setCurrentError(undefined);
- console.log('Creating subplebbit with settings:', publishSubplebbitEditOptions);
+ console.log('Creating subplebbit with settings:', publishCommunityEditOptions);
await createSubplebbit();
setShowSaving(false);
- if (createSubplebbitError) {
- setCurrentError(createSubplebbitError);
- alert(createSubplebbitError.message || 'Error: ' + createSubplebbitError);
+ if (createCommunityError) {
+ setCurrentError(createCommunityError);
+ alert(createCommunityError.message || 'Error: ' + createCommunityError);
}
} catch (e) {
setShowSaving(false);
@@ -456,30 +456,30 @@ const SubplebbitSettings = () => {
}
};
- const { subscribe } = useSubscribe({ subplebbitAddress: createdSubplebbit?.address });
+ const { subscribe } = useSubscribe({ communityAddress: createdCommunity?.address });
useEffect(() => {
- if (createdSubplebbit) {
- console.log('createdSubplebbit', createdSubplebbit);
- alert(`community created, address: ${createdSubplebbit?.address}`);
+ if (createdCommunity) {
+ console.log('createdCommunity', createdCommunity);
+ alert(`community created, address: ${createdCommunity?.address}`);
- if (account && createdSubplebbit.address) {
+ if (account && createdCommunity.address) {
subscribe();
}
- resetSubplebbitSettingsStore();
- navigate(`/s/${createdSubplebbit?.address}/`);
+ resetCommunitySettingsStore();
+ navigate(`/s/${createdCommunity?.address}/`);
}
- }, [createdSubplebbit, navigate, resetSubplebbitSettingsStore, account, subscribe]);
+ }, [createdCommunity, navigate, resetCommunitySettingsStore, account, subscribe]);
const lastViewType = useRef<'create' | 'settings' | 'other' | undefined>(undefined);
// Initialize store for create view only on first entry or when switching from settings view
useEffect(() => {
- if (isInCreateSubplebbitView && lastViewType.current === 'settings') {
- resetSubplebbitSettingsStore();
+ if (isInCreateCommunityView && lastViewType.current === 'settings') {
+ resetCommunitySettingsStore();
const initialRoles: Roles = account?.author?.address ? { [account.author.address]: { role: 'owner' as const } } : {};
- setSubplebbitSettingsStore({
+ setCommunitySettingsStore({
title: '',
description: '',
address: undefined,
@@ -488,28 +488,28 @@ const SubplebbitSettings = () => {
roles: initialRoles,
settings: {},
challenges: [],
- subplebbitAddress: undefined,
+ communityAddress: undefined,
});
}
- if (isInCreateSubplebbitView) {
+ if (isInCreateCommunityView) {
lastViewType.current = 'create';
- } else if (isInSubplebbitSettingsView) {
+ } else if (isInCommunitySettingsView) {
lastViewType.current = 'settings';
} else {
lastViewType.current = 'other';
}
- }, [isInCreateSubplebbitView, storeTitle, resetSubplebbitSettingsStore, setSubplebbitSettingsStore, account, isInSubplebbitSettingsView]);
+ }, [isInCreateCommunityView, storeTitle, resetCommunitySettingsStore, setCommunitySettingsStore, account, isInCommunitySettingsView]);
// Set store for loaded subplebbit settings when editing
useEffect(() => {
- if (!isInCreateSubplebbitView && hasLoaded) {
+ if (!isInCreateCommunityView && hasLoaded) {
// Only reset if we're switching to a different subplebbit or if store is uninitialized
- const { subplebbitAddress: storeSubplebbitAddress } = useSubplebbitSettingsStore.getState();
- const shouldReset = !storeSubplebbitAddress || storeSubplebbitAddress !== subplebbitAddress;
+ const { communityAddress: storeCommunityAddress } = useCommunitySettingsStore.getState();
+ const shouldReset = !storeCommunityAddress || storeCommunityAddress !== subplebbitAddress;
if (shouldReset) {
- resetSubplebbitSettingsStore();
- setSubplebbitSettingsStore({
+ resetCommunitySettingsStore();
+ setCommunitySettingsStore({
title: title ?? '',
description: description ?? '',
address,
@@ -518,15 +518,15 @@ const SubplebbitSettings = () => {
roles: roles ?? {},
settings: settings ?? {},
challenges: challenges ?? [],
- subplebbitAddress,
+ communityAddress: subplebbitAddress,
});
}
}
}, [
- isInCreateSubplebbitView,
+ isInCreateCommunityView,
hasLoaded,
- resetSubplebbitSettingsStore,
- setSubplebbitSettingsStore,
+ resetCommunitySettingsStore,
+ setCommunitySettingsStore,
title,
description,
address,
@@ -540,13 +540,13 @@ const SubplebbitSettings = () => {
const documentTitle = useMemo(() => {
let title;
- if (isInSubplebbitSettingsView) {
+ if (isInCommunitySettingsView) {
title = _.startCase(t('community_settings', { interpolation: { escapeValue: false } }));
- } else if (isInCreateSubplebbitView) {
+ } else if (isInCreateCommunityView) {
title = _.startCase(t('create_community', { interpolation: { escapeValue: false } }));
}
return `${title} - Seedit`;
- }, [isInCreateSubplebbitView, isInSubplebbitSettingsView, t]);
+ }, [isInCreateCommunityView, isInCommunitySettingsView, t]);
useEffect(() => {
document.title = documentTitle;
@@ -558,7 +558,7 @@ const SubplebbitSettings = () => {
const loadingStateString = useStateString(subplebbit);
- if (!hasLoaded && !isInCreateSubplebbitView) {
+ if (!hasLoaded && !isInCreateCommunityView) {
return (
<>
{error?.message && (
@@ -575,7 +575,7 @@ const SubplebbitSettings = () => {
return (
- {!isInCreateSubplebbitView && (
+ {!isInCreateCommunityView && (
@@ -585,20 +585,20 @@ const SubplebbitSettings = () => {
{isChallengesReadOnly &&
cannot read or write challenges, community node isn't reachable.
}
- {!isInCreateSubplebbitView &&
}
+ {!isInCreateCommunityView &&
}
- {!isInCreateSubplebbitView &&
}
+ {!isInCreateCommunityView &&
}
- {!isInCreateSubplebbitView && !isReadOnly && (
+ {!isInCreateCommunityView && !isReadOnly && (
{t('delete_community')}
{t('delete_community_description')}
-
)}
{!isReadOnly && (
-
(isInCreateSubplebbitView ? _createSubplebbit() : saveSubplebbit())} disabled={showSaving || showDeleting}>
- {isInCreateSubplebbitView ? t('create_community') : t('save_options')}
+ (isInCreateCommunityView ? _createCommunity() : saveSubplebbit())} disabled={showSaving || showDeleting}>
+ {isInCreateCommunityView ? t('create_community') : t('save_options')}
)}
{showSaving && }
@@ -622,4 +622,4 @@ const SubplebbitSettings = () => {
);
};
-export default SubplebbitSettings;
+export default CommunitySettings;
diff --git a/src/views/community-settings/index.ts b/src/views/community-settings/index.ts
new file mode 100644
index 00000000..40004c34
--- /dev/null
+++ b/src/views/community-settings/index.ts
@@ -0,0 +1 @@
+export { default } from './community-settings';
diff --git a/src/views/subplebbit/subplebbit.tsx b/src/views/community/community.tsx
similarity index 95%
rename from src/views/subplebbit/subplebbit.tsx
rename to src/views/community/community.tsx
index e26eebff..259cf8ab 100644
--- a/src/views/subplebbit/subplebbit.tsx
+++ b/src/views/community/community.tsx
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { Link, useParams, useNavigate, useSearchParams } from 'react-router-dom';
-import { useAccountComments, useBlock, useFeed, useSubplebbit, type Comment } from '@bitsocial/bitsocial-react-hooks';
+import { useAccountComments, useBlock, useFeed, useCommunity, type Comment } from '@bitsocial/bitsocial-react-hooks';
import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso';
import { Trans, useTranslation } from 'react-i18next';
import styles from '../home/home.module.css';
@@ -12,8 +12,9 @@ import useFeedFiltersStore from '../../stores/use-feed-filters-store';
import useFeedResetStore from '../../stores/use-feed-reset-store';
import { usePinnedPostsStore } from '../../stores/use-pinned-posts-store';
import { useIsBroadlyNsfwSubplebbit } from '../../hooks/use-is-broadly-nsfw-subplebbit';
-import useIsSubplebbitOffline from '../../hooks/use-is-subplebbit-offline';
+import useIsCommunityOffline from '../../hooks/use-is-community-offline';
import useTimeFilter, { isValidTimeFilterName } from '../../hooks/use-time-filter';
+import { getCommunityIdentifiers } from '../../hooks/use-community-identifier';
import ErrorDisplay from '../../components/error-display';
import LoadingEllipsis from '../../components/loading-ellipsis';
import Over18Warning from '../../components/over-18-warning';
@@ -213,16 +214,16 @@ const Footer = ({
);
};
-const Subplebbit = () => {
+const CommunityView = () => {
const params = useParams();
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
const searchQuery = searchParams.get('q') || '';
- const subplebbitAddress = params?.subplebbitAddress || '';
- const subplebbit = useSubplebbit({ subplebbitAddress });
+ const subplebbitAddress = params?.communityAddress || '';
+ const subplebbit = useCommunity(subplebbitAddress ? { community: { name: subplebbitAddress } } : undefined);
const { createdAt, error, shortAddress, started, title, updatedAt, settings } = subplebbit || {};
- const { isOffline } = useIsSubplebbitOffline(subplebbit || {});
+ const { isOffline } = useIsCommunityOffline(subplebbit || {});
const isOnline = !isOffline;
const isSubCreatedButNotYetPublished = typeof createdAt === 'number' && !updatedAt;
@@ -248,7 +249,7 @@ const Subplebbit = () => {
const feedOptions = useMemo(() => {
const options: any = {
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
sortType,
newerThan: searchQuery ? 0 : timeFilterSeconds,
};
@@ -392,4 +393,4 @@ const Subplebbit = () => {
);
};
-export default Subplebbit;
+export default CommunityView;
diff --git a/src/views/community/index.ts b/src/views/community/index.ts
new file mode 100644
index 00000000..759d0610
--- /dev/null
+++ b/src/views/community/index.ts
@@ -0,0 +1 @@
+export { default } from './community';
diff --git a/src/views/domain/domain.tsx b/src/views/domain/domain.tsx
index 5e2f11d8..f7e875a7 100644
--- a/src/views/domain/domain.tsx
+++ b/src/views/domain/domain.tsx
@@ -7,6 +7,7 @@ import useFeedFiltersStore from '../../stores/use-feed-filters-store';
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
import useTimeFilter, { isValidTimeFilterName } from '../../hooks/use-time-filter';
import FeedFooter from '../../components/feed-footer';
+import { getCommunityIdentifiers } from '../../hooks/use-community-identifier';
import LoadingEllipsis from '../../components/loading-ellipsis';
import Post from '../../components/post';
import Sidebar from '../../components/sidebar';
@@ -67,19 +68,19 @@ const Domain = () => {
const options: {
newerThan: number;
sortType: string;
- subplebbitAddresses: string[];
+ communities: ReturnType;
filter: CommentsFilter;
} = {
newerThan: searchQuery ? 0 : (timeFilterSeconds ?? 0),
sortType,
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
filter: { filter: filterFunc, key: filterKey },
};
return options;
}, [subplebbitAddresses, sortType, timeFilterSeconds, searchQuery, matchesDomain, domain]);
- const { feed, hasMore, loadMore, reset, subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
+ const { feed, hasMore, loadMore, reset, communityKeysWithNewerPosts: subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
useEffect(() => {
if (isSearching) {
@@ -108,21 +109,21 @@ const Domain = () => {
// suggest the user to change time filter if there aren't enough posts
const { feed: weeklyFeed } = useFeed({
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
sortType,
newerThan: 60 * 60 * 24 * 7,
filter: { filter: matchesDomain, key: `domain-filter-weekly-${domain}` },
});
const { feed: monthlyFeed } = useFeed({
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
sortType,
newerThan: 60 * 60 * 24 * 30,
filter: { filter: matchesDomain, key: `domain-filter-monthly-${domain}` },
});
const { feed: yearlyFeed } = useFeed({
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
sortType,
newerThan: 60 * 60 * 24 * 365,
filter: { filter: matchesDomain, key: `domain-filter-yearly-${domain}` },
diff --git a/src/views/home/home.tsx b/src/views/home/home.tsx
index cdb8c958..3a410ec5 100644
--- a/src/views/home/home.tsx
+++ b/src/views/home/home.tsx
@@ -8,6 +8,7 @@ import useFeedFiltersStore from '../../stores/use-feed-filters-store';
import { useAutoSubscribeStore } from '../../stores/use-auto-subscribe-store';
import useTimeFilter, { isValidTimeFilterName } from '../../hooks/use-time-filter';
import useRedirectToDefaultSort from '../../hooks/use-redirect-to-default-sort';
+import { getCommunityIdentifiers } from '../../hooks/use-community-identifier';
import FeedFooter from '../../components/feed-footer';
import LoadingEllipsis from '../../components/loading-ellipsis';
import Post from '../../components/post';
@@ -75,7 +76,7 @@ const Home = () => {
newerThan: searchQuery ? 0 : timeFilterSeconds,
postsPerPage: 10,
sortType,
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
};
if (searchQuery) {
@@ -88,7 +89,7 @@ const Home = () => {
return options;
}, [subplebbitAddresses, sortType, timeFilterSeconds, searchQuery, commentFilter]);
- const { feed, hasMore, loadMore, reset, subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
+ const { feed, hasMore, loadMore, reset, communityKeysWithNewerPosts: subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
useEffect(() => {
startTransition(() => {
@@ -126,7 +127,7 @@ const Home = () => {
hasMore: hasMoreWeekly,
loadMore: loadMoreWeekly,
} = useFeed({
- subplebbitAddresses: shouldLoadAdditionalFeeds ? subplebbitAddresses : [],
+ communities: getCommunityIdentifiers(shouldLoadAdditionalFeeds ? subplebbitAddresses : []),
sortType,
newerThan: 60 * 60 * 24 * 7,
});
@@ -135,7 +136,7 @@ const Home = () => {
hasMore: hasMoreMonthly,
loadMore: loadMoreMonthly,
} = useFeed({
- subplebbitAddresses: shouldLoadAdditionalFeeds ? subplebbitAddresses : [],
+ communities: getCommunityIdentifiers(shouldLoadAdditionalFeeds ? subplebbitAddresses : []),
sortType,
newerThan: 60 * 60 * 24 * 30,
});
@@ -144,7 +145,7 @@ const Home = () => {
hasMore: hasMoreYearly,
loadMore: loadMoreYearly,
} = useFeed({
- subplebbitAddresses: shouldLoadAdditionalFeeds ? subplebbitAddresses : [],
+ communities: getCommunityIdentifiers(shouldLoadAdditionalFeeds ? subplebbitAddresses : []),
sortType,
newerThan: 60 * 60 * 24 * 365,
});
diff --git a/src/views/mod/mod.tsx b/src/views/mod/mod.tsx
index 0f8935c6..c7c5e49f 100644
--- a/src/views/mod/mod.tsx
+++ b/src/views/mod/mod.tsx
@@ -1,12 +1,13 @@
import { useEffect, useRef, useState, useMemo } from 'react';
import { useParams, useSearchParams, useNavigate, useLocation } from 'react-router-dom';
import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso';
-import { useAccountSubplebbits, useFeed } from '@bitsocial/bitsocial-react-hooks';
+import { useAccountCommunities, useFeed } from '@bitsocial/bitsocial-react-hooks';
import { useTranslation } from 'react-i18next';
import { commentMatchesPattern } from '../../lib/utils/pattern-utils';
import useFeedFiltersStore from '../../stores/use-feed-filters-store';
import useTimeFilter, { isValidTimeFilterName } from '../../hooks/use-time-filter';
import FeedFooter from '../../components/feed-footer';
+import { getCommunityIdentifiers } from '../../hooks/use-community-identifier';
import LoadingEllipsis from '../../components/loading-ellipsis';
import Post from '../../components/post';
import Sidebar from '../../components/sidebar';
@@ -16,7 +17,7 @@ import styles from '../home/home.module.css';
const lastVirtuosoStates: { [key: string]: StateSnapshot } = {};
const Mod = () => {
- const { accountSubplebbits } = useAccountSubplebbits();
+ const { accountCommunities: accountSubplebbits } = useAccountCommunities();
const subplebbitAddresses = Object.keys(accountSubplebbits);
const params = useParams<{ sortType?: string; timeFilterName?: string }>();
const [searchParams, setSearchParams] = useSearchParams();
@@ -45,7 +46,7 @@ const Mod = () => {
const options: any = {
newerThan: searchQuery ? 0 : timeFilterSeconds,
sortType,
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
};
if (searchQuery) {
@@ -61,7 +62,7 @@ const Mod = () => {
return options;
}, [subplebbitAddresses, sortType, timeFilterSeconds, searchQuery]);
- const { feed, hasMore, loadMore, reset, subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
+ const { feed, hasMore, loadMore, reset, communityKeysWithNewerPosts: subplebbitAddressesWithNewerPosts } = useFeed(feedOptions);
// suggest the user to change time filter if there aren't enough posts
const {
@@ -69,7 +70,7 @@ const Mod = () => {
hasMore: hasMoreWeekly,
loadMore: loadMoreWeekly,
} = useFeed({
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
sortType,
newerThan: 60 * 60 * 24 * 7,
});
@@ -78,7 +79,7 @@ const Mod = () => {
hasMore: hasMoreMonthly,
loadMore: loadMoreMonthly,
} = useFeed({
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
sortType,
newerThan: 60 * 60 * 24 * 30,
});
@@ -87,7 +88,7 @@ const Mod = () => {
hasMore: hasMoreYearly,
loadMore: loadMoreYearly,
} = useFeed({
- subplebbitAddresses,
+ communities: getCommunityIdentifiers(subplebbitAddresses),
sortType,
newerThan: 60 * 60 * 24 * 365,
});
diff --git a/src/views/post-page/post-page.tsx b/src/views/post-page/post-page.tsx
index e58a1ed2..701e3e1c 100644
--- a/src/views/post-page/post-page.tsx
+++ b/src/views/post-page/post-page.tsx
@@ -1,7 +1,7 @@
import { useEffect, useState, useRef, useCallback, useMemo } from 'react';
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
-import { Comment, useAccount, useAccountComment, useAccountComments, useComment, useSubplebbit } from '@bitsocial/bitsocial-react-hooks';
+import { Comment, useAccount, useAccountComment, useAccountComments, useComment, useCommunity } from '@bitsocial/bitsocial-react-hooks';
import findTopParentCidOfReply from '../../lib/utils/cid-utils';
import { sortRepliesByBest } from '../../lib/utils/post-utils';
import { isPendingPostView, isPostContextView } from '../../lib/utils/view-utils';
@@ -274,12 +274,13 @@ const PostPage = () => {
}
}, [pendingPost?.cid, pendingPost?.subplebbitAddress, navigate, resetFeed]);
- const { commentCid, subplebbitAddress } = params;
- let post = useComment({ commentCid });
+ const { commentCid, communityAddress: subplebbitAddress } = params;
+ let post = useComment({ commentCid }) as any;
if (isInPendingPostView) {
post = pendingPost;
}
- const subplebbit = useSubplebbit({ subplebbitAddress: isInPendingPostView ? pendingPost?.subplebbitAddress : subplebbitAddress });
+ const _communityAddr = isInPendingPostView ? pendingPost?.subplebbitAddress : subplebbitAddress;
+ const subplebbit = useCommunity(_communityAddr ? { community: { name: _communityAddr } } : undefined);
// over 18 warning for subplebbit with nsfw tag in multisub default list
const { hasAcceptedWarning } = useContentOptionsStore();
diff --git a/src/views/settings/plebbit-options/plebbit-options.tsx b/src/views/settings/plebbit-options/plebbit-options.tsx
index bf01c96c..d352f4ea 100644
--- a/src/views/settings/plebbit-options/plebbit-options.tsx
+++ b/src/views/settings/plebbit-options/plebbit-options.tsx
@@ -1,7 +1,7 @@
import { RefObject, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
-import { setAccount, useAccount, usePlebbitRpcSettings } from '@bitsocial/bitsocial-react-hooks';
+import { setAccount, useAccount, usePkcRpcSettings } from '@bitsocial/bitsocial-react-hooks';
import styles from './plebbit-options.module.css';
interface SettingsProps {
@@ -159,10 +159,10 @@ const PlebbitRPCSettings = ({ plebbitRpcRef }: SettingsProps) => {
};
const PlebbitDataPathSettings = ({ plebbitDataPathRef }: SettingsProps) => {
- const plebbitRpc = usePlebbitRpcSettings();
- const { plebbitRpcSettings } = plebbitRpc || {};
+ const plebbitRpc = usePkcRpcSettings();
+ const { pkcRpcSettings } = plebbitRpc || {};
const isConnectedToRpc = plebbitRpc?.state === 'connected';
- const path = plebbitRpcSettings?.plebbitOptions?.dataPath || '';
+ const path = pkcRpcSettings?.plebbitOptions?.dataPath || '';
return (
diff --git a/src/views/submit-page/submit-page.tsx b/src/views/submit-page/submit-page.tsx
index d0bb89c7..841a7a34 100644
--- a/src/views/submit-page/submit-page.tsx
+++ b/src/views/submit-page/submit-page.tsx
@@ -2,15 +2,15 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
import { useDropzone } from 'react-dropzone';
import { Trans, useTranslation } from 'react-i18next';
import { Link, useNavigate, useParams } from 'react-router-dom';
-import { useAccount, usePublishComment, useSubplebbit } from '@bitsocial/bitsocial-react-hooks';
-import Plebbit from '@plebbit/plebbit-js';
+import { useAccount, usePublishComment, useCommunity } from '@bitsocial/bitsocial-react-hooks';
import { Capacitor } from '@capacitor/core';
import FileUploader from '../../plugins/file-uploader';
import { getLinkMediaInfo } from '../../lib/utils/media-utils';
+import getShortAddress from '../../lib/utils/address-utils';
import { isValidURL } from '../../lib/utils/url-utils';
import usePublishPostStore from '../../stores/use-publish-post-store';
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
-import useIsSubplebbitOffline from '../../hooks/use-is-subplebbit-offline';
+import useIsCommunityOffline from '../../hooks/use-is-community-offline';
import LoadingEllipsis from '../../components/loading-ellipsis';
import Markdown from '../../components/markdown';
import Embed from '../../components/post/embed';
@@ -405,7 +405,7 @@ const SubplebbitAddressField = () => {
setPublishPostStore({ subplebbitAddress: subscription });
}}
>
- {Plebbit.getShortAddress({ address: subscription })}
+ {getShortAddress(subscription)}
))}
@@ -470,13 +470,13 @@ const SubmitPage = () => {
const { link, title, subplebbitAddress, publishCommentOptions, setPublishPostStore, resetPublishPostStore } = usePublishPostStore();
useEffect(() => {
- setPublishPostStore({ subplebbitAddress: params.subplebbitAddress || '' });
- }, [params.subplebbitAddress, setPublishPostStore]);
+ setPublishPostStore({ subplebbitAddress: params.communityAddress || '' });
+ }, [params.communityAddress, setPublishPostStore]);
- const selectedSubplebbitData = useSubplebbit({ subplebbitAddress });
+ const selectedSubplebbitData = useCommunity(subplebbitAddress ? { community: { name: subplebbitAddress } } : undefined);
const { rules, title: subplebbitTitle } = selectedSubplebbitData;
- const shortAddress = subplebbitAddress && Plebbit.getShortAddress({ address: subplebbitAddress });
- const { isOffline, offlineTitle } = useIsSubplebbitOffline(selectedSubplebbitData);
+ const shortAddress = subplebbitAddress && getShortAddress(subplebbitAddress);
+ const { isOffline, offlineTitle } = useIsCommunityOffline(selectedSubplebbitData);
const { index, publishComment } = usePublishComment(publishCommentOptions);
diff --git a/src/views/subplebbit-settings/index.ts b/src/views/subplebbit-settings/index.ts
deleted file mode 100644
index ed8a6555..00000000
--- a/src/views/subplebbit-settings/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './subplebbit-settings';
diff --git a/src/views/subplebbit-settings/subplebbit-data-editor/index.ts b/src/views/subplebbit-settings/subplebbit-data-editor/index.ts
deleted file mode 100644
index 5edffcdf..00000000
--- a/src/views/subplebbit-settings/subplebbit-data-editor/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './subplebbit-data-editor';
diff --git a/src/views/subplebbit/index.ts b/src/views/subplebbit/index.ts
deleted file mode 100644
index 69fb33d9..00000000
--- a/src/views/subplebbit/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './subplebbit';
diff --git a/src/views/subplebbits/index.ts b/src/views/subplebbits/index.ts
deleted file mode 100644
index 682a6c5d..00000000
--- a/src/views/subplebbits/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './subplebbits';