DivYonko commited on
Commit
3974f5a
Β·
1 Parent(s): cee5a19

Move pinned messages from Stats to Comments view - show above feed

Browse files
Files changed (2) hide show
  1. pages/comments.py +31 -0
  2. pages/stats.py +0 -31
pages/comments.py CHANGED
@@ -48,6 +48,37 @@ df["topic"] = df["topic"].apply(clean_topic) if "topic" in df.columns else "
48
  # ── COMMENTS VIEW ─────────────────────────────────────────────
49
  st.markdown('<div class="sec-hdr"><span class="sec-ttl">Live Chat Feed</span></div>', unsafe_allow_html=True)
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  # Build stream options
52
  _feed_stream_options = {}
53
  for _fs in st.session_state.streams:
 
48
  # ── COMMENTS VIEW ─────────────────────────────────────────────
49
  st.markdown('<div class="sec-hdr"><span class="sec-ttl">Live Chat Feed</span></div>', unsafe_allow_html=True)
50
 
51
+ # ── PINNED MESSAGES (shown above the feed) ────────────────────
52
+ if st.session_state.pinned_messages:
53
+ st.markdown(
54
+ '<div class="sec-hdr"><span class="sec-ttl">πŸ“Œ Pinned Messages</span>'
55
+ f'<span class="sec-pill">{len(st.session_state.pinned_messages)} pinned</span></div>',
56
+ unsafe_allow_html=True
57
+ )
58
+ for _pidx, _pmsg in enumerate(st.session_state.pinned_messages):
59
+ _ps = _pmsg.get("sentiment", "Neutral")
60
+ _ps_color = SENT_COLORS.get(_ps, "#6b7280")
61
+ _pt_color = TOPIC_COLOR.get(_pmsg.get("topic", "General"), "#6b7280")
62
+ _pcol1, _pcol2 = st.columns([10, 1])
63
+ with _pcol1:
64
+ st.markdown(
65
+ f'<div class="chat-card chat-pinned">'
66
+ f'<div class="chat-author">πŸ“Œ {_pmsg.get("author", "Unknown")}</div>'
67
+ f'<div class="chat-text">{_pmsg.get("text", "")}</div>'
68
+ f'<div class="chat-badges">'
69
+ f'<span class="badge pin-badge">Pinned</span>'
70
+ f'<span class="badge" style="color:{_ps_color};">{_ps}</span>'
71
+ f'<span class="badge" style="color:{_pt_color};">{_pmsg.get("topic","General")}</span>'
72
+ f'<span class="badge">{_pmsg.get("time","")[:19]}</span>'
73
+ f'</div></div>',
74
+ unsafe_allow_html=True
75
+ )
76
+ with _pcol2:
77
+ if st.button("\u2715", key=f"unpin_top_{_pidx}"):
78
+ st.session_state.pinned_messages.pop(_pidx)
79
+ st.rerun()
80
+ st.divider()
81
+
82
  # Build stream options
83
  _feed_stream_options = {}
84
  for _fs in st.session_state.streams:
pages/stats.py CHANGED
@@ -1068,37 +1068,6 @@ elif len(st.session_state.streams) > 1:
1068
  st.divider()
1069
  st.info("Add video IDs to your extra stream slots and click β–Ά Start to enable multi-stream comparison.")
1070
 
1071
- # -- PINNED MESSAGES ------------------------------------------
1072
- if st.session_state.pinned_messages:
1073
- st.divider()
1074
- st.markdown(
1075
- '<div class="sec-hdr"><span class="sec-ttl">πŸ“Œ Pinned Messages</span>'
1076
- f'<span class="sec-pill">{len(st.session_state.pinned_messages)} pinned</span></div>',
1077
- unsafe_allow_html=True
1078
- )
1079
- for idx, pmsg in enumerate(st.session_state.pinned_messages):
1080
- s = pmsg.get("sentiment", "Neutral")
1081
- s_color = SENT_COLORS.get(s, "#6b7280")
1082
- t_color = TOPIC_COLOR.get(pmsg.get("topic", "General"), "#6b7280")
1083
- pcol1, pcol2 = st.columns([10, 1])
1084
- with pcol1:
1085
- st.markdown(
1086
- f'<div class="chat-card chat-pinned">'
1087
- f'<div class="chat-author">πŸ“Œ {pmsg.get("author", "Unknown")}</div>'
1088
- f'<div class="chat-text">{pmsg.get("text", "")}</div>'
1089
- f'<div class="chat-badges">'
1090
- f'<span class="badge pin-badge">Pinned</span>'
1091
- f'<span class="badge" style="color:{s_color};">{s}</span>'
1092
- f'<span class="badge" style="color:{t_color};">{pmsg.get("topic","General")}</span>'
1093
- f'<span class="badge">{pmsg.get("time","")[:19]}</span>'
1094
- f'</div></div>',
1095
- unsafe_allow_html=True
1096
- )
1097
- with pcol2:
1098
- if st.button("βœ•", key=f"unpin_{idx}"):
1099
- st.session_state.pinned_messages.pop(idx)
1100
- st.rerun()
1101
-
1102
  # -- AUTO REFRESH ---------------------------------------------
1103
  if auto_refresh:
1104
  time.sleep(refresh_rate)
 
1068
  st.divider()
1069
  st.info("Add video IDs to your extra stream slots and click β–Ά Start to enable multi-stream comparison.")
1070
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1071
  # -- AUTO REFRESH ---------------------------------------------
1072
  if auto_refresh:
1073
  time.sleep(refresh_rate)