mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
emoji sort: Inline helper function.
This commit is contained in:
@@ -155,10 +155,13 @@ exports.render_emoji = function (item) {
|
|||||||
return exports.render_typeahead_item(args);
|
return exports.render_typeahead_item(args);
|
||||||
};
|
};
|
||||||
|
|
||||||
// manipulate prefix_sort to select popular emojis first
|
exports.sort_emojis = function (objs, query) {
|
||||||
// This is kinda a hack and so probably not our long-term solution.
|
const prefix_sort = util.prefix_sort(
|
||||||
function emoji_prefix_sort(query, objs, get_item) {
|
query,
|
||||||
const prefix_sort = util.prefix_sort(query, objs, get_item);
|
objs,
|
||||||
|
(x) => x.emoji_name
|
||||||
|
);
|
||||||
|
|
||||||
const popular_emoji_matches = [];
|
const popular_emoji_matches = [];
|
||||||
const other_emoji_matches = [];
|
const other_emoji_matches = [];
|
||||||
prefix_sort.matches.forEach(function (obj) {
|
prefix_sort.matches.forEach(function (obj) {
|
||||||
@@ -168,8 +171,13 @@ function emoji_prefix_sort(query, objs, get_item) {
|
|||||||
other_emoji_matches.push(obj);
|
other_emoji_matches.push(obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return { matches: popular_emoji_matches.concat(other_emoji_matches), rest: prefix_sort.rest };
|
|
||||||
}
|
return [].concat(
|
||||||
|
popular_emoji_matches,
|
||||||
|
other_emoji_matches,
|
||||||
|
prefix_sort.rest
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
exports.sorter = function (query, objs, get_item) {
|
exports.sorter = function (query, objs, get_item) {
|
||||||
const results = util.prefix_sort(query, objs, get_item);
|
const results = util.prefix_sort(query, objs, get_item);
|
||||||
@@ -411,12 +419,6 @@ exports.sort_slash_commands = function (matches, query) {
|
|||||||
return results.matches.concat(results.rest);
|
return results.matches.concat(results.rest);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.sort_emojis = function (matches, query) {
|
|
||||||
// TODO: sort by category in v2
|
|
||||||
const results = emoji_prefix_sort(query, matches, function (x) { return x.emoji_name; });
|
|
||||||
return results.matches.concat(results.rest);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Gives stream a score from 0 to 3 based on its activity
|
// Gives stream a score from 0 to 3 based on its activity
|
||||||
function activity_score(sub) {
|
function activity_score(sub) {
|
||||||
let stream_score = 0;
|
let stream_score = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user