Skip to content

Commit 3753918

Browse files
Merge pull request #22 from HORNET-Storage/feat/app-buckets
feat-ui: App Buckets
2 parents 195712c + 10fe372 commit 3753918

8 files changed

Lines changed: 490 additions & 175 deletions

File tree

src/components/layouts/main/sider/sidebarNavigation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export const useSidebarNavigation = (): SidebarNavigationItem[] => {
2727
},
2828
{
2929
title: 'common.relay-settings',
30-
key: 'storage-settings',
31-
url: '/storage-settings',
30+
key: 'relay-settings',
31+
url: '/relay-settings',
3232
icon: <StorageSettingsIcon />,
3333
},
3434
{

src/components/router/AppRouter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const Logout = React.lazy(() => import('./Logout'));
6969

7070
export const NFT_DASHBOARD_PATH = '/';
7171
export const MEDICAL_DASHBOARD_PATH = '/medical-dashboard';
72-
export const RELAY_SETTINGS_PATH = '/storage-settings';
72+
export const RELAY_SETTINGS_PATH = '/relay-settings';
7373
export const TABLES_PAGE_PATH = '/nostr-stats';
7474

7575
const MedicalDashboard = withLoading(MedicalDashboardPage);

src/constants/relaySettings.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
export type Settings = {
2+
mode: string;
3+
protocol: string[];
4+
chunked: string[];
5+
chunksize: string;
6+
maxFileSize: number;
7+
maxFileSizeUnit: string;
8+
kinds: string[];
9+
dynamicKinds: string[];
10+
photos: string[];
11+
videos: string[];
12+
gitNestr: string[];
13+
audio: string[];
14+
appBuckets: string[];
15+
dynamicAppBuckets: string[];
16+
isKindsActive: boolean;
17+
isPhotosActive: boolean;
18+
isVideosActive: boolean;
19+
isGitNestrActive: boolean;
20+
isAudioActive: boolean;
21+
};
22+
23+
export type Category = 'kinds' | 'photos' | 'videos' | 'gitNestr' | 'audio' | 'dynamicKinds' | 'appBuckets' | 'dynamicAppBuckets';
24+
export const noteOptions = [
25+
{ kind: 0, kindString: 'kind0', description: 'Metadata', category: 1 },
26+
{ kind: 1, kindString: 'kind1', description: 'Text Note', category: 1 },
27+
{ kind: 2, kindString: 'kind2', description: 'Recommend Relay', category: 1 },
28+
{ kind: 3, kindString: 'kind3', description: 'Follow List', category: 1 },
29+
{ kind: 5, kindString: 'kind5', description: 'Event Deletion', category: 1 },
30+
{ kind: 6, kindString: 'kind6', description: 'Repost', category: 1 },
31+
{ kind: 7, kindString: 'kind7', description: 'Reaction', category: 1 },
32+
{ kind: 8, kindString: 'kind8', description: 'Badge Award', category: 2 },
33+
{ kind: 16, kindString: 'kind16', description: 'Generic Repost', category: 1 },
34+
{ kind: 10000, kindString: 'kind10000', description: 'Mute List', category: 1 },
35+
{ kind: 10001, kindString: 'kind10001', description: 'Pinned Note(s)', category: 1 },
36+
{ kind: 10002, kindString: 'kind10002', description: 'Tiny Relay List', category: 1 },
37+
{ kind: 1984, kindString: 'kind1984', description: 'Reporting', category: 1 },
38+
{ kind: 30000, kindString: 'kind30000', description: 'Custom Follow List', category: 1 },
39+
{ kind: 30008, kindString: 'kind30008', description: 'Profile Badge', category: 2 },
40+
{ kind: 30009, kindString: 'kind30009', description: 'Badge Definition', category: 2 },
41+
{ kind: 30023, kindString: 'kind30023', description: 'Formatted Articles', category: 1 },
42+
{ kind: 30079, kindString: 'kind30079', description: 'Event Paths', category: 1 },
43+
//{ kind: 9734, kindString: 'kind9734', description: 'Lightning Zap Request', category: 2 },
44+
{ kind: 9735, kindString: 'kind9735', description: 'Zap Receipt', category: 2 },
45+
{ kind: 10011, kindString: 'kind10011', description: 'Issue Notes', category: 3 },
46+
{ kind: 10022, kindString: 'kind10022', description: 'PR Notes', category: 3 },
47+
{ kind: 9803, kindString: 'kind9803', description: 'Commit Notes', category: 3 },
48+
];
49+
export const appBuckets = [
50+
{ id: 'nostr', label: 'Nostr' },
51+
{
52+
id: 'gitnestr',
53+
label: 'GitNestr',
54+
},
55+
{
56+
id: 'NostrBox',
57+
label: 'NostrBox',
58+
},
59+
];
60+
export const categories = [
61+
{ id: 1, name: 'Basic Nostr Features' },
62+
{ id: 2, name: 'Extra Nostr Features' },
63+
{ id: 3, name: 'GitNestr Features' },
64+
];

src/hooks/useRelaySettings.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ interface RelaySettings {
1414
videos: string[];
1515
gitNestr: string[];
1616
audio: string[];
17+
appBuckets: string[];
18+
dynamicAppBuckets: string[];
1719
isKindsActive: boolean;
1820
isPhotosActive: boolean;
1921
isVideosActive: boolean;
@@ -22,7 +24,7 @@ interface RelaySettings {
2224
}
2325

2426
const getInitialSettings = (): RelaySettings => {
25-
const savedSettings = localStorage.getItem('settingsCache');
27+
const savedSettings = localStorage.getItem('relaySettings');
2628
return savedSettings
2729
? JSON.parse(savedSettings)
2830
: {
@@ -38,6 +40,8 @@ const getInitialSettings = (): RelaySettings => {
3840
videos: [],
3941
gitNestr: [],
4042
audio: [],
43+
appBuckets: [],
44+
dynamicAppBuckets: [],
4145
isKindsActive: true,
4246
isPhotosActive: true,
4347
isVideosActive: true,
@@ -64,8 +68,27 @@ const useRelaySettings = () => {
6468
if (!response.ok) {
6569
throw new Error(`Network response was not ok (status: ${response.status})`);
6670
}
71+
6772
const data = await response.json();
68-
console.log('Fetched settings:', data.relay_settings);
73+
74+
const storedAppBuckets = JSON.parse(localStorage.getItem('appBuckets') || '[]');
75+
const storedDynamicKinds = JSON.parse(localStorage.getItem('dynamicKinds') || '[]');
76+
console.log(data)
77+
const newAppBuckets =
78+
data.relay_settings.dynamicAppBuckets == undefined
79+
? []
80+
: data.relay_settings.dynamicAppBuckets.filter((bucket: string) => !storedAppBuckets.includes(bucket));
81+
const newDynamicKinds =
82+
data.relay_settings.dynamicKinds == undefined
83+
? []
84+
: data.relay_settings.dynamicKinds.filter((kind: string) => !storedDynamicKinds.includes(kind));
85+
86+
if (newAppBuckets.length > 0) {
87+
localStorage.setItem('appBuckets', JSON.stringify([...storedAppBuckets, ...newAppBuckets]));
88+
}
89+
if (newDynamicKinds.length > 0) {
90+
localStorage.setItem('dynamicKinds', JSON.stringify([...storedDynamicKinds, ...newDynamicKinds]));
91+
}
6992
setRelaySettings({
7093
...data.relay_settings,
7194
protocol: Array.isArray(data.relay_settings.protocol)
@@ -75,7 +98,6 @@ const useRelaySettings = () => {
7598
? data.relay_settings.chunked
7699
: [data.relay_settings.chunked],
77100
});
78-
localStorage.setItem('settingsCache', JSON.stringify(data.relay_settings));
79101
localStorage.setItem('relaySettings', JSON.stringify(data.relay_settings));
80102
} catch (error) {
81103
console.error('Error fetching settings:', error);

src/locales/en/translation.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
"copied": "Copied to clipboard",
225225
"copy": "Copy",
226226
"country": "Country",
227-
"customizeRelaySettings": "Storage Settings",
227+
"customizeRelaySettings": "Relay Settings",
228228
"nft-dashboard": "Relay Dashboard",
229229
"medical-dashboard": "Medical Dashboard",
230230
"dataDisplay": "Data display",
@@ -299,7 +299,7 @@
299299
"radio": "Radio",
300300
"rate": "Rate",
301301
"reactSimpleMaps": "React Simple Maps",
302-
"relay-settings": "Storage Settings",
302+
"relay-settings": "Relay Settings",
303303
"relay-stats": "Relay Stats",
304304
"requiredField": "This field is required!",
305305
"resetPassword": "Reset password",

0 commit comments

Comments
 (0)