Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REACT_APP_BASE_URL=http://localhost:9002
# REACT_APP_BASE_URL=https://11561ba2d27f.ngrok.app
REACT_APP_ASSETS_BUCKET=http://localhost
REACT_APP_DEMO_MODE=false
REACT_APP_DEMO_MODE=true

# more info https://create-react-app.dev/docs/advanced-configuration
ESLINT_NO_DEV_ERRORS=true
Expand Down
4 changes: 2 additions & 2 deletions src/components/layouts/main/sider/sidebarNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const useSidebarNavigation = (): SidebarNavigationItem[] => {
},
{
title: 'common.relay-settings',
key: 'storage-settings',
url: '/storage-settings',
key: 'relay-settings',
url: '/relay-settings',
icon: <StorageSettingsIcon />,
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/router/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Logout = React.lazy(() => import('./Logout'));

export const NFT_DASHBOARD_PATH = '/';
export const MEDICAL_DASHBOARD_PATH = '/medical-dashboard';
export const RELAY_SETTINGS_PATH = '/storage-settings';
export const RELAY_SETTINGS_PATH = '/relay-settings';
export const TABLES_PAGE_PATH = '/nostr-stats';

const MedicalDashboard = withLoading(MedicalDashboardPage);
Expand Down
64 changes: 64 additions & 0 deletions src/constants/relaySettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
export type Settings = {
mode: string;
protocol: string[];
chunked: string[];
chunksize: string;
maxFileSize: number;
maxFileSizeUnit: string;
kinds: string[];
dynamicKinds: string[];
photos: string[];
videos: string[];
gitNestr: string[];
audio: string[];
appBuckets: string[];
dynamicAppBuckets: string[];
isKindsActive: boolean;
isPhotosActive: boolean;
isVideosActive: boolean;
isGitNestrActive: boolean;
isAudioActive: boolean;
};

export type Category = 'kinds' | 'photos' | 'videos' | 'gitNestr' | 'audio' | 'dynamicKinds' | 'appBuckets' | 'dynamicAppBuckets';
export const noteOptions = [
{ kind: 0, kindString: 'kind0', description: 'Metadata', category: 1 },
{ kind: 1, kindString: 'kind1', description: 'Text Note', category: 1 },
{ kind: 2, kindString: 'kind2', description: 'Recommend Relay', category: 1 },
{ kind: 3, kindString: 'kind3', description: 'Follow List', category: 1 },
{ kind: 5, kindString: 'kind5', description: 'Event Deletion', category: 1 },
{ kind: 6, kindString: 'kind6', description: 'Repost', category: 1 },
{ kind: 7, kindString: 'kind7', description: 'Reaction', category: 1 },
{ kind: 8, kindString: 'kind8', description: 'Badge Award', category: 2 },
{ kind: 16, kindString: 'kind16', description: 'Generic Repost', category: 1 },
{ kind: 10000, kindString: 'kind10000', description: 'Mute List', category: 1 },
{ kind: 10001, kindString: 'kind10001', description: 'Pinned Note(s)', category: 1 },
{ kind: 10002, kindString: 'kind10002', description: 'Tiny Relay List', category: 1 },
{ kind: 1984, kindString: 'kind1984', description: 'Reporting', category: 1 },
{ kind: 30000, kindString: 'kind30000', description: 'Custom Follow List', category: 1 },
{ kind: 30008, kindString: 'kind30008', description: 'Profile Badge', category: 2 },
{ kind: 30009, kindString: 'kind30009', description: 'Badge Definition', category: 2 },
{ kind: 30023, kindString: 'kind30023', description: 'Formatted Articles', category: 1 },
{ kind: 30079, kindString: 'kind30079', description: 'Event Paths', category: 1 },
//{ kind: 9734, kindString: 'kind9734', description: 'Lightning Zap Request', category: 2 },
{ kind: 9735, kindString: 'kind9735', description: 'Zap Receipt', category: 2 },
{ kind: 10011, kindString: 'kind10011', description: 'Issue Notes', category: 3 },
{ kind: 10022, kindString: 'kind10022', description: 'PR Notes', category: 3 },
{ kind: 9803, kindString: 'kind9803', description: 'Commit Notes', category: 3 },
];
export const appBuckets = [
{ id: 'nostr', label: 'Nostr' },
{
id: 'gitnestr',
label: 'GitNestr',
},
{
id: 'NostrBox',
label: 'NostrBox',
},
];
export const categories = [
{ id: 1, name: 'Basic Nostr Features' },
{ id: 2, name: 'Extra Nostr Features' },
{ id: 3, name: 'GitNestr Features' },
];
28 changes: 25 additions & 3 deletions src/hooks/useRelaySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ interface RelaySettings {
videos: string[];
gitNestr: string[];
audio: string[];
appBuckets: string[];
dynamicAppBuckets: string[];
isKindsActive: boolean;
isPhotosActive: boolean;
isVideosActive: boolean;
Expand All @@ -22,7 +24,7 @@ interface RelaySettings {
}

const getInitialSettings = (): RelaySettings => {
const savedSettings = localStorage.getItem('settingsCache');
const savedSettings = localStorage.getItem('relaySettings');
return savedSettings
? JSON.parse(savedSettings)
: {
Expand All @@ -38,6 +40,8 @@ const getInitialSettings = (): RelaySettings => {
videos: [],
gitNestr: [],
audio: [],
appBuckets: [],
dynamicAppBuckets: [],
isKindsActive: true,
isPhotosActive: true,
isVideosActive: true,
Expand All @@ -64,8 +68,27 @@ const useRelaySettings = () => {
if (!response.ok) {
throw new Error(`Network response was not ok (status: ${response.status})`);
}

const data = await response.json();
console.log('Fetched settings:', data.relay_settings);

const storedAppBuckets = JSON.parse(localStorage.getItem('appBuckets') || '[]');
const storedDynamicKinds = JSON.parse(localStorage.getItem('dynamicKinds') || '[]');
console.log(data)
const newAppBuckets =
data.relay_settings.dynamicAppBuckets == undefined
? []
: data.relay_settings.dynamicAppBuckets.filter((bucket: string) => !storedAppBuckets.includes(bucket));
const newDynamicKinds =
data.relay_settings.dynamicKinds == undefined
? []
: data.relay_settings.dynamicKinds.filter((kind: string) => !storedDynamicKinds.includes(kind));

if (newAppBuckets.length > 0) {
localStorage.setItem('appBuckets', JSON.stringify([...storedAppBuckets, ...newAppBuckets]));
}
if (newDynamicKinds.length > 0) {
localStorage.setItem('dynamicKinds', JSON.stringify([...storedDynamicKinds, ...newDynamicKinds]));
}
setRelaySettings({
...data.relay_settings,
protocol: Array.isArray(data.relay_settings.protocol)
Expand All @@ -75,7 +98,6 @@ const useRelaySettings = () => {
? data.relay_settings.chunked
: [data.relay_settings.chunked],
});
localStorage.setItem('settingsCache', JSON.stringify(data.relay_settings));
localStorage.setItem('relaySettings', JSON.stringify(data.relay_settings));
} catch (error) {
console.error('Error fetching settings:', error);
Expand Down
4 changes: 2 additions & 2 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"copied": "Copied to clipboard",
"copy": "Copy",
"country": "Country",
"customizeRelaySettings": "Storage Settings",
"customizeRelaySettings": "Relay Settings",
"nft-dashboard": "Relay Dashboard",
"medical-dashboard": "Medical Dashboard",
"dataDisplay": "Data display",
Expand Down Expand Up @@ -299,7 +299,7 @@
"radio": "Radio",
"rate": "Rate",
"reactSimpleMaps": "React Simple Maps",
"relay-settings": "Storage Settings",
"relay-settings": "Relay Settings",
"relay-stats": "Relay Stats",
"requiredField": "This field is required!",
"resetPassword": "Reset password",
Expand Down
Loading