mirror of https://github.com/zulip/zulip.git
ts: Migrate ‘user_sort.js’ to TypeScript.
Also fixes a bug in the people.ts User; `delivery_email` is never undefined.
This commit is contained in:
parent
c756259094
commit
646128db9e
|
@ -269,7 +269,7 @@ EXEMPT_FILES = make_set(
|
|||
"web/src/user_groups.ts",
|
||||
"web/src/user_profile.js",
|
||||
"web/src/user_settings.ts",
|
||||
"web/src/user_sort.js",
|
||||
"web/src/user_sort.ts",
|
||||
"web/src/user_status.ts",
|
||||
"web/src/user_status_ui.js",
|
||||
"web/src/user_topic_popover.js",
|
||||
|
|
|
@ -23,7 +23,7 @@ export type ProfileData = {
|
|||
|
||||
export type User = {
|
||||
user_id: number;
|
||||
delivery_email?: string | null;
|
||||
delivery_email: string | null;
|
||||
email: string;
|
||||
full_name: string;
|
||||
date_joined: string;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export function compare_a_b(a, b) {
|
||||
import type {User} from "./people";
|
||||
|
||||
export function compare_a_b(a: number | string, b: number | string): number {
|
||||
if (a > b) {
|
||||
return 1;
|
||||
} else if (a === b) {
|
||||
|
@ -7,7 +9,7 @@ export function compare_a_b(a, b) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
export function sort_email(a, b) {
|
||||
export function sort_email(a: User, b: User): number {
|
||||
const email_a = a.delivery_email;
|
||||
const email_b = b.delivery_email;
|
||||
|
||||
|
@ -27,10 +29,10 @@ export function sort_email(a, b) {
|
|||
return compare_a_b(email_a.toLowerCase(), email_b.toLowerCase());
|
||||
}
|
||||
|
||||
export function sort_role(a, b) {
|
||||
export function sort_role(a: User, b: User): number {
|
||||
return compare_a_b(a.role, b.role);
|
||||
}
|
||||
|
||||
export function sort_user_id(a, b) {
|
||||
export function sort_user_id(a: User, b: User): number {
|
||||
return compare_a_b(a.user_id, b.user_id);
|
||||
}
|
Loading…
Reference in New Issue