updateChatIsMarkedAsUnread

This commit is contained in:
Alexander Zveruk 2020-05-16 00:32:01 +03:00
parent c3f09546d6
commit 4a719af003
2 changed files with 18 additions and 6 deletions

View file

@ -42,6 +42,7 @@ class Controller:
self.handlers = {
"updateNewMessage": self.update_new_msg,
"updateChatIsPinned": self.update_chat_is_pinned,
"updateChatIsMarkedAsUnread": self.update_chat_marked_as_unread,
"updateChatReadInbox": self.update_chat_read_inbox,
"updateChatTitle": self.update_chat_title,
"updateChatLastMessage": self.update_chat_last_msg,
@ -329,6 +330,17 @@ class Controller:
self.model.chats.update_chat(chat_id, title=title)
self._refresh_current_chat(current_chat_id)
@handle_exception
def update_chat_marked_as_unread(self, update: Dict[str, Any]):
log.info("Proccessing updateChatIsMarkedAsUnread")
chat_id = update["chat_id"]
is_marked_as_unread = update["is_marked_as_unread"]
current_chat_id = self.model.chats.id_by_index(self.model.current_chat)
self.model.chats.update_chat(
chat_id, is_marked_as_unread=is_marked_as_unread
)
self._refresh_current_chat(current_chat_id)
@handle_exception
def update_chat_is_pinned(self, update: Dict[str, Any]):
log.info("Proccessing updateChatIsPinned")

View file

@ -145,13 +145,13 @@ 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, is_pinned, last_msg = (
get_date(chat),
chat["title"],
chat["unread_count"],
chat["is_pinned"],
get_last_msg(chat),
unread_count = (
chat["unread_count"] or 1 if chat["is_marked_as_unread"] else 0
)
date = get_date(chat)
title = chat["title"]
is_pinned = chat["is_pinned"]
last_msg = get_last_msg(chat)
offset = 0
for attr, elem in zip(
self._msg_attribures(is_selected), [f"{date} ", title]