Skip to content

Commit

Permalink
follow-topic: Show "follow" icon in recipient headers
Browse files Browse the repository at this point in the history
Together with the preceding few commits which add this icon in
some other places in the UI, this completes zulip#5770.

Fixes: zulip#5770
  • Loading branch information
gnprice committed Nov 16, 2023
1 parent 87755db commit 6ae2038
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/webview/html/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
streamNameOfStreamMessage,
} from '../../utils/recipient';
import { base64Utf8Encode } from '../../utils/encoding';
import { isTopicFollowed } from '../../mute/muteModel';

const renderTopic = message =>
// TODO: pin down if '' happens, and what its proper semantics are.
Expand All @@ -32,7 +33,7 @@ const renderTopic = message =>
* This is a private helper of messageListElementHtml.
*/
export default (
{ ownUser, subscriptions }: BackgroundData,
{ mute, ownUser, subscriptions }: BackgroundData,
element: HeaderMessageListElement,
): string => {
const { subsequentMessage: message, style: headerStyle } = element;
Expand All @@ -41,6 +42,7 @@ export default (
const streamName = streamNameOfStreamMessage(message);
const topicNarrowStr = keyFromNarrow(topicNarrow(message.stream_id, message.subject));
const topicHtml = renderTopic(message);
const isFollowed = isTopicFollowed(message.stream_id, message.subject, mute);

if (headerStyle === 'topic+date') {
return template`\
Expand All @@ -49,7 +51,7 @@ export default (
data-narrow="${base64Utf8Encode(topicNarrowStr)}"
data-msg-id="${message.id}"
>
<div class="topic-text">$!${topicHtml}</div>
<div class="topic-text" data-followed="${isFollowed}">$!${topicHtml}</div>
<div class="topic-date">${humanDate(new Date(message.timestamp * 1000))}</div>
</div>`;
} else if (headerStyle === 'full') {
Expand All @@ -70,7 +72,7 @@ export default (
data-narrow="${base64Utf8Encode(streamNarrowStr)}">
# ${streamName}
</div>
<div class="topic-text">$!${topicHtml}</div>
<div class="topic-text" data-followed="${isFollowed}">$!${topicHtml}</div>
<div class="topic-date">${humanDate(new Date(message.timestamp * 1000))}</div>
</div>`;
} else {
Expand Down
12 changes: 12 additions & 0 deletions src/webview/static/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,22 @@ body {
.topic-text {
flex: 1;
padding: 0 8px;
display: flex;
align-items: center;
overflow: hidden;
text-overflow: ellipsis;
pointer-events: none;
}
.topic-text[data-followed="true"]::after {
content: "";
background-image: url("images/follow.svg");
margin-left: 12px;
width: 17px;
height: 17px;
/* opacity: 0.2 on web, but that's with the pastel stream colors;
* 0.3 stands up better to our gray. */
opacity: 0.3;
}
.topic-date {
opacity: 0.5;
padding: 0 8px;
Expand Down

0 comments on commit 6ae2038

Please sign in to comment.