Compare commits

..

No commits in common. "4e50ff865f6c813a7a1ed26ce8964d6c146ea62d" and "a2f583e9695b93f50374f3a7ac7f7e51ba99e7fe" have entirely different histories.

View File

@ -1,5 +1,5 @@
from PySide6.QtWidgets import QWidget, QListWidget, QVBoxLayout, QListWidgetItem, QAbstractItemView from PySide6.QtWidgets import QWidget, QListWidget, QVBoxLayout, QListWidgetItem, QAbstractItemView
from PySide6.QtCore import Qt, QSize, Signal, QLocale from PySide6.QtCore import Qt, QSize, Signal
from typing import List from typing import List
from app.core.models.chat_models import PrivateChatListItem from app.core.models.chat_models import PrivateChatListItem
from app.ui.widgets.chat_list_item_widget import ChatListItemWidget from app.ui.widgets.chat_list_item_widget import ChatListItemWidget
@ -168,32 +168,6 @@ class ChatListView(QWidget):
# TODO: Заменить на реальное количество непрочитанных сообщений # TODO: Заменить на реальное количество непрочитанных сообщений
unread_count = 2 unread_count = 2
# Build display timestamp based on recency
if chat.last_message and getattr(chat.last_message, 'created_at', None):
ts_utc = chat.last_message.created_at
ts_dt = ts_utc.astimezone()
now = datetime.now().astimezone()
delta_days = (now.date() - ts_dt.date()).days
if delta_days == 0:
# Respect system 12/24h preference
time_fmt = QLocale.system().timeFormat(QLocale.ShortFormat)
if ('AP' in time_fmt) or ('ap' in time_fmt) or ('a' in time_fmt):
# 12-hour clock
display_ts = ts_dt.strftime('%I:%M %p').lstrip('0')
else:
# 24-hour clock
display_ts = ts_dt.strftime('%H:%M')
elif delta_days == 1:
display_ts = 'Вчера'
elif 1 < delta_days < 7:
weekdays = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']
display_ts = weekdays[ts_dt.weekday()]
elif delta_days < 365:
display_ts = ts_dt.strftime('%b %d')
else:
display_ts = ts_dt.strftime('%d.%m.%y')
else:
display_ts = ''
# Создаем кастомный виджет # Создаем кастомный виджет
is_outgoing = False is_outgoing = False
is_read = None is_read = None
@ -203,13 +177,11 @@ class ChatListView(QWidget):
if is_outgoing: unread_count = 0 if is_outgoing: unread_count = 0
is_read = bool(chat.last_message.is_viewed) is_read = bool(chat.last_message.is_viewed)
item_widget = ChatListItemWidget(companion_name, last_msg, display_ts, unread_count=unread_count, is_outgoing=is_outgoing, is_read=is_read) item_widget = ChatListItemWidget(companion_name, last_msg, timestamp, unread_count=unread_count, is_outgoing=is_outgoing, is_read=is_read)
# Tooltip with full date/time on hover # Tooltip with full date/time on hover
try: try:
if chat.last_message and getattr(chat.last_message, 'created_at', None): if chat.last_message and getattr(chat.last_message, 'created_at', None):
ts_utc = chat.last_message.created_at item_widget.set_timestamp_tooltip(chat.last_message.created_at.strftime('%d.%m.%Y %H:%M:%S'))
ts_local = ts_utc.astimezone()
item_widget.set_timestamp_tooltip(ts_local.strftime('%d.%m.%Y %H:%M:%S'))
else: else:
item_widget.set_timestamp_tooltip("") item_widget.set_timestamp_tooltip("")
except Exception: except Exception:
@ -225,5 +197,3 @@ class ChatListView(QWidget):
self.chat_items_map[id(list_item)] = chat.chat_id self.chat_items_map[id(list_item)] = chat.chat_id