You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Mobile: Improve sync by reducing how often note list is sorted
This commit is contained in:
@@ -102,6 +102,7 @@ export interface State {
|
||||
needApiAuth: boolean;
|
||||
profileConfig: ProfileConfig;
|
||||
noteListRendererIds: string[];
|
||||
noteListLastSortTime: number;
|
||||
|
||||
// Extra reducer keys go here:
|
||||
pluginService: PluginServiceState;
|
||||
@@ -176,6 +177,7 @@ export const defaultState: State = {
|
||||
needApiAuth: false,
|
||||
profileConfig: null,
|
||||
noteListRendererIds: getListRendererIds(),
|
||||
noteListLastSortTime: 0,
|
||||
|
||||
pluginService: pluginServiceDefaultState,
|
||||
shareService: shareServiceDefaultState,
|
||||
@@ -850,6 +852,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
|
||||
case 'NOTE_UPDATE_ALL':
|
||||
draft.notes = action.notes;
|
||||
draft.notesSource = action.notesSource;
|
||||
draft.noteListLastSortTime = Date.now(); // Notes are already sorted when they are set this way.
|
||||
updateSelectedNotesFromExistingNotes(draft);
|
||||
break;
|
||||
|
||||
@@ -869,7 +872,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
|
||||
|
||||
let movedNotePreviousIndex = 0;
|
||||
let noteFolderHasChanged = false;
|
||||
let newNotes = draft.notes.slice();
|
||||
const newNotes = draft.notes.slice();
|
||||
let found = false;
|
||||
for (let i = 0; i < newNotes.length; i++) {
|
||||
const n = newNotes[i];
|
||||
@@ -909,8 +912,6 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
// newNotes = Note.sortNotes(newNotes, draft.notesOrder, draft.settings.uncompletedTodosOnTop);
|
||||
newNotes = Note.sortNotes(newNotes, stateUtils.notesOrder(draft.settings), draft.settings.uncompletedTodosOnTop);
|
||||
draft.notes = newNotes;
|
||||
|
||||
if (noteFolderHasChanged) {
|
||||
@@ -953,6 +954,14 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NOTE_SORT':
|
||||
|
||||
{
|
||||
draft.notes = Note.sortNotes(draft.notes, stateUtils.notesOrder(draft.settings), draft.settings.uncompletedTodosOnTop);
|
||||
draft.noteListLastSortTime = Date.now();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NOTE_IS_INSERTING_NOTES':
|
||||
|
||||
if (draft.isInsertingNotes !== action.value) {
|
||||
|
||||
Reference in New Issue
Block a user