mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-23 08:46:55 +00:00
Correctly clear story instances on deletion.
This commit is contained in:
parent
76f7a870ed
commit
b7370127ff
@ -723,6 +723,16 @@ void Stories::applyDeleted(FullStoryId id) {
|
||||
}
|
||||
_owner->refreshStoryItemViews(id);
|
||||
Assert(!_pollingSettings.contains(story.get()));
|
||||
if (const auto j = _items.find(id.peer); j != end(_items)) {
|
||||
const auto k = j->second.find(id.story);
|
||||
if (k != end(j->second)) {
|
||||
Assert(!k->second.lock());
|
||||
j->second.erase(k);
|
||||
if (j->second.empty()) {
|
||||
_items.erase(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i->second.empty()) {
|
||||
_stories.erase(i);
|
||||
}
|
||||
|
@ -548,6 +548,7 @@ void ListWidget::refreshRows() {
|
||||
resizeToWidth(width());
|
||||
restoreScrollState();
|
||||
mouseActionUpdate();
|
||||
update();
|
||||
}
|
||||
|
||||
bool ListWidget::preventAutoHide() const {
|
||||
@ -1942,6 +1943,7 @@ void ListWidget::applyDragSelection(SelectedMap &applyTo) const {
|
||||
|
||||
void ListWidget::refreshHeight() {
|
||||
resize(width(), recountHeight());
|
||||
update();
|
||||
}
|
||||
|
||||
int ListWidget::recountHeight() {
|
||||
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "info/media/info_media_widget.h"
|
||||
#include "info/media/info_media_list_section.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_media_types.h"
|
||||
#include "data/data_session.h"
|
||||
@ -54,6 +55,14 @@ Provider::Provider(not_null<AbstractController*> controller)
|
||||
layout.second.item->invalidateCache();
|
||||
}
|
||||
}, _lifetime);
|
||||
|
||||
_peer->session().changes().storyUpdates(
|
||||
Data::StoryUpdate::Flag::Destroyed
|
||||
) | rpl::filter([=](const Data::StoryUpdate &update) {
|
||||
return update.story->peer() == _peer;
|
||||
}) | rpl::start_with_next([=](const Data::StoryUpdate &update) {
|
||||
storyRemoved(update.story);
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
Provider::~Provider() {
|
||||
@ -253,15 +262,17 @@ bool Provider::isAfter(
|
||||
return (a->id < b->id);
|
||||
}
|
||||
|
||||
void Provider::itemRemoved(not_null<const HistoryItem*> item) {
|
||||
const auto id = StoryIdFromMsgId(item->id);
|
||||
if (const auto i = _layouts.find(id); i != end(_layouts)) {
|
||||
void Provider::storyRemoved(not_null<Data::Story*> story) {
|
||||
Expects(story->peer() == _peer);
|
||||
|
||||
if (const auto i = _layouts.find(story->id()); i != end(_layouts)) {
|
||||
_peer->owner().stories().unregisterPolling(
|
||||
{ _peer->id, id },
|
||||
story,
|
||||
Data::Stories::Polling::Chat);
|
||||
_layoutRemoved.fire(i->second.item.get());
|
||||
_layouts.erase(i);
|
||||
}
|
||||
_items.remove(story->id());
|
||||
}
|
||||
|
||||
BaseLayout *Provider::getLayout(
|
||||
|
@ -16,6 +16,10 @@ class HistoryItem;
|
||||
class PeerData;
|
||||
class History;
|
||||
|
||||
namespace Data {
|
||||
class Story;
|
||||
} // namespace Data
|
||||
|
||||
namespace Info {
|
||||
class AbstractController;
|
||||
} // namespace Info
|
||||
@ -97,7 +101,7 @@ private:
|
||||
not_null<const Media::BaseLayout*> item,
|
||||
not_null<const Media::BaseLayout*> previous) override;
|
||||
|
||||
void itemRemoved(not_null<const HistoryItem*> item);
|
||||
void storyRemoved(not_null<Data::Story*> story);
|
||||
void markLayoutsStale();
|
||||
void clearStaleLayouts();
|
||||
void clear();
|
||||
|
Loading…
Reference in New Issue
Block a user