Skip to content

Commit dfb3d88

Browse files
committed
refactor: update mode terminology from smart/unlimited to whitelist/blacklist
1 parent 6bea385 commit dfb3d88

File tree

18 files changed

+115
-74
lines changed

18 files changed

+115
-74
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We have a live demo that can be found at http://hornetstorage.net for anyone tha
99

1010
## Key Features
1111
- Manage your hornet-storage relay config directly from the panel
12-
- Switch between our new dumb and smart model for accepting nostr notes
12+
- Switch between our new whitelist and blacklist model for accepting nostr notes
1313
- Decide from which of the supported nostr kinds to enable
1414
- Choose which supported transport protocols to enable such as libp2p and websockets
1515
- Enable / disable which media extensions are accepted by the relay such as png and mp4

src/components/header/components/settingsDropdown/settingsOverlay/ServerPicker/SmartBaseModeSettings.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const SmartBaseModeSettings: React.FC = () => {
2121
const kinds = useAppSelector((state) => state.mode.kinds);
2222

2323
const handleModeChange = () => {
24-
dispatch(setMode(mode === 'smart' ? 'unlimited' : 'smart'));
24+
dispatch(setMode(mode === 'whitelist' ? 'blacklist' : 'whitelist'));
2525
};
2626

2727
// Example kinds options, adjust as necessary
@@ -38,13 +38,13 @@ export const SmartBaseModeSettings: React.FC = () => {
3838
<SwitchContainer>
3939
<span>{t('common.serverSetting')}</span>
4040
<BaseSwitch
41-
checkedChildren="Smart"
42-
unCheckedChildren="unlimited"
43-
checked={mode === 'smart'}
41+
checkedChildren="Whitelist"
42+
unCheckedChildren="Blacklist"
43+
checked={mode === 'whitelist'}
4444
onChange={handleModeChange}
4545
/>
4646
</SwitchContainer>
47-
<h4>{mode === 'smart' ? t('common.supportedKindsAndMedia') : t('common.unsupportedKindsAndMedia')}</h4>
47+
<h4>{mode === 'whitelist' ? t('common.supportedKindsAndMedia') : t('common.unsupportedKindsAndMedia')}</h4>
4848
<>
4949
<BaseSelect
5050
mode="multiple"

src/components/moderation/ModerationNotifications/ModerationNotifications.tsx

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,41 @@ export const ModerationNotifications: React.FC<ModerationNotificationsProps> = (
120120
setIsModalVisible(true);
121121
} catch (error) {
122122
console.error('Failed to fetch event details:', error);
123-
notificationController.error({
124-
message: 'Failed to fetch event details',
125-
description: error instanceof Error ? error.message : 'Unknown error'
126-
});
123+
124+
// Check if this is a 400 error (event not found)
125+
if (error instanceof Error && error.message.includes('400')) {
126+
// Add this event ID to the list of non-existent events
127+
// This is done by accessing the module-level variable directly
128+
(window as any).nonExistentEventIds = (window as any).nonExistentEventIds || new Set<string>();
129+
(window as any).nonExistentEventIds.add(eventId);
130+
131+
// Show success message to the user
132+
notificationController.success({
133+
message: 'Notification removed',
134+
description: 'The notification was automatically removed because the referenced event no longer exists'
135+
});
136+
137+
// Try to delete on backend, but don't worry if it fails
138+
try {
139+
await deleteEvent(eventId);
140+
} catch (deleteError) {
141+
// Silently ignore the error since we're handling it locally
142+
console.log('Backend delete failed, handling locally:', deleteError);
143+
}
144+
145+
// Refresh the notifications list to ensure our changes take effect
146+
fetchNotifications({
147+
page: pagination?.currentPage || 1,
148+
limit: pagination?.pageSize || 10,
149+
filter
150+
});
151+
} else {
152+
// For other errors, show the standard error message
153+
notificationController.error({
154+
message: 'Failed to fetch event details',
155+
description: error instanceof Error ? error.message : 'Unknown error'
156+
});
157+
}
127158
} finally {
128159
setIsEventLoading(false);
129160
}

src/components/relay-settings/layouts/DesktopLayout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ export const DesktopLayout: React.FC<DesktopLayoutProps> = ({
171171
<S.LabelSpan>{t('common.serverSetting')}</S.LabelSpan>
172172
<S.LargeSwitch
173173
className="modeSwitch"
174-
checkedChildren="Strict"
175-
unCheckedChildren="Unlimited"
176-
checked={mode === 'smart'}
174+
checkedChildren="Whitelist"
175+
unCheckedChildren="Blacklist"
176+
checked={mode === 'whitelist'}
177177
onChange={onModeChange}
178178
/>
179179
</S.SwitchContainer>

src/components/relay-settings/layouts/MobileLayout.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ export const MobileLayout: React.FC<MobileLayoutProps> = ({
160160
}}
161161
>
162162
<S.LabelSpan>{t('common.serverSetting')}</S.LabelSpan>
163-
<S.LargeSwitch
164-
className="modeSwitch"
165-
checkedChildren="Strict"
166-
unCheckedChildren="Unlimited"
167-
checked={mode === 'smart'}
168-
onChange={onModeChange}
169-
/>
163+
<S.LargeSwitch
164+
className="modeSwitch"
165+
checkedChildren="Whitelist"
166+
unCheckedChildren="Blacklist"
167+
checked={mode === 'whitelist'}
168+
onChange={onModeChange}
169+
/>
170170
</S.SwitchContainer>
171171

172172
<KindsSection

src/components/relay-settings/sections/KindsSection/KindsSection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export const KindsSection: React.FC<KindsSectionProps> = ({
3333
onAddKind,
3434
onRemoveKind,
3535
}) => {
36-
const header = mode !== 'smart' ? 'Blacklisted Kind Numbers' : 'Kind Numbers';
36+
const header = mode !== 'whitelist' ? 'Blacklisted Kind Numbers' : 'Kind Numbers';
3737

3838
return (
3939
<CollapsibleSection header={header}>
4040
<S.Card>
4141
<div className="flex-col w-full">
42-
{mode !== 'unlimited' && mode !== '' && (
42+
{mode !== 'blacklist' && mode !== '' && (
4343
<div className="switch-container">
4444
<BaseSwitch
4545
checkedChildren="ON"
@@ -75,4 +75,4 @@ export const KindsSection: React.FC<KindsSectionProps> = ({
7575
);
7676
};
7777

78-
export default KindsSection;
78+
export default KindsSection;

src/components/relay-settings/sections/KindsSection/components/AddKindForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const AddKindForm: React.FC<AddKindFormProps> = ({ onAddKind, mode }) =>
1919
}
2020
};
2121

22-
if (mode === 'smart') {
22+
if (mode === 'whitelist') {
2323
return null;
2424
}
2525

@@ -40,4 +40,4 @@ export const AddKindForm: React.FC<AddKindFormProps> = ({ onAddKind, mode }) =>
4040
);
4141
};
4242

43-
export default AddKindForm;
43+
export default AddKindForm;

src/components/relay-settings/sections/KindsSection/components/DynamicKindsList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const DynamicKindsList: React.FC<DynamicKindsListProps> = ({
2121
onRemoveKind,
2222
mode,
2323
}) => {
24-
if (!dynamicKinds.length || mode === 'smart') {
24+
if (!dynamicKinds.length || mode === 'whitelist') {
2525
return null;
2626
}
2727

@@ -32,7 +32,7 @@ export const DynamicKindsList: React.FC<DynamicKindsListProps> = ({
3232
return (
3333
<BaseCheckbox.Group
3434
style={{ paddingLeft: '1rem' }}
35-
className={`custom-checkbox-group grid-checkbox-group large-label ${dynamicKinds.length ? 'dynamic-group ' : ''}${mode === 'unlimited' ? 'blacklist-mode-active ' : ''}`}
35+
className={`custom-checkbox-group grid-checkbox-group large-label ${dynamicKinds.length ? 'dynamic-group ' : ''}${mode === 'blacklist' ? 'blacklist-mode-active ' : ''}`}
3636
value={selectedDynamicKinds}
3737
onChange={handleChange}
3838
>
@@ -43,7 +43,7 @@ export const DynamicKindsList: React.FC<DynamicKindsListProps> = ({
4343
>
4444
<div className="checkbox-container">
4545
<BaseCheckbox
46-
className={mode === 'unlimited' ? 'blacklist-mode-active' : ''}
46+
className={mode === 'blacklist' ? 'blacklist-mode-active' : ''}
4747
value={kind}
4848
/>
4949
<S.CheckboxLabel
@@ -65,4 +65,4 @@ export const DynamicKindsList: React.FC<DynamicKindsListProps> = ({
6565
);
6666
};
6767

68-
export default DynamicKindsList;
68+
export default DynamicKindsList;

src/components/relay-settings/sections/KindsSection/components/KindsList.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const KindsList: React.FC<KindsListProps> = ({
3434
className="large-label"
3535
value={selectedKinds}
3636
onChange={(checkedValues) => onKindsChange(checkedValues as string[])}
37-
disabled={mode !== 'smart' ? false : !isKindsActive}
37+
disabled={mode !== 'whitelist' ? false : !isKindsActive}
3838
>
3939
{groupedNoteOptions.map((group) => (
4040
<div key={group.id} style={{ paddingBottom: '2rem' }}>
@@ -44,11 +44,11 @@ export const KindsList: React.FC<KindsListProps> = ({
4444
<div className="checkbox-container" style={{ paddingLeft: '1rem' }} key={note.kindString}>
4545
<BaseCheckbox
4646
value={note.kindString}
47-
className={mode === 'unlimited' ? 'blacklist-mode-active' : ''}
48-
disabled={mode !== 'smart' ? false : !isKindsActive}
47+
className={mode === 'blacklist' ? 'blacklist-mode-active' : ''}
48+
disabled={mode !== 'whitelist' ? false : !isKindsActive}
4949
/>
5050
<S.CheckboxLabel
51-
isActive={mode !== 'smart' ? true : isKindsActive}
51+
isActive={mode !== 'whitelist' ? true : isKindsActive}
5252
style={{
5353
paddingRight: '.8rem',
5454
paddingLeft: '.8rem',
@@ -67,4 +67,4 @@ export const KindsList: React.FC<KindsListProps> = ({
6767
);
6868
};
6969

70-
export default KindsList;
70+
export default KindsList;

src/components/relay-settings/sections/MediaSection/MediaSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const MediaSection: React.FC<MediaSectionProps> = ({
7676
audio,
7777
}) => {
7878
const getHeader = (type: string) =>
79-
mode !== 'smart' ? `Blacklisted ${type} Extensions` : `${type} Extensions`;
79+
mode !== 'whitelist' ? `Blacklisted ${type} Extensions` : `${type} Extensions`;
8080

8181
return (
8282
<>
@@ -134,4 +134,4 @@ export const MediaSection: React.FC<MediaSectionProps> = ({
134134
);
135135
};
136136

137-
export default MediaSection;
137+
export default MediaSection;

0 commit comments

Comments
 (0)