Update pinned icon in stories list.
This commit is contained in:
parent
9036e9e8e3
commit
645ad5e1bd
|
@ -1358,6 +1358,11 @@ bool HistoryItem::markContentsRead(bool fromThisClient) {
|
||||||
|
|
||||||
void HistoryItem::setIsPinned(bool pinned) {
|
void HistoryItem::setIsPinned(bool pinned) {
|
||||||
const auto changed = (isPinned() != pinned);
|
const auto changed = (isPinned() != pinned);
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
if (changed) {
|
||||||
|
_history->owner().notifyItemDataChange(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
if (pinned) {
|
if (pinned) {
|
||||||
_flags |= MessageFlag::Pinned;
|
_flags |= MessageFlag::Pinned;
|
||||||
if (_flags & MessageFlag::StoryItem) {
|
if (_flags & MessageFlag::StoryItem) {
|
||||||
|
@ -1392,9 +1397,6 @@ void HistoryItem::setIsPinned(bool pinned) {
|
||||||
Storage::SharedMediaType::Pinned,
|
Storage::SharedMediaType::Pinned,
|
||||||
id));
|
id));
|
||||||
}
|
}
|
||||||
if (changed) {
|
|
||||||
_history->owner().notifyItemDataChange(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryItem::returnSavedMedia() {
|
void HistoryItem::returnSavedMedia() {
|
||||||
|
|
|
@ -233,6 +233,13 @@ void ListWidget::subscribeToSession(
|
||||||
) | rpl::start_with_next([this](auto item) {
|
) | rpl::start_with_next([this](auto item) {
|
||||||
repaintItem(item);
|
repaintItem(item);
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
|
|
||||||
|
session->data().itemDataChanges(
|
||||||
|
) | rpl::start_with_next([=](not_null<HistoryItem*> item) {
|
||||||
|
if (const auto found = findItemByItem(item)) {
|
||||||
|
found->layout->itemDataChanged();
|
||||||
|
}
|
||||||
|
}, lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::setupSelectRestriction() {
|
void ListWidget::setupSelectRestriction() {
|
||||||
|
|
|
@ -460,6 +460,14 @@ void Photo::clearSpoiler() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Photo::itemDataChanged() {
|
||||||
|
const auto pinned = parent()->isPinned();
|
||||||
|
if (_pinned != pinned) {
|
||||||
|
_pinned = pinned;
|
||||||
|
delegate()->repaintItem(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Photo::clearHeavyPart() {
|
void Photo::clearHeavyPart() {
|
||||||
_dataMedia = nullptr;
|
_dataMedia = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -637,6 +645,14 @@ void Video::clearSpoiler() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Video::itemDataChanged() {
|
||||||
|
const auto pinned = parent()->isPinned();
|
||||||
|
if (_pinned != pinned) {
|
||||||
|
_pinned = pinned;
|
||||||
|
delegate()->repaintItem(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Video::clearHeavyPart() {
|
void Video::clearHeavyPart() {
|
||||||
_dataMedia = nullptr;
|
_dataMedia = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,8 @@ public:
|
||||||
|
|
||||||
void invalidateCache();
|
void invalidateCache();
|
||||||
|
|
||||||
|
virtual void itemDataChanged() {
|
||||||
|
}
|
||||||
virtual void clearHeavyPart() {
|
virtual void clearHeavyPart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,6 +207,7 @@ public:
|
||||||
QPoint point,
|
QPoint point,
|
||||||
StateRequest request) const override;
|
StateRequest request) const override;
|
||||||
|
|
||||||
|
void itemDataChanged() override;
|
||||||
void clearHeavyPart() override;
|
void clearHeavyPart() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -298,6 +301,7 @@ public:
|
||||||
QPoint point,
|
QPoint point,
|
||||||
StateRequest request) const override;
|
StateRequest request) const override;
|
||||||
|
|
||||||
|
void itemDataChanged() override;
|
||||||
void clearHeavyPart() override;
|
void clearHeavyPart() override;
|
||||||
void clearSpoiler() override;
|
void clearSpoiler() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue