@@ -104,8 +104,8 @@ function NotesPage() {
104104 */
105105 function removeMedia ( id ) {
106106 const index = getMediaIndexById ( id )
107+ if ( index === null ) return 0
107108 const toDelete = mediaArr . splice ( index , 1 ) [ 0 ]
108-
109109 setMediaArr ( [ ...mediaArr ] )
110110 toDelete && loadMediaToServer ( { id : toDelete . id } , "delete" )
111111 }
@@ -231,6 +231,7 @@ function NotesPage() {
231231 */
232232 function changeNoteColor ( id , color ) {
233233 const index = getNoteIndexById ( id )
234+ if ( index === null ) return 0
234235 notesArr [ index ] . color = color
235236 setNotesArr ( [ ...notesArr ] )
236237 loadNotesToServer ( notesArr [ index ] , "set" )
@@ -244,12 +245,11 @@ function NotesPage() {
244245 */
245246 function editNoteContent ( id , name , text ) {
246247 const index = getNoteIndexById ( id )
247- if ( index !== null ) {
248- let note = new Note ( notesArr [ index ] )
249- note . name = name
250- note . text = text
251- notesArr [ index ] = note
252- }
248+ if ( index === null ) return 0
249+ let note = new Note ( notesArr [ index ] )
250+ note . name = name
251+ note . text = text
252+ notesArr [ index ] = note
253253 setNotesArr ( [ ...notesArr ] )
254254 loadNotesToServer ( notesArr [ index ] , "set" )
255255 }
@@ -261,6 +261,7 @@ function NotesPage() {
261261 */
262262 function editNoteMedia ( id , media = [ ] ) {
263263 const index = getNoteIndexById ( id )
264+ if ( index === null ) return 0
264265 notesArr [ index ] . media = media
265266 setNotesArr ( [ ...notesArr ] )
266267 loadNotesToServer ( notesArr [ index ] , "set" )
@@ -273,14 +274,13 @@ function NotesPage() {
273274 */
274275 function editNoteOrder ( id , orderOperationFlag ) {
275276 const index = getNoteIndexById ( id )
276- if ( index !== null ) {
277- notesArr [ index ] . order += orderOperationFlag ? 1 : - 1
278- let fixedArr = fixOrders ( notesArr )
279- setNotesArr ( fixedArr )
280- fixedArr . forEach ( ( note ) => {
281- loadNotesToServer ( note , "set" )
282- } )
283- }
277+ if ( index === null ) return 0
278+ notesArr [ index ] . order += orderOperationFlag ? 1 : - 1
279+ let fixedArr = fixOrders ( notesArr )
280+ setNotesArr ( fixedArr )
281+ fixedArr . forEach ( ( note ) => {
282+ loadNotesToServer ( note , "set" )
283+ } )
284284 }
285285
286286 ///////////
0 commit comments