refactor: Break stream_data's dep on stream_color.

We simply lift the DEFAULT_COLOR constant to stream_data.
This commit is contained in:
Steve Howell 2021-03-28 14:51:24 +00:00 committed by Tim Abbott
parent 98372cd244
commit d9e4c2285c
3 changed files with 4 additions and 6 deletions

View File

@ -12,7 +12,6 @@ const {page_params} = require("../zjsunit/zpage_params");
const color_data = zrequire("color_data");
const stream_topic_history = zrequire("stream_topic_history");
const people = zrequire("people");
const stream_color = zrequire("stream_color");
const stream_data = zrequire("stream_data");
const message_list = zrequire("message_list");
const settings_config = zrequire("settings_config");
@ -96,7 +95,7 @@ test("basics", () => {
assert(!stream_data.get_invite_only("unknown"));
assert.equal(stream_data.get_color("social"), "red");
assert.equal(stream_data.get_color("unknown"), stream_color.default_color);
assert.equal(stream_data.get_color("unknown"), "#c2c2c2");
assert.equal(stream_data.get_name("denMARK"), "Denmark");
assert.equal(stream_data.get_name("unknown Stream"), "unknown Stream");

View File

@ -5,8 +5,6 @@ import {i18n} from "./i18n";
import * as message_view_header from "./message_view_header";
import * as subs from "./subs";
export const default_color = "#c2c2c2";
function update_table_stream_color(table, stream_name, color) {
// This is ugly, but temporary, as the new design will make it
// so that we only have color in the headers.

View File

@ -8,10 +8,11 @@ import {page_params} from "./page_params";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as settings_config from "./settings_config";
import * as stream_color from "./stream_color";
import * as stream_topic_history from "./stream_topic_history";
import * as util from "./util";
const DEFAULT_COLOR = "#c2c2c2";
// Expose get_subscriber_count for our automated puppeteer tests.
export const get_subscriber_count = peer_data.get_subscriber_count;
@ -544,7 +545,7 @@ export function canonicalized_name(stream_name) {
export function get_color(stream_name) {
const sub = get_sub(stream_name);
if (sub === undefined) {
return stream_color.default_color;
return DEFAULT_COLOR;
}
return sub.color;
}