null checks on sort function values
This commit is contained in:
parent
a3beb04f7e
commit
e27df6bc09
|
@ -481,6 +481,16 @@ export class CipherService implements CipherServiceAbstraction {
|
|||
let aName = a.name;
|
||||
let bName = b.name;
|
||||
|
||||
if (aName == null && bName != null) {
|
||||
return -1;
|
||||
}
|
||||
if (aName != null && bName == null) {
|
||||
return 1;
|
||||
}
|
||||
if (aName == null && bName == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const result = this.i18nService.collator ? this.i18nService.collator.compare(aName, bName) :
|
||||
aName.localeCompare(bName);
|
||||
|
||||
|
|
|
@ -127,6 +127,16 @@ export class CollectionService implements CollectionServiceAbstraction {
|
|||
|
||||
private getLocaleSortingFunction(): (a: CollectionView, b: CollectionView) => number {
|
||||
return (a, b) => {
|
||||
if (a.name == null && b.name != null) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name != null && b.name == null) {
|
||||
return 1;
|
||||
}
|
||||
if (a.name == null && b.name == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.i18nService.collator ? this.i18nService.collator.compare(a.name, b.name) :
|
||||
a.name.localeCompare(b.name);
|
||||
};
|
||||
|
|
|
@ -166,6 +166,16 @@ export class FolderService implements FolderServiceAbstraction {
|
|||
|
||||
private getLocaleSortingFunction(): (a: FolderView, b: FolderView) => number {
|
||||
return (a, b) => {
|
||||
if (a.name == null && b.name != null) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name != null && b.name == null) {
|
||||
return 1;
|
||||
}
|
||||
if (a.name == null && b.name == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.i18nService.collator ? this.i18nService.collator.compare(a.name, b.name) :
|
||||
a.name.localeCompare(b.name);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue