Skip to content

Commit

Permalink
follow-topic: Show "follow" icon in recipient headers
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Nov 16, 2023
1 parent c9b6fda commit f0d4ee2
Show file tree
Hide file tree
Showing 4 changed files with 21 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
3 changes: 3 additions & 0 deletions src/webview/static/images/follow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tools/build-webview
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ sync "src/webview/static" "${dest}" <<EOF
+ /base.css
+ /images/
+ /images/follow.svg
+ /images/play_button.svg
- *
EOF

0 comments on commit f0d4ee2

Please sign in to comment.