File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ function NoteList(props) {
5454 { /**Отзывчивая сетка карточек */ }
5555 < StackGrid className = "container p-0" { ...gridSettings } >
5656 { /**Рендер каждой карточки из массива */ }
57- { props . notes . map ? ( props . notes . sort ( sortByOrder ) . map ( ( note , index ) => {
57+ { Array . isArray ( props . notes ) ? ( props . notes . sort ( sortByOrder ) . reverse ( ) . map ( ( note , index ) => {
5858 return (
5959 < NoteItem note = { note } key = { note . id } index = { index } />
6060 )
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ function NotesPage() {
147147 */
148148 function editNoteOrder ( index , orderOperationFlag ) {
149149 if ( notesArr [ index ] ) {
150- notesArr [ index ] . order += orderOperationFlag ? 2 : - 2
150+ notesArr [ index ] . order += orderOperationFlag ? 1 : - 1
151151 let fixedArr = fixOrders ( notesArr )
152152 setNotesArr ( fixedArr )
153153 fixedArr . forEach ( ( note ) => {
Original file line number Diff line number Diff line change 77 * @param {object } b
88 */
99export function sortByOrder ( a , b ) {
10- if ( a . order > b . order ) return - 1
11- if ( a . order < b . order ) return 1
10+ if ( a . order > b . order ) return 1
11+ if ( a . order < b . order ) return - 1
1212 return 0
1313}
1414
@@ -30,7 +30,7 @@ export function calcOrder(notesArr = []) {
3030 */
3131export function fixOrders ( notesArr = [ ] ) {
3232 let fixedArr = notesArr
33- const sortedArr = Array . isArray ( notesArr ) ? notesArr . sort ( sortByOrder ) . reverse ( ) : [ ]
33+ const sortedArr = Array . isArray ( notesArr ) ? notesArr . sort ( sortByOrder ) : [ ]
3434 sortedArr . forEach ( ( sortedNote , sortedNoteIndex ) => {
3535 fixedArr . forEach ( ( note ) => {
3636 if ( note . id === sortedNote . id ) note . order = sortedNoteIndex
You can’t perform that action at this time.
0 commit comments