mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 20:03:17 +00:00
showing pinned messages on the UI
This commit is contained in:
parent
a4b9adb9b9
commit
77a8102000
1 changed files with 11 additions and 4 deletions
|
@ -145,10 +145,11 @@ class ChatView:
|
|||
self.win.vline(0, self.w - 1, curses.ACS_VLINE, self.h)
|
||||
for i, chat in enumerate(chats):
|
||||
is_selected = i == current
|
||||
date, title, unread_count, last_msg = (
|
||||
date, title, unread_count, is_pinned, last_msg = (
|
||||
get_date(chat),
|
||||
chat["title"],
|
||||
chat["unread_count"],
|
||||
chat["is_pinned"],
|
||||
get_last_msg(chat),
|
||||
)
|
||||
offset = 0
|
||||
|
@ -173,7 +174,9 @@ class ChatView:
|
|||
|
||||
self.win.addstr(i, offset, last_msg, self._msg_color(is_selected))
|
||||
|
||||
if left_label := self._get_chat_label(unread_count, chat):
|
||||
if left_label := self._get_chat_label(
|
||||
unread_count, is_pinned, chat
|
||||
):
|
||||
self.win.addstr(
|
||||
i,
|
||||
self.w - len(left_label) - 1,
|
||||
|
@ -184,10 +187,14 @@ class ChatView:
|
|||
self._refresh()
|
||||
|
||||
@staticmethod
|
||||
def _get_chat_label(unread_count: int, chat: Dict[str, Any]) -> str:
|
||||
def _get_chat_label(
|
||||
unread_count: int, is_pinned: bool, chat: Dict[str, Any]
|
||||
) -> str:
|
||||
label = ""
|
||||
if is_pinned:
|
||||
label += "pinned "
|
||||
if unread_count:
|
||||
label = f"{unread_count} "
|
||||
label += f"{unread_count} "
|
||||
|
||||
if chat["notification_settings"]["mute_for"]:
|
||||
label = f"muted {label}"
|
||||
|
|
Loading…
Reference in a new issue