Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stream bar: Convert module to typescript.

evykassirerd3b5a76a675e
diff --git a/web/src/stream_bar.js b/web/src/stream_bar.ts
similarity index 56%
rename from web/src/stream_bar.js
rename to web/src/stream_bar.ts
index 9585a56dea3..f714ceb9893 100644
--- a/web/src/stream_bar.js
+++ b/web/src/stream_bar.ts
@@ -1,10 +1,11 @@
import * as stream_data from "./stream_data";
+import {DEFAULT_COLOR} from "./stream_data";
// In an attempt to decrease mixing, set stream bar
// color look like the stream being used.
// (In particular, if there's a color associated with it,
// have that color be reflected here too.)
-export function decorate(stream_id, $element) {
- const color = stream_data.get_color(stream_id);
+export function decorate(stream_id: number | undefined, $element: JQuery): void {
+ const color = stream_id === undefined ? DEFAULT_COLOR : stream_data.get_color(stream_id);
$element.css("background-color", color);
}
diff --git a/web/src/stream_data.ts b/web/src/stream_data.ts
index 0b758f8e2c6..b2e11f711b1 100644
--- a/web/src/stream_data.ts
+++ b/web/src/stream_data.ts
@@ -40,7 +40,7 @@ export type InviteStreamData = {
default_stream: boolean;
};
-const DEFAULT_COLOR = "#c2c2c2";
+export const DEFAULT_COLOR = "#c2c2c2";
// Expose get_subscriber_count for our automated puppeteer tests.
export const get_subscriber_count = peer_data.get_subscriber_count;