mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
This commit is contained in:
parent
c1ae449ce2
commit
f781183250
@ -77,6 +77,9 @@ const NoteList = (props: Props) => {
|
|||||||
props.showCompletedTodos,
|
props.showCompletedTodos,
|
||||||
props.notes,
|
props.notes,
|
||||||
props.selectedFolderInTrash,
|
props.selectedFolderInTrash,
|
||||||
|
makeItemIndexVisible,
|
||||||
|
focusNote,
|
||||||
|
props.dispatch,
|
||||||
);
|
);
|
||||||
|
|
||||||
const noteItemStyle = useMemo(() => {
|
const noteItemStyle = useMemo(() => {
|
||||||
|
@ -3,8 +3,10 @@ import Note from '@joplin/lib/models/Note';
|
|||||||
import { NoteEntity } from '@joplin/lib/services/database/types';
|
import { NoteEntity } from '@joplin/lib/services/database/types';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import canManuallySortNotes from './canManuallySortNotes';
|
import canManuallySortNotes from './canManuallySortNotes';
|
||||||
|
import { FocusNote } from './useFocusNote';
|
||||||
|
import { Dispatch } from 'redux';
|
||||||
|
|
||||||
const useMoveNote = (notesParentType: string, noteSortOrder: string, selectedNoteIds: string[], selectedFolderId: string, uncompletedTodosOnTop: boolean, showCompletedTodos: boolean, notes: NoteEntity[], selectedFolderInTrash: boolean) => {
|
const useMoveNote = (notesParentType: string, noteSortOrder: string, selectedNoteIds: string[], selectedFolderId: string, uncompletedTodosOnTop: boolean, showCompletedTodos: boolean, notes: NoteEntity[], selectedFolderInTrash: boolean, makeItemIndexVisible: (itemIndex: number)=> void, focusNote: FocusNote, dispatch: Dispatch) => {
|
||||||
const moveNote = useCallback((direction: number, inc: number) => {
|
const moveNote = useCallback((direction: number, inc: number) => {
|
||||||
if (!canManuallySortNotes(notesParentType, noteSortOrder, selectedFolderInTrash)) return;
|
if (!canManuallySortNotes(notesParentType, noteSortOrder, selectedFolderInTrash)) return;
|
||||||
|
|
||||||
@ -17,7 +19,17 @@ const useMoveNote = (notesParentType: string, noteSortOrder: string, selectedNot
|
|||||||
targetNoteIndex -= inc;
|
targetNoteIndex -= inc;
|
||||||
}
|
}
|
||||||
void Note.insertNotesAt(selectedFolderId, selectedNoteIds, targetNoteIndex, uncompletedTodosOnTop, showCompletedTodos);
|
void Note.insertNotesAt(selectedFolderId, selectedNoteIds, targetNoteIndex, uncompletedTodosOnTop, showCompletedTodos);
|
||||||
}, [selectedFolderId, noteSortOrder, notes, notesParentType, selectedNoteIds, uncompletedTodosOnTop, showCompletedTodos, selectedFolderInTrash]);
|
|
||||||
|
// The note will be moved to the target index, so we need to update the scroll amount to make it visible
|
||||||
|
dispatch({
|
||||||
|
type: 'NOTE_SELECT',
|
||||||
|
id: noteId,
|
||||||
|
});
|
||||||
|
|
||||||
|
makeItemIndexVisible(targetNoteIndex);
|
||||||
|
|
||||||
|
focusNote(noteId);
|
||||||
|
}, [selectedFolderId, noteSortOrder, notes, notesParentType, selectedNoteIds, uncompletedTodosOnTop, showCompletedTodos, selectedFolderInTrash, makeItemIndexVisible, focusNote, dispatch]);
|
||||||
|
|
||||||
return moveNote;
|
return moveNote;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user