Skip to content

Commit 720f7fe

Browse files
committed
order fixup
1 parent bfd0349 commit 720f7fe

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

client/src/NoteComponents/NoteList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
)

client/src/Pages/NotesPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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) => {

client/src/Shared/order.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @param {object} b
88
*/
99
export 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
*/
3131
export 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

0 commit comments

Comments
 (0)