stream_color: Fix duplicate ids for colored privacy icons.

This also fixes the color on these icons in the stream-specific rows
of the notification settings table.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-03-27 17:48:47 -07:00 committed by Tim Abbott
parent deabb8ed53
commit eb572e525a
8 changed files with 13 additions and 9 deletions

View File

@ -35,9 +35,8 @@ function update_table_stream_color(table, stream_name, color) {
} }
} }
function update_stream_sidebar_swatch_color(id, color) { function update_stream_privacy_color(id, color) {
$(`#stream_sidebar_swatch_${CSS.escape(id)}`).css("background-color", color); $(`.stream-privacy-${CSS.escape(id)}`).css("color", color);
$(`#stream_sidebar_privacy_swatch_${CSS.escape(id)}`).css("color", color);
} }
function update_historical_message_color(stream_name, color) { function update_historical_message_color(stream_name, color) {
@ -95,7 +94,7 @@ export function update_stream_color(sub, color, {update_historical = false} = {}
if (update_historical) { if (update_historical) {
update_historical_message_color(sub.name, color); update_historical_message_color(sub.name, color);
} }
update_stream_sidebar_swatch_color(stream_id, color); update_stream_privacy_color(stream_id, color);
message_view_header.colorize_message_view_header(); message_view_header.colorize_message_view_header();
} }

View File

@ -80,6 +80,7 @@ export function get_unmatched_streams_for_notification_settings() {
if (make_table_row) { if (make_table_row) {
settings_values.stream_name = row.name; settings_values.stream_name = row.name;
settings_values.stream_id = row.stream_id; settings_values.stream_id = row.stream_id;
settings_values.color = row.color;
settings_values.invite_only = row.invite_only; settings_values.invite_only = row.invite_only;
settings_values.is_web_public = row.is_web_public; settings_values.is_web_public = row.is_web_public;

View File

@ -6,7 +6,7 @@
<span class="fa fa-envelope"></span> <span class="fa fa-envelope"></span>
<a href="{{pm_url}}">Direct messages</a> <a href="{{pm_url}}">Direct messages</a>
{{else}} {{else}}
<span id="stream_sidebar_privacy_swatch_{{stream_id}}" class="stream-privacy filter-icon" style="color: {{stream_color}}"> <span class="stream-privacy-{{stream_id}} stream-privacy filter-icon" style="color: {{stream_color}}">
{{> stream_privacy }} {{> stream_privacy }}
</span> </span>
<a href="{{topic_url}}">{{stream}}</a> <a href="{{topic_url}}">{{stream}}</a>

View File

@ -1,6 +1,6 @@
<tr class="stream-notifications-row {{#if muted}}control-label-disabled{{/if}}" data-stream-id="{{stream.stream_id}}"> <tr class="stream-notifications-row {{#if muted}}control-label-disabled{{/if}}" data-stream-id="{{stream.stream_id}}">
<td> <td>
<span id="stream_privacy_swatch_{{stream.stream_id}}" class="stream-privacy filter-icon"> <span class="stream-privacy-{{stream.stream_id}} stream-privacy filter-icon" style="color: {{stream.color}}">
{{> ../stream_privacy {{> ../stream_privacy
invite_only=stream.invite_only invite_only=stream.invite_only
is_web_public=stream.is_web_public }} is_web_public=stream.is_web_public }}

View File

@ -2,7 +2,7 @@
<ul class="nav nav-list streams_popover" data-stream-id="{{ stream.stream_id }}" data-name="{{ stream.name }}"> <ul class="nav nav-list streams_popover" data-stream-id="{{ stream.stream_id }}" data-name="{{ stream.name }}">
<li> <li>
<p class="topic-name"> <p class="topic-name">
<span id="stream_sidebar_privacy_swatch_{{stream.stream_id}}" class="stream-privacy filter-icon" style="color: {{stream.color}}"> <span class="stream-privacy-{{stream.stream_id}} stream-privacy filter-icon" style="color: {{stream.color}}">
{{> stream_privacy {{> stream_privacy
invite_only=stream.invite_only invite_only=stream.invite_only
is_web_public=stream.is_web_public }} is_web_public=stream.is_web_public }}

View File

@ -4,7 +4,7 @@
<div class="bottom_left_row"> <div class="bottom_left_row">
<div class="subscription_block selectable_sidebar_block"> <div class="subscription_block selectable_sidebar_block">
<span id="stream_sidebar_privacy_swatch_{{id}}" class="stream-privacy filter-icon" style="color: {{color}}"> <span class="stream-privacy-{{id}} stream-privacy filter-icon" style="color: {{color}}">
{{> stream_privacy }} {{> stream_privacy }}
</span> </span>

View File

@ -1,6 +1,6 @@
<tr data-stream-id="{{stream_id}}"> <tr data-stream-id="{{stream_id}}">
<td class="subscription_list_stream"> <td class="subscription_list_stream">
<span id="stream_sidebar_privacy_swatch_{{stream_id}}" class="stream-privacy filter-icon" style="color: {{stream_color}}"> <span class="stream-privacy-{{stream_id}} stream-privacy filter-icon" style="color: {{stream_color}}">
{{> stream_privacy }} {{> stream_privacy }}
</span> </span>
<a class = "stream_list_item" href="{{stream_edit_url}}">{{name}}</a> <a class = "stream_list_item" href="{{stream_edit_url}}">{{name}}</a>

View File

@ -541,6 +541,7 @@ test("notifications", () => {
const india = { const india = {
stream_id: 102, stream_id: 102,
name: "India", name: "India",
color: "#000080",
subscribed: true, subscribed: true,
invite_only: false, invite_only: false,
is_web_public: false, is_web_public: false,
@ -610,6 +611,7 @@ test("notifications", () => {
const canada = { const canada = {
stream_id: 103, stream_id: 103,
name: "Canada", name: "Canada",
color: "#d80621",
subscribed: true, subscribed: true,
invite_only: true, invite_only: true,
is_web_public: false, is_web_public: false,
@ -670,6 +672,7 @@ test("notifications", () => {
is_web_public: false, is_web_public: false,
stream_name: "Canada", stream_name: "Canada",
stream_id: 103, stream_id: 103,
color: "#d80621",
}, },
{ {
desktop_notifications: true, desktop_notifications: true,
@ -681,6 +684,7 @@ test("notifications", () => {
is_web_public: false, is_web_public: false,
stream_name: "India", stream_name: "India",
stream_id: 102, stream_id: 102,
color: "#000080",
}, },
]; ];