Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dd98675

Browse files
nullcheck
1 parent 2c842ba commit dd98675

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

‎client/src/NoteComponents/NoteItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function NoteItem({ note }) {
3838
return (
3939
<div className="p-1" >
4040
<div className="card" style={{ backgroundColor: bgColor }} >
41-
4241
{/**Изображение заметки*/}
4342
{Array.isArray(mediaList) ? (mediaList.map((imgId) => {
4443
const media = getMediaById(imgId)

‎client/src/NoteComponents/media/media.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function Media({ setNoteMedia, mediaList = [], style, className, disabled, noteI
9999
<Modal {...modalProps.bind()} >
100100
<div style={{ minHeight: `${sizeData.current ? sizeData.current.parentElement.clientHeight : 100}px` }} className="p-1 d-flex flex-wrap align-content-between align-items-center justify-content-center">
101101

102-
<div className="form-group container d-flex flex-row flex-wrap align-items-start mb-0">
102+
<div className="form-group container d-flex flex-row flex-wrap align-items-start justify-content-around mb-0">
103103
{Array.isArray(mediaList) && mediaList.length ? (mediaList.map((imgId, index) => {
104104
const media = getMediaById(imgId)
105105
const src = typeof media === "object" && media && media.data

‎client/src/Pages/NotesPage.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /