1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-01 21:24:45 +02:00

Server: Sort users by name, then email

This commit is contained in:
Laurent Cozic 2021-06-17 17:34:17 +01:00
parent ac03c08f33
commit 65c3d01cc6

View File

@ -83,6 +83,13 @@ router.get('users', async (_path: SubPath, ctx: AppContext) => {
const users = await userModel.all();
users.sort((u1: User, u2: User) => {
if (u1.full_name && u2.full_name) return u1.full_name.toLowerCase() < u2.full_name.toLowerCase() ? -1 : +1;
if (u1.full_name && !u2.full_name) return +1;
if (!u1.full_name && u2.full_name) return -1;
return u1.email.toLowerCase() < u2.email.toLowerCase() ? -1 : +1;
});
const view: View = defaultView('users');
view.content.users = users.map(user => {
return {