Skip to content

Commit

Permalink
Desktop, Mobile: Immediately sort notes after toggling a checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Feb 19, 2024
1 parent bfc3112 commit 5820f63
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/app-desktop/gui/NoteList/NoteList2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ const NoteList = (props: Props) => {
isSelected={props.selectedNoteIds.includes(note.id)}
isWatched={props.watchedNoteFiles.includes(note.id)}
listRenderer={listRenderer}
dispatch={props.dispatch}
/>,
);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/app-desktop/gui/NoteListItem/NoteListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { OnInputChange } from './utils/types';
import Note from '@joplin/lib/models/Note';
import { NoteEntity } from '@joplin/lib/services/database/types';
import useRenderedNote from './utils/useRenderedNote';
import { Dispatch } from 'redux';

interface NoteItemProps {
dragIndex: number;
Expand All @@ -28,6 +29,7 @@ interface NoteItemProps {
isSelected: boolean;
isWatched: boolean;
listRenderer: ListRenderer;
dispatch: Dispatch;
}

const NoteListItem = (props: NoteItemProps, ref: LegacyRef<HTMLDivElement>) => {
Expand All @@ -52,10 +54,12 @@ const NoteListItem = (props: NoteItemProps, ref: LegacyRef<HTMLDivElement>) => {
id: changeEvent.noteId,
todo_completed: changeEvent.value ? Date.now() : 0,
}, { userSideValidation: true });

props.dispatch({ type: 'NOTE_SORT' });
} else {
if (props.onChange) await props.onChange(changeEvent);
}
}, [props.onChange, noteId]);
}, [props.onChange, noteId, props.dispatch]);

const rootElement = useRootElement(elementId);

Expand Down
2 changes: 2 additions & 0 deletions packages/app-mobile/components/note-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class NoteItemComponent extends Component {
todo_completed: checked ? time.unixMs() : 0,
};
await Note.save(newNote);

this.props.dispatch({ type: 'NOTE_SORT' });
}

onPress() {
Expand Down

0 comments on commit 5820f63

Please sign in to comment.