void Entry::cachePinnedIndex(int index) { if (_pinnedIndex != index) { const auto wasPinned = isPinnedDialog(); _pinnedIndex = index; updateChatListSortPosition(); updateChatListEntry(); if (wasPinned != isPinnedDialog()) { changedChatListPinHook(); } } }
void Entry::updateChatListSortPosition() { _sortKeyInChatList = useProxyPromotion() ? ProxyPromotedDialogPos() : isPinnedDialog() ? PinnedDialogPos(_pinnedIndex) : DialogPosFromDate(adjustChatListTimeId()); if (needUpdateInChatList()) { setChatListExistence(true); } }
void Entry::updateChatListSortPosition() { if (Auth().supportMode() && _sortKeyInChatList != 0 && Auth().settings().supportFixChatsOrder()) { updateChatListEntry(); return; } _sortKeyInChatList = useProxyPromotion() ? ProxyPromotedDialogPos() : isPinnedDialog() ? PinnedDialogPos(_pinnedIndex) : DialogPosFromDate(adjustChatListTimeId()); if (needUpdateInChatList()) { setChatListExistence(true); } }
void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms) { auto history = row->history(); auto item = history->lastMsg; auto cloudDraft = history->cloudDraft(); if (Data::draftIsNull(cloudDraft)) { cloudDraft = nullptr; } auto displayDate = [item, cloudDraft]() { if (item) { if (cloudDraft) { return (item->date > cloudDraft->date) ? item->date : cloudDraft->date; } return item->date; } return cloudDraft ? cloudDraft->date : QDateTime(); }; int unreadCount = history->unreadCount(); if (history->peer->migrateFrom()) { if (auto migrated = App::historyLoaded(history->peer->migrateFrom()->id)) { unreadCount += migrated->unreadCount(); } } if (item && cloudDraft && unreadCount > 0) { cloudDraft = nullptr; // Draw item, if draft is older. } paintRow(p, row, history, item, cloudDraft, displayDate(), fullWidth, active, selected, onlyBackground, ms, [&p, fullWidth, active, selected, ms, history, unreadCount](int nameleft, int namewidth, HistoryItem *item) { int availableWidth = namewidth; int texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip; if (unreadCount) { auto counter = QString::number(unreadCount); auto mutedCounter = history->mute(); auto unreadRight = fullWidth - st::dialogsPadding.x(); auto unreadTop = texttop + st::dialogsTextFont->ascent - st::dialogsUnreadFont->ascent - (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2; auto unreadWidth = 0; UnreadBadgeStyle st; st.active = active; st.muted = history->mute(); paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth); availableWidth -= unreadWidth + st.padding; } else if (history->isPinnedDialog()) { auto &icon = (active ? st::dialogsPinnedIconActive : (selected ? st::dialogsPinnedIconOver : st::dialogsPinnedIcon)); icon.paint(p, fullWidth - st::dialogsPadding.x() - icon.width(), texttop, fullWidth); availableWidth -= icon.width() + st::dialogsUnreadPadding; } auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService); if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) { item->drawInDialog(p, QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height), active, selected, history->textCachedFor, history->lastItemTextCache); } }, [&p, fullWidth, active, selected, ms, history, unreadCount] { if (unreadCount) { auto counter = QString::number(unreadCount); if (counter.size() > 4) { counter = qsl("..") + counter.mid(counter.size() - 3); } auto mutedCounter = history->mute(); auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize; auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight; auto unreadWidth = 0; UnreadBadgeStyle st; st.active = active; st.muted = history->mute(); paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth); } }); }