mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
typeahead_helper: Fetch full subscriber list while sorting.
Work towards #34244.
This commit is contained in:
@@ -15,6 +15,7 @@ import type {
|
|||||||
TopicSuggestion,
|
TopicSuggestion,
|
||||||
} from "./composebox_typeahead.ts";
|
} from "./composebox_typeahead.ts";
|
||||||
import type {InputPillContainer} from "./input_pill.ts";
|
import type {InputPillContainer} from "./input_pill.ts";
|
||||||
|
import * as peer_data from "./peer_data.ts";
|
||||||
import * as people from "./people.ts";
|
import * as people from "./people.ts";
|
||||||
import type {PseudoMentionUser, User} from "./people.ts";
|
import type {PseudoMentionUser, User} from "./people.ts";
|
||||||
import * as pm_conversations from "./pm_conversations.ts";
|
import * as pm_conversations from "./pm_conversations.ts";
|
||||||
@@ -302,6 +303,18 @@ export function compare_people_for_relevance(
|
|||||||
// Now handle actual people users.
|
// Now handle actual people users.
|
||||||
// give preference to subscribed users first
|
// give preference to subscribed users first
|
||||||
if (current_stream_id !== undefined) {
|
if (current_stream_id !== undefined) {
|
||||||
|
// Fetch subscriber data if we don't have it yet, but don't wait for it.
|
||||||
|
// It's fine to use partial data for now, and hopefully on subsequent
|
||||||
|
// keystrokes, we'll have the full data to show more subscribers at the
|
||||||
|
// top of the list.
|
||||||
|
//
|
||||||
|
// (We will usually have it, since entering a channel triggers a fetch.)
|
||||||
|
if (!peer_data.has_full_subscriber_data(current_stream_id)) {
|
||||||
|
void peer_data.maybe_fetch_stream_subscribers(current_stream_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the client does not yet have complete subscriber data,
|
||||||
|
// "unknown" and "not subscribed" are both represented as false here.
|
||||||
const a_is_sub = stream_data.is_user_subscribed(current_stream_id, person_a.user.user_id);
|
const a_is_sub = stream_data.is_user_subscribed(current_stream_id, person_a.user.user_id);
|
||||||
const b_is_sub = stream_data.is_user_subscribed(current_stream_id, person_b.user.user_id);
|
const b_is_sub = stream_data.is_user_subscribed(current_stream_id, person_b.user.user_id);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ const message_user_ids = mock_esm("../src/message_user_ids", {
|
|||||||
user_ids: () => [],
|
user_ids: () => [],
|
||||||
});
|
});
|
||||||
const stream_topic_history_util = mock_esm("../src/stream_topic_history_util");
|
const stream_topic_history_util = mock_esm("../src/stream_topic_history_util");
|
||||||
|
mock_esm("../src/channel", {
|
||||||
|
get: () => ({subscribers: []}),
|
||||||
|
});
|
||||||
|
|
||||||
let set_timeout_called;
|
let set_timeout_called;
|
||||||
set_global("setTimeout", (f, time) => {
|
set_global("setTimeout", (f, time) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const assert = require("node:assert/strict");
|
const assert = require("node:assert/strict");
|
||||||
|
|
||||||
const {zrequire} = require("./lib/namespace.cjs");
|
const {mock_esm, zrequire} = require("./lib/namespace.cjs");
|
||||||
const {run_test} = require("./lib/test.cjs");
|
const {run_test} = require("./lib/test.cjs");
|
||||||
|
|
||||||
const settings_config = zrequire("settings_config");
|
const settings_config = zrequire("settings_config");
|
||||||
@@ -24,6 +24,10 @@ const th = zrequire("typeahead_helper");
|
|||||||
const user_groups = zrequire("user_groups");
|
const user_groups = zrequire("user_groups");
|
||||||
const {initialize_user_settings} = zrequire("user_settings");
|
const {initialize_user_settings} = zrequire("user_settings");
|
||||||
|
|
||||||
|
mock_esm("../src/channel", {
|
||||||
|
get: () => ({subscribers: []}),
|
||||||
|
});
|
||||||
|
|
||||||
const current_user = {};
|
const current_user = {};
|
||||||
set_current_user(current_user);
|
set_current_user(current_user);
|
||||||
const realm = {};
|
const realm = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user