Use notify* instead of mark* in Data::Session.

This commit is contained in:
John Preston 2018-01-17 21:20:55 +03:00
parent 8a56ede187
commit 04c8c95634
17 changed files with 137 additions and 140 deletions

View File

@ -1219,7 +1219,7 @@ void ApiWrap::saveStickerSets(const Stickers::Order &localOrder, const Stickers:
if (writeArchived) Local::writeArchivedStickers(); if (writeArchived) Local::writeArchivedStickers();
if (writeCloudRecent) Local::writeRecentStickers(); if (writeCloudRecent) Local::writeRecentStickers();
if (writeFaved) Local::writeFavedStickers(); if (writeFaved) Local::writeFavedStickers();
_session->data().markStickersUpdated(); _session->data().notifyStickersUpdated();
if (_stickerSetDisenableRequests.empty()) { if (_stickerSetDisenableRequests.empty()) {
stickersSaveOrder(); stickersSaveOrder();
@ -1834,7 +1834,7 @@ void ApiWrap::setGroupStickerSet(not_null<ChannelData*> megagroup, const MTPInpu
Expects(megagroup->mgInfo != nullptr); Expects(megagroup->mgInfo != nullptr);
megagroup->mgInfo->stickerSet = set; megagroup->mgInfo->stickerSet = set;
request(MTPchannels_SetStickers(megagroup->inputChannel, set)).send(); request(MTPchannels_SetStickers(megagroup->inputChannel, set)).send();
_session->data().markStickersUpdated(); _session->data().notifyStickersUpdated();
} }
void ApiWrap::requestStickers(TimeId now) { void ApiWrap::requestStickers(TimeId now) {
@ -1986,7 +1986,7 @@ void ApiWrap::readFeaturedSets() {
MTP_vector<MTPlong>(wrappedIds)); MTP_vector<MTPlong>(wrappedIds));
request(std::move(requestData)).done([=](const MTPBool &result) { request(std::move(requestData)).done([=](const MTPBool &result) {
Local::writeFeaturedStickers(); Local::writeFeaturedStickers();
_session->data().markStickersUpdated(); _session->data().notifyStickersUpdated();
}).send(); }).send();
_session->data().setFeaturedStickerSetsUnreadCount(count); _session->data().setFeaturedStickerSetsUnreadCount(count);

View File

@ -951,7 +951,7 @@ namespace {
if (saved.size() > Global::SavedGifsLimit()) saved.pop_back(); if (saved.size() > Global::SavedGifsLimit()) saved.pop_back();
Local::writeSavedGifs(); Local::writeSavedGifs();
Auth().data().markSavedGifsUpdated(); Auth().data().notifySavedGifsUpdated();
Auth().data().setLastSavedGifsUpdate(0); Auth().data().setLastSavedGifsUpdate(0);
Auth().api().updateStickers(); Auth().api().updateStickers();
} }
@ -1277,7 +1277,7 @@ namespace {
if (Global::started() if (Global::started()
&& !App::quitting() && !App::quitting()
&& AuthSession::Exists()) { && AuthSession::Exists()) {
Auth().data().markItemRemoved(item); Auth().data().notifyItemRemoved(item);
} }
} }

View File

@ -239,7 +239,7 @@ void StickerSetBox::Inner::installDone(const MTPmessages_StickerSetInstallResult
Local::writeArchivedStickers(); Local::writeArchivedStickers();
} }
Local::writeInstalledStickers(); Local::writeInstalledStickers();
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
_setInstalled.fire_copy(_setId); _setInstalled.fire_copy(_setId);
} }

View File

@ -72,7 +72,7 @@ void ApplyArchivedResult(const MTPDmessages_stickerSetInstallResultArchive &d) {
Ui::Toast::Show(toast); Ui::Toast::Show(toast);
// Ui::show(Box<StickersBox>(archived), LayerOption::KeepOther); // Ui::show(Box<StickersBox>(archived), LayerOption::KeepOther);
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
// For testing: Just apply random subset or your sticker sets as archived. // For testing: Just apply random subset or your sticker sets as archived.
@ -132,7 +132,7 @@ void InstallLocally(uint64 setId) {
Local::writeArchivedStickers(); Local::writeArchivedStickers();
} }
} }
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
void UndoInstallLocally(uint64 setId) { void UndoInstallLocally(uint64 setId) {
@ -151,7 +151,7 @@ void UndoInstallLocally(uint64 setId) {
} }
Local::writeInstalledStickers(); Local::writeInstalledStickers();
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
Ui::show( Ui::show(
Box<InformBox>(lang(lng_stickers_not_found)), Box<InformBox>(lang(lng_stickers_not_found)),
@ -234,7 +234,7 @@ void SetIsFaved(not_null<DocumentData*> document, base::optional<std::vector<not
return; return;
} }
Local::writeFavedStickers(); Local::writeFavedStickers();
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
Auth().api().stickerSetInstalled(FavedSetId); Auth().api().stickerSetInstalled(FavedSetId);
} }
@ -302,7 +302,7 @@ void SetIsNotFaved(not_null<DocumentData*> document) {
sets.erase(it); sets.erase(it);
} }
Local::writeFavedStickers(); Local::writeFavedStickers();
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
void SetFaved(not_null<DocumentData*> document, bool faved) { void SetFaved(not_null<DocumentData*> document, bool faved) {
@ -374,7 +374,7 @@ void SetsReceived(const QVector<MTPStickerSet> &data, int32 hash) {
LOG(("API Error: received stickers hash %1 while counted hash is %2").arg(hash).arg(Local::countStickersHash())); LOG(("API Error: received stickers hash %1 while counted hash is %2").arg(hash).arg(Local::countStickersHash()));
} }
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
void SetPackAndEmoji(Set &set, Pack &&pack, const QVector<MTPStickerPack> &packs) { void SetPackAndEmoji(Set &set, Pack &&pack, const QVector<MTPStickerPack> &packs) {
@ -475,7 +475,7 @@ void SpecialSetReceived(uint64 setId, const QString &setTitle, const QVector<MTP
default: Unexpected("setId in SpecialSetReceived()"); default: Unexpected("setId in SpecialSetReceived()");
} }
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVector<MTPlong> &unread, int32 hash) { void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVector<MTPlong> &unread, int32 hash) {
@ -575,7 +575,7 @@ void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVect
Local::writeFeaturedStickers(); Local::writeFeaturedStickers();
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
void GifsReceived(const QVector<MTPDocument> &items, int32 hash) { void GifsReceived(const QVector<MTPDocument> &items, int32 hash) {
@ -598,7 +598,7 @@ void GifsReceived(const QVector<MTPDocument> &items, int32 hash) {
Local::writeSavedGifs(); Local::writeSavedGifs();
Auth().data().markSavedGifsUpdated(); Auth().data().notifySavedGifsUpdated();
} }
Pack GetListByEmoji(not_null<EmojiPtr> emoji) { Pack GetListByEmoji(not_null<EmojiPtr> emoji) {
@ -792,7 +792,7 @@ Set *FeedSetFull(const MTPmessages_StickerSet &data) {
} }
} }
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
return set; return set;
} }

View File

@ -108,7 +108,7 @@ void Session::animationLoadSettingsChanged() {
void Session::notifyPhotoLayoutChanged(not_null<const PhotoData*> photo) { void Session::notifyPhotoLayoutChanged(not_null<const PhotoData*> photo) {
if (const auto i = _photoViews.find(photo); i != end(_photoViews)) { if (const auto i = _photoViews.find(photo); i != end(_photoViews)) {
for (const auto view : i->second) { for (const auto view : i->second) {
markViewLayoutChange(view); notifyViewLayoutChange(view);
} }
} }
} }
@ -118,7 +118,7 @@ void Session::notifyDocumentLayoutChanged(
const auto i = _documentViews.find(document); const auto i = _documentViews.find(document);
if (i != end(_documentViews)) { if (i != end(_documentViews)) {
for (const auto view : i->second) { for (const auto view : i->second) {
markViewLayoutChange(view); notifyViewLayoutChange(view);
} }
} }
if (const auto items = InlineBots::Layout::documentItems()) { if (const auto items = InlineBots::Layout::documentItems()) {
@ -147,27 +147,19 @@ void Session::markMediaRead(not_null<const DocumentData*> document) {
} }
} }
void Session::markItemLayoutChange(not_null<const HistoryItem*> item) { void Session::notifyViewLayoutChange(not_null<const ViewElement*> view) {
_itemLayoutChanges.fire_copy(item);
}
rpl::producer<not_null<const HistoryItem*>> Session::itemLayoutChanged() const {
return _itemLayoutChanges.events();
}
void Session::markViewLayoutChange(not_null<const HistoryView::Element*> view) {
_viewLayoutChanges.fire_copy(view); _viewLayoutChanges.fire_copy(view);
} }
rpl::producer<not_null<const HistoryView::Element*>> Session::viewLayoutChanged() const { rpl::producer<not_null<const ViewElement*>> Session::viewLayoutChanged() const {
return _viewLayoutChanges.events(); return _viewLayoutChanges.events();
} }
void Session::markItemIdChange(IdChange event) { void Session::notifyItemIdChange(IdChange event) {
_itemIdChanges.fire_copy(event); _itemIdChanges.fire_copy(event);
enumerateItemViews(event.item, [](not_null<HistoryView::Element*> view) { enumerateItemViews(
view->refreshDataId(); event.item,
}); [](not_null<ViewElement*> view) { view->refreshDataId(); });
} }
rpl::producer<Session::IdChange> Session::itemIdChanged() const { rpl::producer<Session::IdChange> Session::itemIdChanged() const {
@ -222,7 +214,7 @@ rpl::producer<not_null<const HistoryItem*>> Session::itemPlayInlineRequest() con
return _itemPlayInlineRequest.events(); return _itemPlayInlineRequest.events();
} }
void Session::markItemRemoved(not_null<const HistoryItem*> item) { void Session::notifyItemRemoved(not_null<const HistoryItem*> item) {
_itemRemoved.fire_copy(item); _itemRemoved.fire_copy(item);
} }
@ -230,7 +222,7 @@ rpl::producer<not_null<const HistoryItem*>> Session::itemRemoved() const {
return _itemRemoved.events(); return _itemRemoved.events();
} }
void Session::markHistoryUnloaded(not_null<const History*> history) { void Session::notifyHistoryUnloaded(not_null<const History*> history) {
_historyUnloaded.fire_copy(history); _historyUnloaded.fire_copy(history);
} }
@ -238,7 +230,7 @@ rpl::producer<not_null<const History*>> Session::historyUnloaded() const {
return _historyUnloaded.events(); return _historyUnloaded.events();
} }
void Session::markHistoryCleared(not_null<const History*> history) { void Session::notifyHistoryCleared(not_null<const History*> history) {
_historyCleared.fire_copy(history); _historyCleared.fire_copy(history);
} }
@ -288,7 +280,7 @@ rpl::producer<not_null<UserData*>> Session::megagroupParticipantAdded(
}); });
} }
void Session::markStickersUpdated() { void Session::notifyStickersUpdated() {
_stickersUpdated.fire({}); _stickersUpdated.fire({});
} }
@ -296,7 +288,7 @@ rpl::producer<> Session::stickersUpdated() const {
return _stickersUpdated.events(); return _stickersUpdated.events();
} }
void Session::markSavedGifsUpdated() { void Session::notifySavedGifsUpdated() {
_savedGifsUpdated.fire({}); _savedGifsUpdated.fire({});
} }
@ -1107,13 +1099,13 @@ void Session::gameApplyFields(
void Session::registerPhotoView( void Session::registerPhotoView(
not_null<const PhotoData*> photo, not_null<const PhotoData*> photo,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
_photoViews[photo].insert(view); _photoViews[photo].insert(view);
} }
void Session::unregisterPhotoView( void Session::unregisterPhotoView(
not_null<const PhotoData*> photo, not_null<const PhotoData*> photo,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
const auto i = _photoViews.find(photo); const auto i = _photoViews.find(photo);
if (i != _photoViews.end()) { if (i != _photoViews.end()) {
auto &items = i->second; auto &items = i->second;
@ -1125,13 +1117,13 @@ void Session::unregisterPhotoView(
void Session::registerDocumentView( void Session::registerDocumentView(
not_null<const DocumentData*> document, not_null<const DocumentData*> document,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
_documentViews[document].insert(view); _documentViews[document].insert(view);
} }
void Session::unregisterDocumentView( void Session::unregisterDocumentView(
not_null<const DocumentData*> document, not_null<const DocumentData*> document,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
const auto i = _documentViews.find(document); const auto i = _documentViews.find(document);
if (i != _documentViews.end()) { if (i != _documentViews.end()) {
auto &items = i->second; auto &items = i->second;
@ -1161,13 +1153,13 @@ void Session::unregisterDocumentItem(
void Session::registerWebPageView( void Session::registerWebPageView(
not_null<const WebPageData*> page, not_null<const WebPageData*> page,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
_webpageViews[page].insert(view); _webpageViews[page].insert(view);
} }
void Session::unregisterWebPageView( void Session::unregisterWebPageView(
not_null<const WebPageData*> page, not_null<const WebPageData*> page,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
const auto i = _webpageViews.find(page); const auto i = _webpageViews.find(page);
if (i != _webpageViews.end()) { if (i != _webpageViews.end()) {
auto &items = i->second; auto &items = i->second;
@ -1197,13 +1189,13 @@ void Session::unregisterWebPageItem(
void Session::registerGameView( void Session::registerGameView(
not_null<const GameData*> game, not_null<const GameData*> game,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
_gameViews[game].insert(view); _gameViews[game].insert(view);
} }
void Session::unregisterGameView( void Session::unregisterGameView(
not_null<const GameData*> game, not_null<const GameData*> game,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
const auto i = _gameViews.find(game); const auto i = _gameViews.find(game);
if (i != _gameViews.end()) { if (i != _gameViews.end()) {
auto &items = i->second; auto &items = i->second;
@ -1215,7 +1207,7 @@ void Session::unregisterGameView(
void Session::registerContactView( void Session::registerContactView(
UserId contactId, UserId contactId,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
if (!contactId) { if (!contactId) {
return; return;
} }
@ -1224,7 +1216,7 @@ void Session::registerContactView(
void Session::unregisterContactView( void Session::unregisterContactView(
UserId contactId, UserId contactId,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
if (!contactId) { if (!contactId) {
return; return;
} }
@ -1289,7 +1281,7 @@ void Session::unregisterContactItem(
void Session::registerAutoplayAnimation( void Session::registerAutoplayAnimation(
not_null<::Media::Clip::Reader*> reader, not_null<::Media::Clip::Reader*> reader,
not_null<HistoryView::Element*> view) { not_null<ViewElement*> view) {
_autoplayAnimations.emplace(reader, view); _autoplayAnimations.emplace(reader, view);
} }

View File

@ -61,11 +61,9 @@ public:
not_null<HistoryItem*> item; not_null<HistoryItem*> item;
MsgId oldId = 0; MsgId oldId = 0;
}; };
void markItemIdChange(IdChange event); void notifyItemIdChange(IdChange event);
rpl::producer<IdChange> itemIdChanged() const; rpl::producer<IdChange> itemIdChanged() const;
void markItemLayoutChange(not_null<const HistoryItem*> item); void notifyViewLayoutChange(not_null<const ViewElement*> view);
rpl::producer<not_null<const HistoryItem*>> itemLayoutChanged() const;
void markViewLayoutChange(not_null<const ViewElement*> view);
rpl::producer<not_null<const ViewElement*>> viewLayoutChanged() const; rpl::producer<not_null<const ViewElement*>> viewLayoutChanged() const;
void requestItemViewRepaint(not_null<const HistoryItem*> item); void requestItemViewRepaint(not_null<const HistoryItem*> item);
rpl::producer<not_null<const HistoryItem*>> itemViewRepaintRequest() const; rpl::producer<not_null<const HistoryItem*>> itemViewRepaintRequest() const;
@ -79,13 +77,14 @@ public:
rpl::producer<not_null<const HistoryItem*>> itemViewRefreshRequest() const; rpl::producer<not_null<const HistoryItem*>> itemViewRefreshRequest() const;
void requestItemPlayInline(not_null<const HistoryItem*> item); void requestItemPlayInline(not_null<const HistoryItem*> item);
rpl::producer<not_null<const HistoryItem*>> itemPlayInlineRequest() const; rpl::producer<not_null<const HistoryItem*>> itemPlayInlineRequest() const;
void markItemRemoved(not_null<const HistoryItem*> item); void notifyHistoryUnloaded(not_null<const History*> history);
rpl::producer<not_null<const HistoryItem*>> itemRemoved() const;
void markHistoryUnloaded(not_null<const History*> history);
rpl::producer<not_null<const History*>> historyUnloaded() const; rpl::producer<not_null<const History*>> historyUnloaded() const;
void markHistoryCleared(not_null<const History*> history); void notifyItemRemoved(not_null<const HistoryItem*> item);
rpl::producer<not_null<const HistoryItem*>> itemRemoved() const;
void notifyHistoryCleared(not_null<const History*> history);
rpl::producer<not_null<const History*>> historyCleared() const; rpl::producer<not_null<const History*>> historyCleared() const;
using MegagroupParticipant = std::tuple< using MegagroupParticipant = std::tuple<
not_null<ChannelData*>, not_null<ChannelData*>,
not_null<UserData*>>; not_null<UserData*>>;
@ -102,9 +101,9 @@ public:
rpl::producer<not_null<UserData*>> megagroupParticipantAdded( rpl::producer<not_null<UserData*>> megagroupParticipantAdded(
not_null<ChannelData*> channel) const; not_null<ChannelData*> channel) const;
void markStickersUpdated(); void notifyStickersUpdated();
rpl::producer<> stickersUpdated() const; rpl::producer<> stickersUpdated() const;
void markSavedGifsUpdated(); void notifySavedGifsUpdated();
rpl::producer<> savedGifsUpdated() const; rpl::producer<> savedGifsUpdated() const;
bool stickersUpdateNeeded(TimeMs now) const { bool stickersUpdateNeeded(TimeMs now) const {
@ -276,16 +275,16 @@ public:
void registerPhotoView( void registerPhotoView(
not_null<const PhotoData*> photo, not_null<const PhotoData*> photo,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void unregisterPhotoView( void unregisterPhotoView(
not_null<const PhotoData*> photo, not_null<const PhotoData*> photo,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void registerDocumentView( void registerDocumentView(
not_null<const DocumentData*> document, not_null<const DocumentData*> document,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void unregisterDocumentView( void unregisterDocumentView(
not_null<const DocumentData*> document, not_null<const DocumentData*> document,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void registerDocumentItem( void registerDocumentItem(
not_null<const DocumentData*> document, not_null<const DocumentData*> document,
not_null<HistoryItem*> item); not_null<HistoryItem*> item);
@ -294,10 +293,10 @@ public:
not_null<HistoryItem*> item); not_null<HistoryItem*> item);
void registerWebPageView( void registerWebPageView(
not_null<const WebPageData*> page, not_null<const WebPageData*> page,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void unregisterWebPageView( void unregisterWebPageView(
not_null<const WebPageData*> page, not_null<const WebPageData*> page,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void registerWebPageItem( void registerWebPageItem(
not_null<const WebPageData*> page, not_null<const WebPageData*> page,
not_null<HistoryItem*> item); not_null<HistoryItem*> item);
@ -306,16 +305,16 @@ public:
not_null<HistoryItem*> item); not_null<HistoryItem*> item);
void registerGameView( void registerGameView(
not_null<const GameData*> game, not_null<const GameData*> game,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void unregisterGameView( void unregisterGameView(
not_null<const GameData*> game, not_null<const GameData*> game,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void registerContactView( void registerContactView(
UserId contactId, UserId contactId,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void unregisterContactView( void unregisterContactView(
UserId contactId, UserId contactId,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void registerContactItem( void registerContactItem(
UserId contactId, UserId contactId,
not_null<HistoryItem*> item); not_null<HistoryItem*> item);
@ -324,7 +323,7 @@ public:
not_null<HistoryItem*> item); not_null<HistoryItem*> item);
void registerAutoplayAnimation( void registerAutoplayAnimation(
not_null<::Media::Clip::Reader*> reader, not_null<::Media::Clip::Reader*> reader,
not_null<HistoryView::Element*> view); not_null<ViewElement*> view);
void unregisterAutoplayAnimation( void unregisterAutoplayAnimation(
not_null<::Media::Clip::Reader*> reader); not_null<::Media::Clip::Reader*> reader);
@ -439,7 +438,6 @@ private:
base::Observable<void> _pendingHistoryResize; base::Observable<void> _pendingHistoryResize;
base::Observable<ItemVisibilityQuery> _queryItemVisibility; base::Observable<ItemVisibilityQuery> _queryItemVisibility;
rpl::event_stream<IdChange> _itemIdChanges; rpl::event_stream<IdChange> _itemIdChanges;
rpl::event_stream<not_null<const HistoryItem*>> _itemLayoutChanges;
rpl::event_stream<not_null<const ViewElement*>> _viewLayoutChanges; rpl::event_stream<not_null<const ViewElement*>> _viewLayoutChanges;
rpl::event_stream<not_null<const HistoryItem*>> _itemViewRepaintRequest; rpl::event_stream<not_null<const HistoryItem*>> _itemViewRepaintRequest;
rpl::event_stream<not_null<const ViewElement*>> _viewRepaintRequest; rpl::event_stream<not_null<const ViewElement*>> _viewRepaintRequest;
@ -472,7 +470,7 @@ private:
std::unique_ptr<PhotoData>> _photos; std::unique_ptr<PhotoData>> _photos;
std::map< std::map<
not_null<const PhotoData*>, not_null<const PhotoData*>,
base::flat_set<not_null<HistoryView::Element*>>> _photoViews; base::flat_set<not_null<ViewElement*>>> _photoViews;
std::unordered_map< std::unordered_map<
DocumentId, DocumentId,
std::unique_ptr<DocumentData>> _documents; std::unique_ptr<DocumentData>> _documents;
@ -481,7 +479,7 @@ private:
base::flat_set<not_null<HistoryItem*>>> _documentItems; base::flat_set<not_null<HistoryItem*>>> _documentItems;
std::map< std::map<
not_null<const DocumentData*>, not_null<const DocumentData*>,
base::flat_set<not_null<HistoryView::Element*>>> _documentViews; base::flat_set<not_null<ViewElement*>>> _documentViews;
std::unordered_map< std::unordered_map<
WebPageId, WebPageId,
std::unique_ptr<WebPageData>> _webpages; std::unique_ptr<WebPageData>> _webpages;
@ -490,22 +488,22 @@ private:
base::flat_set<not_null<HistoryItem*>>> _webpageItems; base::flat_set<not_null<HistoryItem*>>> _webpageItems;
std::map< std::map<
not_null<const WebPageData*>, not_null<const WebPageData*>,
base::flat_set<not_null<HistoryView::Element*>>> _webpageViews; base::flat_set<not_null<ViewElement*>>> _webpageViews;
std::unordered_map< std::unordered_map<
GameId, GameId,
std::unique_ptr<GameData>> _games; std::unique_ptr<GameData>> _games;
std::map< std::map<
not_null<const GameData*>, not_null<const GameData*>,
base::flat_set<not_null<HistoryView::Element*>>> _gameViews; base::flat_set<not_null<ViewElement*>>> _gameViews;
std::map< std::map<
UserId, UserId,
base::flat_set<not_null<HistoryItem*>>> _contactItems; base::flat_set<not_null<HistoryItem*>>> _contactItems;
std::map< std::map<
UserId, UserId,
base::flat_set<not_null<HistoryView::Element*>>> _contactViews; base::flat_set<not_null<ViewElement*>>> _contactViews;
base::flat_map< base::flat_map<
not_null<::Media::Clip::Reader*>, not_null<::Media::Clip::Reader*>,
not_null<HistoryView::Element*>> _autoplayAnimations; not_null<ViewElement*>> _autoplayAnimations;
base::flat_set<not_null<WebPageData*>> _webpagesUpdated; base::flat_set<not_null<WebPageData*>> _webpagesUpdated;
base::flat_set<not_null<GameData*>> _gamesUpdated; base::flat_set<not_null<GameData*>> _gamesUpdated;
@ -515,7 +513,7 @@ private:
Groups _groups; Groups _groups;
std::map< std::map<
not_null<HistoryItem*>, not_null<HistoryItem*>,
std::vector<not_null<HistoryView::Element*>>> _views; std::vector<not_null<ViewElement*>>> _views;
MessageIdsList _mimeForwardIds; MessageIdsList _mimeForwardIds;

View File

@ -2424,12 +2424,12 @@ void History::clear(bool leaveItems) {
forgetScrollState(); forgetScrollState();
} }
if (leaveItems) { if (leaveItems) {
Auth().data().markHistoryUnloaded(this); Auth().data().notifyHistoryUnloaded(this);
} else { } else {
setLastMessage(nullptr); setLastMessage(nullptr);
notifies.clear(); notifies.clear();
Auth().storage().remove(Storage::SharedMediaRemoveAll(peer->id)); Auth().storage().remove(Storage::SharedMediaRemoveAll(peer->id));
Auth().data().markHistoryCleared(this); Auth().data().notifyHistoryCleared(this);
} }
clearBlocks(leaveItems); clearBlocks(leaveItems);
if (leaveItems) { if (leaveItems) {

View File

@ -338,7 +338,7 @@ void HistoryItem::setRealId(MsgId newId) {
} }
} }
Auth().data().markItemIdChange({ this, oldId }); Auth().data().notifyItemIdChange({ this, oldId });
Auth().data().requestItemViewRepaint(this); Auth().data().requestItemViewRepaint(this);
} }
@ -630,51 +630,6 @@ bool HistoryItem::isEmpty() const {
&& !Has<HistoryMessageLogEntryOriginal>(); && !Has<HistoryMessageLogEntryOriginal>();
} }
void HistoryItem::clipCallback(Media::Clip::Notification notification) {
using namespace Media::Clip;
auto media = this->media();
if (!media) {
return;
}
// #TODO GIFs
//auto reader = media->getClipReader();
//if (!reader) {
// return;
//}
//switch (notification) {
//case NotificationReinit: {
// auto stopped = false;
// if (reader->autoPausedGif()) {
// auto amVisible = false;
// Auth().data().queryItemVisibility().notify({ this, &amVisible }, true);
// if (!amVisible) { // stop animation if it is not visible
// media->stopInline();
// if (auto document = media->getDocument()) { // forget data from memory
// document->forget();
// }
// stopped = true;
// }
// } else if (reader->mode() == Media::Clip::Reader::Mode::Video && reader->state() == Media::Clip::State::Finished) {
// // Stop finished video message.
// media->stopInline();
// }
// if (!stopped) {
// Auth().data().requestItemViewResize(this);
// Auth().data().markItemLayoutChange(this);
// }
//} break;
//case NotificationRepaint: {
// if (!reader->currentDisplayed()) {
// Auth().data().requestItemViewRepaint(this);
// }
//} break;
//}
}
void HistoryItem::audioTrackUpdated() { void HistoryItem::audioTrackUpdated() {
auto media = this->media(); auto media = this->media();
if (!media) { if (!media) {

View File

@ -265,7 +265,6 @@ public:
MessageGroupId groupId() const; MessageGroupId groupId() const;
void clipCallback(Media::Clip::Notification notification);
void audioTrackUpdated(); void audioTrackUpdated();
HistoryItem *previousItem() const; HistoryItem *previousItem() const;

View File

@ -2687,7 +2687,7 @@ bool HistoryGif::playInline(bool autoplay) {
: Mode::Gif; : Mode::Gif;
setClipReader(Media::Clip::MakeReader(_data, _parent->data()->fullId(), [this](Media::Clip::Notification notification) { setClipReader(Media::Clip::MakeReader(_data, _parent->data()->fullId(), [this](Media::Clip::Notification notification) {
// #TODO GIFs // #TODO GIFs
_parent->data()->clipCallback(notification); _parent->clipCallback(notification);
}, mode)); }, mode));
if (mode == Mode::Video) { if (mode == Mode::Video) {
_roundPlayback = std::make_unique<Media::Clip::Playback>(); _roundPlayback = std::make_unique<Media::Clip::Playback>();
@ -2717,7 +2717,7 @@ void HistoryGif::stopInline() {
clearClipReader(); clearClipReader();
Auth().data().requestViewResize(_parent); Auth().data().requestViewResize(_parent);
Auth().data().markViewLayoutChange(_parent); Auth().data().notifyViewLayoutChange(_parent);
} }
void HistoryGif::setClipReader(Media::Clip::ReaderPointer gif) { void HistoryGif::setClipReader(Media::Clip::ReaderPointer gif) {

View File

@ -646,10 +646,10 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
} }
} }
}); });
Auth().data().itemLayoutChanged( Auth().data().viewLayoutChanged(
) | rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto view) {
if (_peer && _list) { if (_peer && _list) {
if (const auto view = item->mainView()) { if (view == view->data()->mainView()) {
if (view->isUnderCursor()) { if (view->isUnderCursor()) {
_list->onUpdateSelected(); _list->onUpdateSelected();
} }
@ -909,7 +909,7 @@ void HistoryWidget::start() {
updateStickersByEmoji(); updateStickersByEmoji();
}, lifetime()); }, lifetime());
updateRecentStickers(); updateRecentStickers();
Auth().data().markSavedGifsUpdated(); Auth().data().notifySavedGifsUpdated();
subscribe(Auth().api().fullPeerUpdated(), [this](PeerData *peer) { subscribe(Auth().api().fullPeerUpdated(), [this](PeerData *peer) {
fullPeerUpdated(peer); fullPeerUpdated(peer);
}); });

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "media/media_clip_reader.h"
#include "history/history_item_components.h" #include "history/history_item_components.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "history/history_media.h" #include "history/history_media.h"
@ -260,6 +261,52 @@ void Element::nextInBlocksChanged() {
setAttachToNext(false); setAttachToNext(false);
} }
void Element::clipCallback(Media::Clip::Notification notification) {
using namespace Media::Clip;
const auto media = this->media();
if (!media) {
return;
}
const auto reader = media->getClipReader();
if (!reader) {
return;
}
switch (notification) {
case NotificationReinit: {
auto stopped = false;
if (reader->autoPausedGif()) {
auto amVisible = false;
Auth().data().queryItemVisibility().notify({ data(), &amVisible }, true);
if (!amVisible) { // stop animation if it is not visible
media->stopInline();
if (const auto document = media->getDocument()) {
document->forget();
}
stopped = true;
}
} else if (reader->mode() == Reader::Mode::Video
&& reader->state() == State::Finished) {
// Stop finished video message.
media->stopInline();
}
if (!stopped) {
Auth().data().requestViewResize(this);
Auth().data().notifyViewLayoutChange(this);
}
} break;
case NotificationRepaint: {
if (!reader->currentDisplayed()) {
Auth().data().requestViewRepaint(this);
}
} break;
}
}
void Element::refreshDataId() { void Element::refreshDataId() {
if (const auto media = this->media()) { if (const auto media = this->media()) {
media->refreshParentId(data()); media->refreshParentId(data());

View File

@ -186,6 +186,8 @@ public:
void previousInBlocksChanged(); void previousInBlocksChanged();
void nextInBlocksChanged(); void nextInBlocksChanged();
void clipCallback(Media::Clip::Notification notification);
virtual ~Element(); virtual ~Element();
protected: protected:

View File

@ -561,10 +561,10 @@ void ListWidget::start() {
ObservableViewer( ObservableViewer(
Auth().downloader().taskFinished() Auth().downloader().taskFinished()
) | rpl::start_with_next([this] { update(); }, lifetime()); ) | rpl::start_with_next([this] { update(); }, lifetime());
Auth().data().itemLayoutChanged( //Auth().data().itemLayoutChanged( // #TODO
) | rpl::start_with_next([this](auto item) { //) | rpl::start_with_next([this](auto item) {
itemLayoutChanged(item); // itemLayoutChanged(item);
}, lifetime()); //}, lifetime());
Auth().data().itemRemoved( Auth().data().itemRemoved(
) | rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
itemRemoved(item); itemRemoved(item);

View File

@ -120,7 +120,7 @@ void DeleteSavedGifClickHandler::onClickImpl() const {
MTP::send(MTPmessages_SaveGif(_data->mtpInput(), MTP_bool(true))); MTP::send(MTPmessages_SaveGif(_data->mtpInput(), MTP_bool(true)));
} }
Auth().data().markSavedGifsUpdated(); Auth().data().notifySavedGifsUpdated();
} }
int Gif::resizeGetHeight(int width) { int Gif::resizeGetHeight(int width) {

View File

@ -5366,7 +5366,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} }
Local::writeInstalledStickers(); Local::writeInstalledStickers();
if (writeArchived) Local::writeArchivedStickers(); if (writeArchived) Local::writeArchivedStickers();
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
} }
} }
@ -5390,7 +5390,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} else { } else {
Auth().data().stickerSetsOrderRef() = std::move(result); Auth().data().stickerSetsOrderRef() = std::move(result);
Local::writeInstalledStickers(); Local::writeInstalledStickers();
Auth().data().markStickersUpdated(); Auth().data().notifyStickersUpdated();
} }
} }
} break; } break;

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "history/history_media.h" #include "history/history_media.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "history/view/history_view_element.h"
#include "media/media_clip_reader.h" #include "media/media_clip_reader.h"
#include "media/view/media_clip_playback.h" #include "media/view/media_clip_playback.h"
#include "media/media_audio.h" #include "media/media_audio.h"
@ -46,7 +47,10 @@ Float::Float(
prepareShadow(); prepareShadow();
rpl::merge( rpl::merge(
Auth().data().itemLayoutChanged(), //Auth().data().viewLayoutChanged(
//) | rpl::map(
// [](auto view) { return view->data(); }
//),
Auth().data().itemViewRepaintRequest() Auth().data().itemViewRepaintRequest()
) | rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
if (_item == item) { if (_item == item) {