@@ -61,32 +61,28 @@ export function CurateBox(props: CurateBoxProps) {
61
61
62
62
const splitStatus = React . useMemo ( ( ) => props . curation . game . status ? props . curation . game . status . split ( ';' ) . map ( s => s . trim ( ) ) . sort ( ) : [ ] , [ props . curation . game . status ] ) ;
63
63
const splitPlayMode = React . useMemo ( ( ) => props . curation . game . playMode ? props . curation . game . playMode . split ( ';' ) . map ( s => s . trim ( ) ) . sort ( ) : [ ] , [ props . curation . game . playMode ] ) ;
64
-
65
- const sortedTags = React . useMemo ( ( ) => {
66
- const tags = props . curation . game . tags ;
67
- if ( tags ) {
68
- return [ ...tags ] . sort ( ( a , b ) => {
69
- // Sort by category, then name secondarily
70
- if ( a . category !== b . category ) {
71
- const categoryA : TagCategory | undefined = props . tagCategories . find ( c => c . name === a . category ) ;
72
- const categoryB : TagCategory | undefined = props . tagCategories . find ( c => c . name === b . category ) ;
73
- if ( ! categoryA && ! categoryB ) {
74
- return a . name . toLowerCase ( ) . localeCompare ( b . name ) ;
75
- } else if ( ! categoryA ) {
76
- return - 1 ;
77
- } else if ( ! categoryB ) {
78
- return 1 ;
79
- } else {
80
- return categoryA . name . toLowerCase ( ) . localeCompare ( categoryB . name . toLowerCase ( ) ) ;
81
- }
82
- } else {
64
+ const tags = props . curation . game . tags ;
65
+ let sortedTags : Tag [ ] = [ ] ;
66
+ if ( tags ) {
67
+ sortedTags = [ ...tags ] . sort ( ( a , b ) => {
68
+ // Sort by category, then name secondarily
69
+ if ( a . category !== b . category ) {
70
+ const categoryA : TagCategory | undefined = props . tagCategories . find ( c => c . name === a . category ) ;
71
+ const categoryB : TagCategory | undefined = props . tagCategories . find ( c => c . name === b . category ) ;
72
+ if ( ! categoryA && ! categoryB ) {
83
73
return a . name . toLowerCase ( ) . localeCompare ( b . name ) ;
74
+ } else if ( ! categoryA ) {
75
+ return - 1 ;
76
+ } else if ( ! categoryB ) {
77
+ return 1 ;
78
+ } else {
79
+ return categoryA . name . toLowerCase ( ) . localeCompare ( categoryB . name . toLowerCase ( ) ) ;
84
80
}
85
- } ) ;
86
- } else {
87
- return [ ] ;
88
- }
89
- } , [ props . curation . game . tags ] ) ;
81
+ } else {
82
+ return a . name . toLowerCase ( ) . localeCompare ( b . name ) ;
83
+ }
84
+ } ) ;
85
+ }
90
86
91
87
const onSetThumbnail = useAddImageCallback ( CurationImageEnum . THUMBNAIL , props . curation ) ;
92
88
const onSetScreenshot = useAddImageCallback ( CurationImageEnum . SCREENSHOT , props . curation ) ;
@@ -95,28 +91,24 @@ export function CurateBox(props: CurateBoxProps) {
95
91
const onDropThumbnail = useDropImageCallback ( 'logo.png' , props . curation , strings . dialog ) ;
96
92
const onDropScreenshot = useDropImageCallback ( 'ss.png' , props . curation , strings . dialog ) ;
97
93
98
- const thumbnailPath = React . useMemo ( ( ) => {
99
- return props . curation . thumbnail . exists ? `${ getCurationURL ( props . curation . folder ) } /logo.png?v` + props . curation . thumbnail . version : undefined ;
100
- } , [ props . curation . thumbnail ] ) ;
101
- const screenshotPath = React . useMemo ( ( ) => {
102
- return props . curation . screenshot . exists ? `${ getCurationURL ( props . curation . folder ) } /ss.png?v` + props . curation . screenshot . version : undefined ;
103
- } , [ props . curation . screenshot ] ) ;
94
+ const thumbnailPath = props . curation . thumbnail . exists ? `${ getCurationURL ( props . curation . folder ) } /logo.png?v` + props . curation . thumbnail . version : undefined ;
95
+ const screenshotPath = props . curation . screenshot . exists ? `${ getCurationURL ( props . curation . folder ) } /ss.png?v` + props . curation . screenshot . version : undefined ;
104
96
105
97
const onNewAddApp = useCreateAddAppCallback ( 'normal' , props . curation . folder , dispatch ) ;
106
98
const onAddExtras = useCreateAddAppCallback ( 'extras' , props . curation . folder , dispatch ) ;
107
99
const onAddMessage = useCreateAddAppCallback ( 'message' , props . curation . folder , dispatch ) ;
108
100
109
- const onAddStatus = React . useCallback ( ( value : string ) => {
101
+ const onAddStatus = ( value : string ) => {
110
102
const newSplits = [ ...splitStatus ] ;
111
103
newSplits . push ( value ) ;
112
104
dispatch ( editCurationMeta ( {
113
105
folder,
114
106
property : 'status' ,
115
107
value : Array . from ( new Set ( newSplits . sort ( ) ) ) . join ( '; ' )
116
108
} ) ) ;
117
- } , [ props . curation . folder , splitStatus , dispatch ] ) ;
109
+ } ;
118
110
119
- const onRemoveStatus = React . useCallback ( ( index : number ) => {
111
+ const onRemoveStatus = ( index : number ) => {
120
112
const newSplits = [ ...splitStatus ] ;
121
113
newSplits . splice ( index , 1 ) ;
122
114
const newStatus = newSplits . join ( '; ' ) ;
@@ -125,19 +117,19 @@ export function CurateBox(props: CurateBoxProps) {
125
117
property : 'status' ,
126
118
value : newStatus
127
119
} ) ) ;
128
- } , [ props . curation . folder , props . curation . game . status , splitStatus , dispatch ] ) ;
120
+ } ;
129
121
130
- const onAddPlayMode = React . useCallback ( ( value : string ) => {
122
+ const onAddPlayMode = ( value : string ) => {
131
123
const newSplits = [ ...splitPlayMode ] ;
132
124
newSplits . push ( value ) ;
133
125
dispatch ( editCurationMeta ( {
134
126
folder,
135
127
property : 'playMode' ,
136
128
value : Array . from ( new Set ( newSplits . sort ( ) ) ) . join ( '; ' )
137
129
} ) ) ;
138
- } , [ props . curation . folder , props . curation . game . playMode , splitPlayMode , dispatch ] ) ;
130
+ } ;
139
131
140
- const onRemovePlayMode = React . useCallback ( ( index : number ) => {
132
+ const onRemovePlayMode = ( index : number ) => {
141
133
const newSplits = [ ...splitPlayMode ] ;
142
134
newSplits . splice ( index , 1 ) ;
143
135
const newPlayMode = newSplits . join ( '; ' ) ;
@@ -146,17 +138,17 @@ export function CurateBox(props: CurateBoxProps) {
146
138
property : 'playMode' ,
147
139
value : newPlayMode
148
140
} ) ) ;
149
- } , [ props . curation . folder , props . curation . game . playMode , splitPlayMode , dispatch ] ) ;
141
+ } ;
150
142
151
- const onTagChange = React . useCallback ( ( event : React . ChangeEvent < InputElement > ) : void => {
143
+ const onTagChange = ( event : React . ChangeEvent < InputElement > ) : void => {
152
144
props . onTagTextChange ( event . currentTarget . value ) ;
153
- } , [ props . onTagTextChange ] ) ;
145
+ } ;
154
146
155
- const onPlatformChange = React . useCallback ( ( event : React . ChangeEvent < InputElement > ) : void => {
147
+ const onPlatformChange = ( event : React . ChangeEvent < InputElement > ) : void => {
156
148
props . onPlatformTextChange ( event . currentTarget . value ) ;
157
- } , [ props . onPlatformTextChange ] ) ;
149
+ } ;
158
150
159
- const onTagKeyDown = React . useCallback ( ( event : React . KeyboardEvent < InputElement > ) : void => {
151
+ const onTagKeyDown = ( event : React . KeyboardEvent < InputElement > ) : void => {
160
152
if ( event . defaultPrevented ) { return ; }
161
153
162
154
if ( event . key === 'Enter' ) {
@@ -167,9 +159,9 @@ export function CurateBox(props: CurateBoxProps) {
167
159
}
168
160
}
169
161
}
170
- } , [ ] ) ;
162
+ } ;
171
163
172
- const onPlatformKeyDown = React . useCallback ( ( event : React . KeyboardEvent < InputElement > ) : void => {
164
+ const onPlatformKeyDown = ( event : React . KeyboardEvent < InputElement > ) : void => {
173
165
if ( event . defaultPrevented ) { return ; }
174
166
175
167
if ( event . key === 'Enter' ) {
@@ -180,9 +172,9 @@ export function CurateBox(props: CurateBoxProps) {
180
172
}
181
173
}
182
174
}
183
- } , [ ] ) ;
175
+ } ;
184
176
185
- const onAddTag = React . useCallback ( ( tag : Tag ) => {
177
+ const onAddTag = ( tag : Tag ) => {
186
178
const tags = props . curation . game . tags || [ ] ;
187
179
if ( ! tags . find ( t => t . id === tag . id ) ) {
188
180
dispatch ( addTag ( {
@@ -191,9 +183,9 @@ export function CurateBox(props: CurateBoxProps) {
191
183
} ) ) ;
192
184
}
193
185
props . onTagTextChange ( '' ) ;
194
- } , [ props . curation . folder , props . curation . game . tags ] ) ;
186
+ } ;
195
187
196
- const onAddPlatform = React . useCallback ( ( platform : Platform ) => {
188
+ const onAddPlatform = ( platform : Platform ) => {
197
189
const platforms = props . curation . game . platforms || [ ] ;
198
190
if ( ! platforms . find ( p => p . id === platform . id ) ) {
199
191
dispatch ( addPlatform ( {
@@ -203,29 +195,29 @@ export function CurateBox(props: CurateBoxProps) {
203
195
} ) ) ;
204
196
}
205
197
props . onPlatformTextChange ( '' ) ;
206
- } , [ props . curation . folder , props . curation . game . platforms ] ) ;
198
+ } ;
207
199
208
- const onRemoveTag = React . useCallback ( ( tagId : number ) => {
200
+ const onRemoveTag = ( tagId : number ) => {
209
201
dispatch ( removeTag ( {
210
202
folder,
211
203
tagId
212
204
} ) ) ;
213
- } , [ props . curation . folder , props . curation . game . tags ] ) ;
205
+ } ;
214
206
215
- const onRemovePlatform = React . useCallback ( ( platformId ) => {
207
+ const onRemovePlatform = ( platformId : number ) => {
216
208
dispatch ( removePlatform ( {
217
209
folder,
218
210
platformId,
219
211
platformAppPaths : props . platformAppPaths
220
212
} ) ) ;
221
- } , [ props . curation . folder , props . curation . game . platforms ] ) ;
213
+ } ;
222
214
223
- const onToggleContentNodeView = React . useCallback ( ( tree : string [ ] ) => {
215
+ const onToggleContentNodeView = ( tree : string [ ] ) => {
224
216
dispatch ( toggleContentNodeView ( {
225
217
folder,
226
218
tree
227
219
} ) ) ;
228
- } , [ props . curation . folder , props . curation . contents ] ) ;
220
+ } ;
229
221
230
222
const onContentTreeNodeMenuFactory = ( node : ContentTreeNode , tree : string [ ] ) => ( ) => {
231
223
const contextButtons : MenuItemConstructorOptions [ ] = [ {
@@ -303,7 +295,7 @@ export function CurateBox(props: CurateBoxProps) {
303
295
}
304
296
}
305
297
306
- const renderContentTree = React . useMemo ( ( ) => {
298
+ const renderContentTree = ( ) => {
307
299
// Extract first string from launch command via regex
308
300
let launchPath : string | undefined = undefined ;
309
301
if ( props . curation . game . launchCommand ) {
@@ -342,43 +334,43 @@ export function CurateBox(props: CurateBoxProps) {
342
334
{ render }
343
335
</ div >
344
336
) ;
345
- } , [ props . curation . contents , props . curation . game . launchCommand ] ) ;
337
+ } ;
346
338
347
- const renderTagIcon = React . useCallback ( ( tag : Tag ) => {
339
+ const renderTagIcon = ( tag : Tag ) => {
348
340
const category = props . tagCategories . find ( c => c . name === tag . category ) ;
349
341
return (
350
342
< OpenIcon
351
343
className = 'curate-tag__icon'
352
344
color = { category ? category . color : '#FFFFFF' }
353
345
icon = 'tag' />
354
346
) ;
355
- } , [ ] ) ;
347
+ } ;
356
348
357
- const renderPlatformIconSugg = React . useCallback ( ( platformSugg : TagSuggestion ) => {
349
+ const renderPlatformIconSugg = ( platformSugg : TagSuggestion ) => {
358
350
const iconUrl = getPlatformIconURL ( platformSugg . name , props . logoVersion ) ;
359
351
return (
360
352
< div
361
353
className = 'curate-tag__icon'
362
354
style = { { backgroundImage : `url(${ iconUrl } )` } } />
363
355
) ;
364
- } , [ ] ) ;
356
+ } ;
365
357
366
- const renderPlatformIcon = React . useCallback ( ( platform : Platform ) => {
358
+ const renderPlatformIcon = ( platform : Platform ) => {
367
359
const iconUrl = getPlatformIconURL ( platform . name , props . logoVersion ) ;
368
360
return (
369
361
< div
370
362
className = 'curate-tag__icon'
371
363
style = { { backgroundImage : `url(${ iconUrl } )` } } />
372
364
) ;
373
- } , [ ] ) ;
365
+ } ;
374
366
375
- const onChangePrimaryPlatform = React . useCallback ( ( newPrimary : string ) => {
367
+ const onChangePrimaryPlatform = ( newPrimary : string ) => {
376
368
dispatch ( setPrimaryPlatform ( {
377
369
folder,
378
370
value : newPrimary ,
379
371
platformAppPaths : props . platformAppPaths
380
372
} ) ) ;
381
- } , [ props . curation . folder ] ) ;
373
+ } ;
382
374
383
375
const addAppBoxes = (
384
376
< table className = "curate-box-table" >
@@ -676,7 +668,7 @@ export function CurateBox(props: CurateBoxProps) {
676
668
{ strings . curate . contentFiles + ': ' }
677
669
</ div >
678
670
< pre className = 'curate-box-files__body simple-scroll' >
679
- { renderContentTree }
671
+ { renderContentTree ( ) }
680
672
</ pre >
681
673
</ div >
682
674
< hr />
@@ -707,15 +699,15 @@ export function CurateBox(props: CurateBoxProps) {
707
699
}
708
700
709
701
function useAddImageCallback ( type : CurationImageEnum , curation : LoadedCuration | undefined ) : ( data : ArrayBuffer ) => void {
710
- return React . useCallback ( async ( data : ArrayBuffer ) => {
702
+ return async ( data : ArrayBuffer ) => {
711
703
if ( curation ) {
712
704
const suffix = type === CurationImageEnum . THUMBNAIL ? 'logo.png' : 'ss.png' ;
713
705
const res = await axios . post ( `${ getCurationURL ( curation . folder ) } /${ suffix } ` , data ) ;
714
706
if ( res . status !== 200 ) {
715
707
alert ( `ERROR: Server Returned ${ res . status } - ${ res . statusText } ` ) ;
716
708
}
717
709
}
718
- } , [ curation && curation . folder ] ) ;
710
+ } ;
719
711
}
720
712
721
713
/**
@@ -725,15 +717,15 @@ function useAddImageCallback(type: CurationImageEnum, curation: LoadedCuration |
725
717
* @param curation Curation to delete it from.
726
718
*/
727
719
function useRemoveImageCallback ( type : CurationImageEnum , curation : LoadedCuration | undefined ) : ( ) => Promise < void > {
728
- return React . useCallback ( async ( ) => {
720
+ return async ( ) => {
729
721
if ( curation ) {
730
722
return window . Shared . back . request ( BackIn . CURATE_EDIT_REMOVE_IMAGE , curation . folder , type ) ;
731
723
}
732
- } , [ curation && curation . folder ] ) ;
724
+ } ;
733
725
}
734
726
735
727
function useDropImageCallback ( filename : 'logo.png' | 'ss.png' , curation : CurationState , strings : LangContainer [ 'dialog' ] ) {
736
- return React . useCallback ( async ( event : React . DragEvent ) => {
728
+ return async ( event : React . DragEvent ) => {
737
729
const files = event . dataTransfer . files ;
738
730
739
731
if ( curation && ! curation . locked && files . length > 0 ) {
@@ -743,16 +735,16 @@ function useDropImageCallback(filename: 'logo.png' | 'ss.png', curation: Curatio
743
735
alert ( strings . mustBePngImage ) ;
744
736
}
745
737
}
746
- } , [ curation && curation . folder , strings ] ) ;
738
+ } ;
747
739
}
748
740
749
741
function useCreateAddAppCallback ( type : AddAppType , folder : string , dispatch : Dispatch ) {
750
- return React . useCallback ( ( ) => {
742
+ return ( ) => {
751
743
dispatch ( createAddApp ( {
752
744
folder,
753
745
addAppType : type
754
746
} ) ) ;
755
- } , [ dispatch , folder ] ) ;
747
+ } ;
756
748
}
757
749
758
750
function createAppPathDropdownItems ( platformAppPaths : PlatformAppPathSuggestions , currentPlatform ?: string ) : DropdownItem [ ] {
0 commit comments