compose: Add privacy icons to the stream dropdown menu.

These were previously used in the input form field and
this commit removes the code that supported that and
replaces it by using existing dropdown_widget functionality
to display the icons in the compose dropdown.
This commit is contained in:
evykassirer
2023-02-06 16:25:45 -08:00
committed by Tim Abbott
parent 8a2455a294
commit 02ae5818ae
5 changed files with 7 additions and 47 deletions

View File

@@ -1,37 +1,13 @@
import $ from "jquery";
import * as stream_data from "./stream_data";
function update_compose_stream_icon(stream_name) {
const $streamfield = $("#compose_select_stream_name");
const $globe_icon = $("#compose-globe-icon");
const $lock_icon = $("#compose-lock-icon");
// Reset state
$globe_icon.hide();
$lock_icon.hide();
$streamfield.removeClass("lock-padding");
if (stream_data.is_invite_only_by_stream_name(stream_name)) {
$lock_icon.show();
$streamfield.addClass("lock-padding");
} else if (stream_data.is_web_public_by_stream_name(stream_name)) {
$globe_icon.show();
$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) {
export function decorate(stream_name, $element) {
if (stream_name === undefined) {
return;
}
const color = stream_data.get_color(stream_name);
if (is_compose) {
update_compose_stream_icon(stream_name);
}
$element.css("background-color", color);
}