1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Desktop: Fixes #10077: Special characters in notebooks and tags are not sorted alphabetically (#10085)

Co-authored-by: Martin Dörfelt <martin.d@andix.de>
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
cagnusmarlsen
2024-03-20 16:47:46 +05:30
committed by GitHub
parent ea29cf4e13
commit e9ebd845b9
7 changed files with 70 additions and 12 deletions

View File

@@ -18,6 +18,7 @@ import { pull, removeElement, unique } from '../ArrayUtils';
import { LoadOptions, SaveOptions } from './utils/types';
import ActionLogger from '../utils/ActionLogger';
import { getDisplayParentId, getTrashFolderId } from '../services/trash';
import { getCollator } from './utils/getCollator';
const urlUtils = require('../urlUtils.js');
const { isImageMimeType } = require('../resourceUtils');
const { MarkupToHtml } = require('@joplin/renderer');
@@ -294,8 +295,7 @@ export default class Note extends BaseItem {
return noteFieldComp(a.id, b.id);
};
const collator = this.getNaturalSortingCollator();
const collator = getCollator();
return notes.sort((a: NoteEntity, b: NoteEntity) => {
if (noteOnTop(a) && !noteOnTop(b)) return -1;
@@ -1121,15 +1121,11 @@ export default class Note extends BaseItem {
public static handleTitleNaturalSorting(items: NoteEntity[], options: any) {
if (options.order.length > 0 && options.order[0].by === 'title') {
const collator = this.getNaturalSortingCollator();
const collator = getCollator();
items.sort((a, b) => ((options.order[0].dir === 'ASC') ? 1 : -1) * collator.compare(a.title, b.title));
}
}
public static getNaturalSortingCollator() {
return new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
}
public static async createConflictNote(sourceNote: NoteEntity, changeSource: number): Promise<NoteEntity> {
const conflictNote = { ...sourceNote };
delete conflictNote.id;