2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-18 13:59:46 +00:00

Fix crash in pinned topic deletion.

This commit is contained in:
John Preston
2022-12-07 10:43:02 +04:00
parent d01969ff1e
commit 02e2fb1258
14 changed files with 66 additions and 40 deletions

View File

@@ -76,6 +76,11 @@ rpl::producer<UpdateType> Changes::Manager<DataType, UpdateType>::flagsValue(
) | rpl::then(updates(data, flags));
}
template <typename DataType, typename UpdateType>
void Changes::Manager<DataType, UpdateType>::drop(not_null<DataType*> data) {
_updates.remove(data);
}
template <typename DataType, typename UpdateType>
void Changes::Manager<DataType, UpdateType>::sendNotifications() {
for (const auto &[data, flags] : base::take(_updates)) {
@@ -166,8 +171,11 @@ rpl::producer<HistoryUpdate> Changes::realtimeHistoryUpdates(
void Changes::topicUpdated(
not_null<ForumTopic*> topic,
TopicUpdate::Flags flags) {
_topicChanges.updated(topic, flags);
scheduleNotifications();
const auto drop = (flags & TopicUpdate::Flag::Destroyed);
_topicChanges.updated(topic, flags, drop);
if (!drop) {
scheduleNotifications();
}
}
rpl::producer<TopicUpdate> Changes::topicUpdates(
@@ -192,6 +200,10 @@ rpl::producer<TopicUpdate> Changes::realtimeTopicUpdates(
return _topicChanges.realtimeUpdates(flag);
}
void Changes::topicRemoved(not_null<ForumTopic*> topic) {
_topicChanges.drop(topic);
}
void Changes::messageUpdated(
not_null<HistoryItem*> item,
MessageUpdate::Flags flags) {
@@ -227,8 +239,11 @@ rpl::producer<MessageUpdate> Changes::realtimeMessageUpdates(
void Changes::entryUpdated(
not_null<Dialogs::Entry*> entry,
EntryUpdate::Flags flags) {
_entryChanges.updated(entry, flags);
scheduleNotifications();
const auto drop = (flags & EntryUpdate::Flag::Destroyed);
_entryChanges.updated(entry, flags, drop);
if (!drop) {
scheduleNotifications();
}
}
rpl::producer<EntryUpdate> Changes::entryUpdates(
@@ -253,6 +268,10 @@ rpl::producer<EntryUpdate> Changes::realtimeEntryUpdates(
return _entryChanges.realtimeUpdates(flag);
}
void Changes::entryRemoved(not_null<Dialogs::Entry*> entry) {
_entryChanges.drop(entry);
}
void Changes::scheduleNotifications() {
if (!_notify) {
_notify = true;