stream_settings_ui: Move set_color to stream_settings_api.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-05 14:35:50 -07:00 committed by Tim Abbott
parent 62015a0b48
commit dd584ba8a9
5 changed files with 12 additions and 9 deletions

View File

@ -6,7 +6,7 @@ import $ from "jquery";
import {$t} from "./i18n";
import * as settings_data from "./settings_data";
import * as stream_data from "./stream_data";
import * as stream_settings_ui from "./stream_settings_ui";
import * as stream_settings_api from "./stream_settings_api";
extend([lchPlugin, mixPlugin]);
@ -85,7 +85,7 @@ function picker_do_change_color(color) {
$(".colorpicker").spectrum(sidebar_popover_colorpicker_options_full);
const stream_id = Number.parseInt($(this).attr("stream_id"), 10);
const hex_color = color.toHexString();
stream_settings_ui.set_color(stream_id, hex_color);
stream_settings_api.set_color(stream_id, hex_color);
}
subscriptions_table_colorpicker_options.change = picker_do_change_color;

View File

@ -16,6 +16,7 @@ import * as stream_color_events from "./stream_color_events";
import * as stream_data from "./stream_data";
import * as stream_list from "./stream_list";
import * as stream_muting from "./stream_muting";
import * as stream_settings_api from "./stream_settings_api";
import * as stream_settings_ui from "./stream_settings_ui";
import * as sub_store from "./sub_store";
import * as unread_ui from "./unread_ui";
@ -130,7 +131,7 @@ export function mark_subscribed(sub, subscribers, color) {
// needed.
blueslip.warn("Frontend needed to pick a color in mark_subscribed");
color = color_data.pick_color();
stream_settings_ui.set_color(sub.stream_id, color);
stream_settings_api.set_color(sub.stream_id, color);
}
stream_data.subscribe_myself(sub);
if (subscribers) {

View File

@ -1,5 +1,6 @@
import * as channel from "./channel";
import * as settings_ui from "./settings_ui";
import * as sub_store from "./sub_store";
export function bulk_set_stream_property(sub_data, $status_element) {
const url = "/json/users/me/subscriptions/properties";
@ -20,3 +21,8 @@ export function set_stream_property(sub, property, value, $status_element) {
const sub_data = {stream_id: sub.stream_id, property, value};
bulk_set_stream_property([sub_data], $status_element);
}
export function set_color(stream_id, color) {
const sub = sub_store.get(stream_id);
set_stream_property(sub, "color", color);
}

View File

@ -254,11 +254,6 @@ export function update_is_default_stream() {
}
}
export function set_color(stream_id, color) {
const sub = sub_store.get(stream_id);
stream_settings_api.set_stream_property(sub, "color", color);
}
export function update_subscribers_ui(sub) {
update_left_panel_row(sub);
stream_edit_subscribers.update_subscribers_list(sub);

View File

@ -15,6 +15,7 @@ const compose_fade = mock_esm("../src/compose_fade");
const stream_color_events = mock_esm("../src/stream_color_events");
const stream_list = mock_esm("../src/stream_list");
const stream_muting = mock_esm("../src/stream_muting");
const stream_settings_api = mock_esm("../src/stream_settings_api");
const stream_settings_ui = mock_esm("../src/stream_settings_ui", {
update_settings_for_subscribed: noop,
update_empty_left_panel_message: noop,
@ -344,7 +345,7 @@ test("marked_subscribed (color)", ({override}) => {
// narrow state is undefined
{
const stub = make_stub();
override(stream_settings_ui, "set_color", stub.f);
override(stream_settings_api, "set_color", stub.f);
blueslip.expect("warn", "Frontend needed to pick a color in mark_subscribed");
stream_events.mark_subscribed(sub, [], undefined);
assert.equal(stub.num_calls, 1);