@@ -51,10 +51,6 @@ const RelaySettingsPage: React.FC = () => {
5151 const [ settings , setSettings ] = useState < Settings > ( {
5252 mode : JSON . parse ( localStorage . getItem ( 'relaySettings' ) || '{}' ) . mode || relaymode || 'unlimited' ,
5353 protocol : [ 'WebSocket' ] ,
54- chunked : [ 'unchunked' ] ,
55- chunksize : '2' ,
56- maxFileSize : 100 ,
57- maxFileSizeUnit : 'MB' ,
5854 kinds : [ ] ,
5955 dynamicKinds : [ ] ,
6056 photos : [ ] ,
@@ -68,7 +64,9 @@ const RelaySettingsPage: React.FC = () => {
6864 isVideosActive : true ,
6965 isGitNestrActive : true ,
7066 isAudioActive : true ,
67+ isFileStorageActive : false ,
7168 } ) ;
69+
7270 const groupedNoteOptions = categories . map ( ( category ) => ( {
7371 ...category ,
7472 notes : noteOptions . filter ( ( note ) => note . category === category . id ) ,
@@ -269,18 +267,21 @@ const RelaySettingsPage: React.FC = () => {
269267 } ) ) ;
270268 } ;
271269
272- const handleChunkedChange = ( checkedValues : string [ ] ) => {
273- setSettings ( ( prevSettings ) => ( {
274- ...prevSettings ,
275- chunked : checkedValues ,
276- } ) ) ;
277- updateSettings ( 'chunked' , checkedValues ) ;
278- } ;
270+ // const handleChunkedChange = (checkedValues: string[]) => {
271+ // setSettings((prevSettings) => ({
272+ // ...prevSettings,
273+ // chunked: checkedValues,
274+ // }));
275+ // updateSettings('chunked', checkedValues);
276+ // };
279277
280278 const handleSettingsChange = ( category : Category , checkedValues : string [ ] ) => {
281279 console . log ( "changing settings" , category , checkedValues )
282280 if ( settings . mode === 'unlimited' ) {
283- handleBlacklistChange ( category , checkedValues ) ;
281+ setBlacklist ( ( prevBlacklist ) => ( {
282+ ...prevBlacklist ,
283+ [ category ] : checkedValues ,
284+ } ) ) ;
284285 } else {
285286 setSettings ( ( prevSettings ) => {
286287 const updatedSettings = { ...prevSettings , [ category ] : checkedValues } ;
@@ -298,30 +299,6 @@ const RelaySettingsPage: React.FC = () => {
298299 updateSettings ( category , value ) ;
299300 } ;
300301
301- const handleChunkSizeChange = ( value : string ) => {
302- setSettings ( ( prevSettings ) => ( {
303- ...prevSettings ,
304- chunksize : value ,
305- } ) ) ;
306- updateSettings ( 'chunksize' , value ) ;
307- } ;
308-
309- const handleMaxFileSizeChange = ( value : number ) => {
310- setSettings ( ( prevSettings ) => ( {
311- ...prevSettings ,
312- maxFileSize : value ,
313- } ) ) ;
314- updateSettings ( 'maxFileSize' , value ) ;
315- } ;
316-
317- const handleMaxFileSizeUnitChange = ( value : string ) => {
318- setSettings ( ( prevSettings ) => ( {
319- ...prevSettings ,
320- maxFileSizeUnit : value ,
321- } ) ) ;
322- updateSettings ( 'maxFileSizeUnit' , value ) ;
323- } ;
324-
325302 const handleNewBucket = ( bucket : string ) => {
326303 const currentBuckets = settings . appBuckets . concat ( storedAppBuckets ) ;
327304 if ( currentBuckets . includes ( bucket ) ) {
@@ -364,9 +341,7 @@ const RelaySettingsPage: React.FC = () => {
364341 updateSettings ( 'gitNestr' , settings . isGitNestrActive ? settings . gitNestr : [ ] ) ,
365342 updateSettings ( 'audio' , settings . isAudioActive ? settings . audio : [ ] ) ,
366343 updateSettings ( 'protocol' , settings . protocol ) ,
367- updateSettings ( 'chunked' , settings . chunked ) ,
368- updateSettings ( 'maxFileSize' , settings . maxFileSize ) ,
369- updateSettings ( 'maxFileSizeUnit' , settings . maxFileSizeUnit ) ,
344+ updateSettings ( 'isFileStorageActive' , settings . isFileStorageActive ) ,
370345 // updateSettings('appBuckets', settings.appBuckets),
371346 //updateSettings('dynamicAppBuckets', settings.dynamicAppBuckets),
372347 ] ) ;
@@ -401,12 +376,15 @@ const RelaySettingsPage: React.FC = () => {
401376 fetchSettings ( ) ;
402377 } , [ fetchSettings ] ) ;
403378
379+ useEffect ( ( ) => {
380+ fetchSettings ( ) ;
381+ } , [ fetchSettings ] ) ;
382+
404383 useEffect ( ( ) => {
405384 if ( relaySettings ) {
406385 setSettings ( {
407386 ...relaySettings ,
408387 protocol : Array . isArray ( relaySettings . protocol ) ? relaySettings . protocol : [ relaySettings . protocol ] ,
409- chunked : Array . isArray ( relaySettings . chunked ) ? relaySettings . chunked : [ relaySettings . chunked ] ,
410388 } ) ;
411389 }
412390 } , [ relaySettings ] ) ;
@@ -464,83 +442,21 @@ const RelaySettingsPage: React.FC = () => {
464442 onChange = { ( checkedValues ) => handleProtocolChange ( checkedValues as string [ ] ) }
465443 style = { {
466444 display : 'grid' ,
467- gridTemplateColumns : '10rem auto' , // Adjust the width as needed
445+ gridTemplateColumns : '10rem auto' ,
468446 } }
469447 />
470448 </ div >
471449 < div style = { { borderTop : '1px solid #ccc' , margin : '1rem 0' } } > </ div >
472450 < div style = { { display : 'flex' , flexDirection : 'column' } } >
473- < S . LabelSpan style = { { marginBottom : '1rem' } } > { t ( 'common.chunkedSetting' ) } </ S . LabelSpan > { ' ' }
474- < Checkbox . Group
475- className = "custom-checkbox-group"
476- options = { [
477- { label : `Unchunked \u{1F338}` , value : 'unchunked' , style : { fontSize : '.85rem' } } ,
478- { label : `Chunked \u{1F333}` , value : 'chunked' , style : { fontSize : '.85rem' } } ,
479- ] }
480- value = { settings . chunked }
481- onChange = { ( checkedValues ) => handleChunkedChange ( checkedValues as string [ ] ) }
482- style = { {
483- display : 'grid' ,
484- gridTemplateColumns : '10rem auto' , // Adjust the width as needed
485- } }
486- />
451+ < S . LabelSpan style = { { marginBottom : '1rem' } } > { t ( 'File Storage' ) } </ S . LabelSpan > { ' ' }
452+ < BaseCheckbox
453+ checked = { settings . isFileStorageActive }
454+ onChange = { ( e ) => handleSwitchChange ( 'isFileStorageActive' , e . target . checked ) }
455+ style = { { fontSize : '.85rem' } }
456+ >
457+ Enable/Disable
458+ </ BaseCheckbox >
487459 </ div >
488- { settings . chunked . includes ( 'unchunked' ) && (
489- < >
490- < div style = { { marginTop : '1.5rem' } } >
491- < strong > Max Unchunked File Size:</ strong >
492- < S . Space />
493- </ div >
494- < div style = { { display : 'flex' , alignItems : 'center' , gap : '1rem' , marginTop : '0.5rem' } } >
495- < Input
496- type = "number"
497- value = { settings . maxFileSize }
498- onChange = { ( e ) => handleMaxFileSizeChange ( Number ( e . target . value ) ) }
499- style = { { width : 100 } }
500- />
501- < Select
502- className = "custom-dropdown"
503- value = { settings . maxFileSizeUnit }
504- onChange = { handleMaxFileSizeUnitChange }
505- style = { { width : 100 } }
506- >
507- { maxFileSizeUnitOptions . map ( ( unit ) => (
508- < Option key = { unit } value = { unit } >
509- { unit }
510- </ Option >
511- ) ) }
512- </ Select >
513- </ div >
514- </ >
515- ) }
516- { settings . chunked . includes ( 'chunked' ) && (
517- < >
518- < div style = { { marginTop : '1rem' } } >
519- < strong > Max Chunked File Size:</ strong >
520- < S . Space />
521- </ div >
522- < div style = { { display : 'flex' , alignItems : 'center' , gap : '1rem' , marginTop : '0.5rem' } } >
523- < Input
524- type = "number"
525- value = { settings . maxFileSize }
526- onChange = { ( e ) => handleMaxFileSizeChange ( Number ( e . target . value ) ) }
527- style = { { width : 100 } }
528- />
529- < Select
530- className = "custom-dropdown"
531- value = { settings . maxFileSizeUnit }
532- onChange = { handleMaxFileSizeUnitChange }
533- style = { { width : 100 } }
534- >
535- { maxFileSizeUnitOptions . map ( ( unit ) => (
536- < Option key = { unit } value = { unit } >
537- { unit }
538- </ Option >
539- ) ) }
540- </ Select >
541- </ div >
542- </ >
543- ) }
544460 </ BaseCol >
545461 </ S . Card >
546462 </ StyledPanel >
@@ -949,83 +865,14 @@ const RelaySettingsPage: React.FC = () => {
949865 </ div >
950866 < div style = { { borderTop : '1px solid #ccc' , margin : '1rem 0' } } > </ div >
951867 < div style = { { display : 'flex' , flexDirection : 'column' } } >
952- < S . LabelSpan style = { { marginBottom : '0.5rem' } } > { t ( 'common.chunkedSetting' ) } </ S . LabelSpan >
953- < Checkbox . Group
954- className = "custom-checkbox-group"
955- options = { [
956- {
957- label : `Unchunked \u{1F338}` ,
958- value : 'unchunked' ,
959- style : { fontSize : '.8rem' } ,
960- } ,
961- { label : `Chunked \u{1F333}` , value : 'chunked' , style : { fontSize : '.8rem' } } ,
962- ] }
963- value = { settings . chunked }
964- onChange = { ( checkedValues ) => handleChunkedChange ( checkedValues as string [ ] ) }
965- style = { {
966- display : 'grid' ,
967- gridTemplateColumns : '9rem auto' ,
968- paddingRight : '0' ,
969- justifyContent : 'start' ,
970- fontSize : 'small' ,
971- } }
972- />
973- { settings . chunked . includes ( 'unchunked' ) && (
974- < >
975- < div style = { { marginTop : '1rem' } } >
976- < strong > Max Unchunked File Size:</ strong >
977- < S . Space />
978- </ div >
979- < div style = { { display : 'flex' , alignItems : 'center' , gap : '1rem' , marginTop : '0.5rem' } } >
980- < Input
981- type = "number"
982- value = { settings . maxFileSize }
983- onChange = { ( e ) => handleMaxFileSizeChange ( Number ( e . target . value ) ) }
984- style = { { width : 100 } }
985- />
986- < Select
987- className = "custom-dropdown"
988- value = { settings . maxFileSizeUnit }
989- onChange = { handleMaxFileSizeUnitChange }
990- style = { { width : 100 } }
991- >
992- { maxFileSizeUnitOptions . map ( ( unit ) => (
993- < Option key = { unit } value = { unit } >
994- { unit }
995- </ Option >
996- ) ) }
997- </ Select >
998- </ div >
999- </ >
1000- ) }
1001- { settings . chunked . includes ( 'chunked' ) && (
1002- < >
1003- < div style = { { marginTop : '1rem' } } >
1004- < strong > Max Chunked File Size:</ strong >
1005- < S . Space />
1006- </ div >
1007- < div style = { { display : 'flex' , alignItems : 'center' , gap : '1rem' , marginTop : '0.5rem' } } >
1008- < Input
1009- type = "number"
1010- value = { settings . maxFileSize }
1011- onChange = { ( e ) => handleMaxFileSizeChange ( Number ( e . target . value ) ) }
1012- style = { { width : 100 } }
1013- />
1014- < Select
1015- className = "custom-dropdown"
1016- value = { settings . maxFileSizeUnit }
1017- onChange = { handleMaxFileSizeUnitChange }
1018- style = { { width : 100 } }
1019- >
1020- { maxFileSizeUnitOptions . map ( ( unit ) => (
1021- < Option key = { unit } value = { unit } >
1022- { unit }
1023- </ Option >
1024- ) ) }
1025- </ Select >
1026- </ div >
1027- </ >
1028- ) }
868+ < S . LabelSpan style = { { marginBottom : '0.5rem' } } > { t ( 'File Storage' ) } </ S . LabelSpan >
869+ < BaseCheckbox
870+ checked = { settings . isFileStorageActive }
871+ onChange = { ( e ) => handleSwitchChange ( 'isFileStorageActive' , e . target . checked ) }
872+ style = { { fontSize : '.8rem' } }
873+ >
874+ Enable/Disable
875+ </ BaseCheckbox >
1029876 </ div >
1030877 </ BaseCol >
1031878 </ S . Card >
0 commit comments