2021-03-22 18:29:15 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-03-24 17:54:23 +01:00
|
|
|
import * as color_class from "./color_class";
|
2021-03-22 18:29:15 +01:00
|
|
|
import * as stream_data from "./stream_data";
|
|
|
|
|
2021-11-20 04:09:13 +01:00
|
|
|
function update_compose_stream_icon(stream_name) {
|
2021-03-22 18:29:15 +01:00
|
|
|
const streamfield = $("#stream_message_recipient_stream");
|
2021-11-20 04:20:21 +01:00
|
|
|
const globe_icon = $("#compose-globe-icon");
|
|
|
|
const lock_icon = $("#compose-lock-icon");
|
|
|
|
|
|
|
|
// Reset state
|
|
|
|
globe_icon.hide();
|
|
|
|
lock_icon.hide();
|
|
|
|
streamfield.removeClass("lock-padding");
|
|
|
|
|
2021-03-22 18:29:15 +01:00
|
|
|
if (stream_data.get_invite_only(stream_name)) {
|
2021-11-20 04:20:21 +01:00
|
|
|
lock_icon.show();
|
|
|
|
streamfield.addClass("lock-padding");
|
|
|
|
} else if (stream_data.is_web_public_by_stream_name(stream_name)) {
|
|
|
|
globe_icon.show();
|
2021-03-22 18:29:15 +01:00
|
|
|
streamfield.addClass("lock-padding");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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_name, element, is_compose) {
|
|
|
|
if (stream_name === undefined) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const color = stream_data.get_color(stream_name);
|
|
|
|
if (is_compose) {
|
2021-11-20 04:09:13 +01:00
|
|
|
update_compose_stream_icon(stream_name);
|
2021-03-22 18:29:15 +01:00
|
|
|
}
|
|
|
|
element
|
|
|
|
.css("background-color", color)
|
2021-03-24 17:54:23 +01:00
|
|
|
.removeClass("dark_background")
|
|
|
|
.addClass(color_class.get_css_class(color));
|
2021-03-22 18:29:15 +01:00
|
|
|
}
|