list_render: Convert generic_sorting_functions from object to Map.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-02-12 07:09:01 +00:00 committed by Tim Abbott
parent 4f39199f6d
commit c4e08a99d7
1 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ exports.create = function ($container, list, opts) {
sorting_function: null, sorting_function: null,
prop: null, prop: null,
sorting_functions: new Map(), sorting_functions: new Map(),
generic_sorting_functions: {}, generic_sorting_functions: new Map(),
offset: 0, offset: 0,
listRenders: {}, listRenders: {},
list: list, list: list,
@ -223,7 +223,7 @@ exports.create = function ($container, list, opts) {
} else if (typeof sorting_function === "string") { } else if (typeof sorting_function === "string") {
if (typeof prop === "string") { if (typeof prop === "string") {
/* eslint-disable max-len */ /* eslint-disable max-len */
meta.sorting_function = meta.generic_sorting_functions[sorting_function](prop); meta.sorting_function = meta.generic_sorting_functions.get(sorting_function)(prop);
} else { } else {
meta.sorting_function = meta.sorting_functions.get(sorting_function); meta.sorting_function = meta.sorting_functions.get(sorting_function);
} }
@ -253,7 +253,7 @@ exports.create = function ($container, list, opts) {
// generic sorting functions are ones that will use a specified prop // generic sorting functions are ones that will use a specified prop
// and perform a sort on it with the given sorting function. // and perform a sort on it with the given sorting function.
add_generic_sort_function: function (name, sorting_function) { add_generic_sort_function: function (name, sorting_function) {
meta.generic_sorting_functions[name] = sorting_function; meta.generic_sorting_functions.set(name, sorting_function);
}, },
remove_sort: function () { remove_sort: function () {