web-narrow: Update operators to use channel and channels.

Updates operators used for narrow.activate and sent as narrow
parameters to the server to use channel and channels.

Part of stream to channel rename project.
This commit is contained in:
Lauryn Menard 2024-04-23 21:59:36 +02:00 committed by Tim Abbott
parent 8d102cf12f
commit 58b91202f4
12 changed files with 21 additions and 21 deletions

View File

@ -27,7 +27,7 @@ function restore_draft(draft_id) {
narrow.activate(
[
{
operator: "stream",
operator: "channel",
operand: stream_data.get_stream_name_from_id(compose_args.stream_id),
},
{operator: "topic", operand: compose_args.topic},

View File

@ -156,7 +156,7 @@ export function group_edit_url(group: UserGroup, right_side_tab: string): string
}
export function search_public_streams_notice_url(terms: NarrowTerm[]): string {
const public_operator = {operator: "streams", operand: "public"};
const public_operator = {operator: "channels", operand: "public"};
return search_terms_to_hash([public_operator, ...terms]);
}

View File

@ -1209,7 +1209,7 @@ export function process_hotkey(e, hotkey) {
narrow.activate(
[
{
operator: "stream",
operator: "channel",
operand: stream_data.get_stream_name_from_id(msg.stream_id),
},
{operator: "topic", operand: msg.topic},

View File

@ -1393,7 +1393,7 @@ export function with_first_message_id(stream_id, topic_name, success_cb, error_c
num_before: 1,
num_after: 0,
narrow: JSON.stringify([
{operator: "stream", operand: stream_id},
{operator: "channel", operand: stream_id},
{operator: "topic", operand: topic_name},
]),
};
@ -1421,7 +1421,7 @@ export function is_message_oldest_or_newest(
num_before: 1,
num_after: 1,
narrow: JSON.stringify([
{operator: "stream", operand: stream_id},
{operator: "channel", operand: stream_id},
{operator: "topic", operand: topic_name},
]),
};

View File

@ -406,7 +406,7 @@ export function update_messages(events) {
// The fix is likely somewhat involved, so punting for now.
const new_stream_name = sub_store.get(new_stream_id).name;
new_filter = new_filter.filter_with_new_params({
operator: "stream",
operator: "channel",
operand: new_stream_name,
});
changed_narrow = true;

View File

@ -102,7 +102,7 @@ export function unstar_all_messages_in_topic(stream_id: number, topic: string):
num_before: 1000,
num_after: 0,
narrow: JSON.stringify([
{operator: "stream", operand: stream_id},
{operator: "channel", operand: stream_id},
{operator: "topic", operand: topic},
{operator: "is", operand: "starred"},
]),

View File

@ -843,7 +843,7 @@ export function render_message_list_with_selected_message(opts) {
export function activate_stream_for_cycle_hotkey(stream_name) {
// This is the common code for A/D hotkeys.
const filter_expr = [{operator: "stream", operand: stream_name}];
const filter_expr = [{operator: "channel", operand: stream_name}];
activate(filter_expr, {});
}
@ -914,7 +914,7 @@ export function narrow_to_next_topic(opts = {}) {
}
const filter_expr = [
{operator: "stream", operand: next_narrow.stream},
{operator: "channel", operand: next_narrow.stream},
{operator: "topic", operand: next_narrow.topic},
];
@ -980,7 +980,7 @@ export function by_topic(target_id, opts) {
const stream_name = stream_data.get_stream_name_from_id(original.stream_id);
const search_terms = [
{operator: "stream", operand: stream_name},
{operator: "channel", operand: stream_name},
{operator: "topic", operand: original.topic},
];
opts = {then_select_id: target_id, ...opts};
@ -1042,7 +1042,7 @@ export function to_compose_target() {
const stream_name = stream_data.get_sub_by_id(stream_id).name;
// If we are composing to a new topic, we narrow to the stream but
// grey-out the message view instead of narrowing to an empty view.
const terms = [{operator: "stream", operand: stream_name}];
const terms = [{operator: "channel", operand: stream_name}];
const topic = compose_state.topic();
if (topic !== "") {
terms.push({operator: "topic", operand: topic});

View File

@ -22,7 +22,7 @@ function narrow_via_edit_scheduled_message(compose_args) {
narrow.activate(
[
{
operator: "stream",
operator: "channel",
operand: stream_data.get_stream_name_from_id(compose_args.stream_id),
},
{operator: "topic", operand: compose_args.topic},

View File

@ -863,7 +863,7 @@ export function initialize_everything(state_data) {
const sub = sub_store.get(stream_id);
narrow.activate(
[
{operator: "stream", operand: sub.name},
{operator: "channel", operand: sub.name},
{operator: "topic", operand: topic},
],
{trigger: "sidebar"},

View File

@ -479,7 +479,7 @@ export function mark_stream_as_read(stream_id) {
bulk_update_read_flags_for_narrow(
[
{operator: "is", operand: "unread", negated: false},
{operator: "stream", operand: stream_id},
{operator: "channel", operand: stream_id},
],
"add",
{
@ -492,7 +492,7 @@ export function mark_topic_as_read(stream_id, topic) {
bulk_update_read_flags_for_narrow(
[
{operator: "is", operand: "unread", negated: false},
{operator: "stream", operand: stream_id},
{operator: "channel", operand: stream_id},
{operator: "topic", operand: topic},
],
"add",
@ -506,7 +506,7 @@ export function mark_topic_as_read(stream_id, topic) {
export function mark_topic_as_unread(stream_id, topic) {
bulk_update_read_flags_for_narrow(
[
{operator: "stream", operand: stream_id},
{operator: "channel", operand: stream_id},
{operator: "topic", operand: topic},
],
"remove",

View File

@ -136,7 +136,7 @@ run_test("unstar_all_in_topic", ({override}) => {
num_before: 1000,
num_after: 0,
narrow: JSON.stringify([
{operator: "stream", operand: 20},
{operator: "channel", operand: 20},
{operator: "topic", operand: "topic"},
{operator: "is", operand: "starred"},
]),

View File

@ -692,7 +692,7 @@ run_test("narrow_to_compose_target streams", ({override_rewire}) => {
assert.equal(args.called, true);
assert.equal(args.opts.trigger, "narrow_to_compose_target");
assert.deepEqual(args.terms, [
{operator: "stream", operand: "ROME"},
{operator: "channel", operand: "ROME"},
{operator: "topic", operand: "one"},
]);
@ -702,7 +702,7 @@ run_test("narrow_to_compose_target streams", ({override_rewire}) => {
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.terms, [
{operator: "stream", operand: "ROME"},
{operator: "channel", operand: "ROME"},
{operator: "topic", operand: "four"},
]);
@ -711,14 +711,14 @@ run_test("narrow_to_compose_target streams", ({override_rewire}) => {
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.terms, [{operator: "stream", operand: "ROME"}]);
assert.deepEqual(args.terms, [{operator: "channel", operand: "ROME"}]);
// Test with no topic
compose_state.topic(undefined);
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
assert.deepEqual(args.terms, [{operator: "stream", operand: "ROME"}]);
assert.deepEqual(args.terms, [{operator: "channel", operand: "ROME"}]);
});
run_test("narrow_to_compose_target direct messages", ({override, override_rewire}) => {