recent_topics: Append proper prefix before stream name.

We reuse the existing logic for displaying and updating stream color
from the stream left sidebar.

Tests fixtures were extracted and updated for this commit.
This commit is contained in:
Aman Agrawal
2020-05-26 14:03:35 +05:30
committed by Tim Abbott
parent 515334dfb2
commit d8a312eddb
4 changed files with 26 additions and 1 deletions

View File

@@ -6,6 +6,15 @@ set_global('$', global.make_zjquery({
set_global('hashchange', {
exit_overlay: () => {},
});
set_global('stream_data', {
get_sub: () => {
return {
color: "",
invite_only: false,
is_web_public: true,
};
},
});
set_global('overlays', {
open_overlay: (opts) => {
overlays.close_callback = opts.on_close;
@@ -195,12 +204,15 @@ function generate_topic_data(topic_info_array) {
data.push({
count_senders: 0,
hidden: hidden,
invite_only: false,
is_web_public: true,
last_msg_time: 'Just now',
senders: [
1,
2,
],
stream: 'stream' + stream_id,
stream_color: '',
stream_id: stream_id,
stream_url: 'https://www.example.com',
topic: topic,

View File

@@ -76,6 +76,7 @@ function format_topic(topic_data) {
const last_msg = message_store.get(topic_data.last_msg_id);
const stream = last_msg.stream;
const stream_id = last_msg.stream_id;
const stream_info = stream_data.get_sub(stream);
const topic = last_msg.topic;
const time = new XDate(last_msg.timestamp * 1000);
const last_msg_time = timerender.last_seen_status_from_date(time);
@@ -96,12 +97,17 @@ function format_topic(topic_data) {
const senders_info = people.sender_info_with_small_avatar_urls_for_sender_ids(senders);
return {
// stream info
stream_id: stream_id,
stream: stream,
stream_color: stream_info.color,
invite_only: stream_info.invite_only,
is_web_public: stream_info.is_web_public,
stream_url: hash_util.by_stream_uri(stream_id),
topic: topic,
unread_count: unread_count,
last_msg_time: last_msg_time,
stream_url: hash_util.by_stream_uri(stream_id),
topic_url: hash_util.by_stream_topic_uri(stream_id, topic),
hidden: hidden,
senders: senders_info,

View File

@@ -62,6 +62,10 @@
padding: 0 2px 0 2px;
}
.fa-lock {
padding-right: 3px;
}
.tableFixHead {
padding: 10px;
padding-top: 0px !important;

View File

@@ -7,6 +7,9 @@
{{/if}}
</td>
<td class="recent_topic_stream">
<span id="stream_sidebar_privacy_swatch_{{stream_id}}" class="stream-privacy filter-icon" style="color: {{stream_color}}">
{{> stream_privacy }}
</span>
<a href="{{stream_url}}">{{stream}}</a>
</td>
<td class="recent_topic_name">