mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Correctly clear story instances on deletion.
This commit is contained in:
parent
76f7a870ed
commit
b7370127ff
4 changed files with 32 additions and 5 deletions
|
@ -723,6 +723,16 @@ void Stories::applyDeleted(FullStoryId id) {
|
||||||
}
|
}
|
||||||
_owner->refreshStoryItemViews(id);
|
_owner->refreshStoryItemViews(id);
|
||||||
Assert(!_pollingSettings.contains(story.get()));
|
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()) {
|
if (i->second.empty()) {
|
||||||
_stories.erase(i);
|
_stories.erase(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,6 +548,7 @@ void ListWidget::refreshRows() {
|
||||||
resizeToWidth(width());
|
resizeToWidth(width());
|
||||||
restoreScrollState();
|
restoreScrollState();
|
||||||
mouseActionUpdate();
|
mouseActionUpdate();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListWidget::preventAutoHide() const {
|
bool ListWidget::preventAutoHide() const {
|
||||||
|
@ -1942,6 +1943,7 @@ void ListWidget::applyDragSelection(SelectedMap &applyTo) const {
|
||||||
|
|
||||||
void ListWidget::refreshHeight() {
|
void ListWidget::refreshHeight() {
|
||||||
resize(width(), recountHeight());
|
resize(width(), recountHeight());
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListWidget::recountHeight() {
|
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_widget.h"
|
||||||
#include "info/media/info_media_list_section.h"
|
#include "info/media/info_media_list_section.h"
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -54,6 +55,14 @@ Provider::Provider(not_null<AbstractController*> controller)
|
||||||
layout.second.item->invalidateCache();
|
layout.second.item->invalidateCache();
|
||||||
}
|
}
|
||||||
}, _lifetime);
|
}, _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() {
|
Provider::~Provider() {
|
||||||
|
@ -253,15 +262,17 @@ bool Provider::isAfter(
|
||||||
return (a->id < b->id);
|
return (a->id < b->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Provider::itemRemoved(not_null<const HistoryItem*> item) {
|
void Provider::storyRemoved(not_null<Data::Story*> story) {
|
||||||
const auto id = StoryIdFromMsgId(item->id);
|
Expects(story->peer() == _peer);
|
||||||
if (const auto i = _layouts.find(id); i != end(_layouts)) {
|
|
||||||
|
if (const auto i = _layouts.find(story->id()); i != end(_layouts)) {
|
||||||
_peer->owner().stories().unregisterPolling(
|
_peer->owner().stories().unregisterPolling(
|
||||||
{ _peer->id, id },
|
story,
|
||||||
Data::Stories::Polling::Chat);
|
Data::Stories::Polling::Chat);
|
||||||
_layoutRemoved.fire(i->second.item.get());
|
_layoutRemoved.fire(i->second.item.get());
|
||||||
_layouts.erase(i);
|
_layouts.erase(i);
|
||||||
}
|
}
|
||||||
|
_items.remove(story->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseLayout *Provider::getLayout(
|
BaseLayout *Provider::getLayout(
|
||||||
|
|
|
@ -16,6 +16,10 @@ class HistoryItem;
|
||||||
class PeerData;
|
class PeerData;
|
||||||
class History;
|
class History;
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
class Story;
|
||||||
|
} // namespace Data
|
||||||
|
|
||||||
namespace Info {
|
namespace Info {
|
||||||
class AbstractController;
|
class AbstractController;
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
@ -97,7 +101,7 @@ private:
|
||||||
not_null<const Media::BaseLayout*> item,
|
not_null<const Media::BaseLayout*> item,
|
||||||
not_null<const Media::BaseLayout*> previous) override;
|
not_null<const Media::BaseLayout*> previous) override;
|
||||||
|
|
||||||
void itemRemoved(not_null<const HistoryItem*> item);
|
void storyRemoved(not_null<Data::Story*> story);
|
||||||
void markLayoutsStale();
|
void markLayoutsStale();
|
||||||
void clearStaleLayouts();
|
void clearStaleLayouts();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
Loading…
Add table
Reference in a new issue