Hide service messages from feed.

This commit is contained in:
John Preston 2018-01-30 16:17:50 +03:00
parent 2586268b81
commit 9f3048c1dc
6 changed files with 50 additions and 22 deletions

View File

@ -169,7 +169,7 @@ void Element::setY(int y) {
int Element::marginTop() const {
const auto item = data();
auto result = 0;
if (!isHiddenByGroup()) {
if (!isHidden()) {
if (isAttachedToPrevious()) {
result += st::msgMarginTopAttached;
} else {
@ -185,7 +185,7 @@ int Element::marginTop() const {
int Element::marginBottom() const {
const auto item = data();
return isHiddenByGroup() ? 0 : st::msgMargin.bottom();
return isHidden() ? 0 : st::msgMargin.bottom();
}
bool Element::isUnderCursor() const {
@ -231,6 +231,10 @@ bool Element::isHiddenByGroup() const {
return _flags & Flag::HiddenByGroup;
}
bool Element::isHidden() const {
return isHiddenByGroup();
}
void Element::refreshMedia() {
_flags &= ~Flag::HiddenByGroup;

View File

@ -136,6 +136,7 @@ public:
virtual int infoWidth() const;
bool isHiddenByGroup() const;
virtual bool isHidden() const;
// For blocks context this should be called only from recountAttachToPreviousInBlocks().
void setAttachToPrevious(bool attachToNext);

View File

@ -925,7 +925,7 @@ void ListWidget::updateItemsGeometry() {
const auto first = [&] {
for (auto i = 0; i != count; ++i) {
const auto view = _items[i].get();
if (view->isHiddenByGroup()) {
if (view->isHidden()) {
view->setDisplayDate(false);
} else {
view->setDisplayDate(true);
@ -1552,7 +1552,7 @@ void ListWidget::updateDragSelection(
}
};
const auto changeView = [&](not_null<Element*> view, bool add) {
if (!view->isHiddenByGroup()) {
if (!view->isHidden()) {
changeGroup(view->data(), add);
}
};
@ -2065,7 +2065,7 @@ void ListWidget::refreshAttachmentsAtIndex(int index) {
const auto from = [&] {
if (index > 0) {
for (auto i = index - 1; i != 0; --i) {
if (!_items[i]->isHiddenByGroup()) {
if (!_items[i]->isHidden()) {
return i;
}
}
@ -2075,7 +2075,7 @@ void ListWidget::refreshAttachmentsAtIndex(int index) {
const auto till = [&] {
const auto count = int(_items.size());
for (auto i = index + 1; i != count; ++i) {
if (!_items[i]->isHiddenByGroup()) {
if (!_items[i]->isHidden()) {
return i + 1;
}
}
@ -2093,7 +2093,7 @@ void ListWidget::refreshAttachmentsFromTill(int from, int till) {
auto view = _items[from].get();
for (auto i = from + 1; i != till; ++i) {
const auto next = _items[i].get();
if (next->isHiddenByGroup()) {
if (next->isHidden()) {
next->setDisplayDate(false);
} else {
const auto viewDate = view->data()->date;

View File

@ -347,6 +347,11 @@ void Message::draw(
QRect clip,
TextSelection selection,
TimeMs ms) const {
auto g = countGeometry();
if (g.width() < 1) {
return;
}
const auto item = message();
const auto media = this->media();
@ -354,11 +359,6 @@ void Message::draw(
const auto bubble = drawBubble();
const auto selected = (selection == FullSelection);
auto g = countGeometry();
if (g.width() < 1) {
return;
}
auto dateh = 0;
if (const auto date = Get<DateBadge>()) {
dateh = date->height();
@ -372,6 +372,10 @@ void Message::draw(
}
}
if (isHidden()) {
return;
}
auto fullAnimMs = App::main() ? App::main()->highlightStartTime(item) : 0LL;
if (fullAnimMs > 0 && fullAnimMs <= ms) {
auto animms = ms - fullAnimMs;
@ -609,7 +613,7 @@ void Message::paintText(Painter &p, QRect &trect, TextSelection selection) const
PointState Message::pointState(QPoint point) const {
const auto g = countGeometry();
if (g.width() < 1) {
if (g.width() < 1 || isHidden()) {
return PointState::Outside;
}
@ -664,7 +668,7 @@ bool Message::displayFromPhoto() const {
}
bool Message::hasFromPhoto() const {
if (isHiddenByGroup()) {
if (isHidden()) {
return false;
}
switch (context()) {
@ -695,7 +699,7 @@ TextState Message::textState(
auto result = TextState(item);
auto g = countGeometry();
if (g.width() < 1) {
if (g.width() < 1 || isHidden()) {
return result;
}
@ -1289,7 +1293,7 @@ bool Message::hasOutLayout() const {
bool Message::drawBubble() const {
const auto item = message();
if (isHiddenByGroup()) {
if (isHidden()) {
return false;
} else if (logEntryOriginal()) {
return true;
@ -1532,7 +1536,7 @@ QRect Message::countGeometry() const {
}
int Message::resizeContentGetHeight(int newWidth) {
if (isHiddenByGroup()) {
if (isHidden()) {
return marginTop() + marginBottom();
} else if (newWidth < st::msgMinWidth) {
return height();

View File

@ -311,14 +311,18 @@ QRect Service::countGeometry() const {
}
QSize Service::performCountCurrentSize(int newWidth) {
const auto item = message();
const auto media = this->media();
auto newHeight = displayedDateHeight();
if (const auto bar = Get<UnreadBar>()) {
newHeight += bar->height();
}
if (isHidden()) {
return { newWidth, newHeight };
}
const auto item = message();
const auto media = this->media();
if (item->_text.isEmpty()) {
item->_textHeight = 0;
} else {
@ -362,6 +366,13 @@ QSize Service::performCountOptimalSize() {
return { maxWidth, minHeight };
}
bool Service::isHidden() const {
if (context() == Context::Feed) {
return true;
}
return Element::isHidden();
}
void Service::draw(
Painter &p,
QRect clip,
@ -392,6 +403,13 @@ void Service::draw(
height -= unreadbarh;
}
if (isHidden()) {
if (auto skiph = dateh + unreadbarh) {
p.translate(0, -skiph);
}
return;
}
auto fullAnimMs = App::main() ? App::main()->highlightStartTime(item) : 0LL;
if (fullAnimMs > 0 && fullAnimMs <= ms) {
auto animms = ms - fullAnimMs;
@ -441,7 +459,7 @@ PointState Service::pointState(QPoint point) const {
const auto media = this->media();
auto g = countGeometry();
if (g.width() < 1) {
if (g.width() < 1 || isHidden()) {
return PointState::Outside;
}
@ -464,7 +482,7 @@ TextState Service::textState(QPoint point, StateRequest request) const {
auto result = TextState(item);
auto g = countGeometry();
if (g.width() < 1) {
if (g.width() < 1 || isHidden()) {
return result;
}

View File

@ -19,6 +19,7 @@ public:
not_null<ElementDelegate*> delegate,
not_null<HistoryService*> data);
bool isHidden() const override;
void draw(
Painter &p,
QRect clip,