Skip to content

Commit

Permalink
Fix story mention text updating.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jul 20, 2023
1 parent 150957a commit 68fa3e3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
12 changes: 10 additions & 2 deletions Telegram/SourceFiles/data/data_media_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ FullStoryId Media::storyId() const {
return {};
}

bool Media::storyExpired() const {
bool Media::storyExpired(bool revalidate) {
return false;
}

Expand Down Expand Up @@ -2033,7 +2033,15 @@ FullStoryId MediaStory::storyId() const {
return _storyId;
}

bool MediaStory::storyExpired() const {
bool MediaStory::storyExpired(bool revalidate) {
if (revalidate) {
const auto stories = &parent()->history()->owner().stories();
if (const auto maybeStory = stories->lookup(_storyId)) {
_expired = false;
} else if (maybeStory.error() == Data::NoStory::Deleted) {
_expired = true;
}
}
return _expired;
}

Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/data/data_media_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Media {
virtual PollData *poll() const;
virtual const WallPaper *paper() const;
virtual FullStoryId storyId() const;
virtual bool storyExpired() const;
virtual bool storyExpired(bool revalidate = false);
virtual bool storyMention() const;

virtual bool uploading() const;
Expand Down Expand Up @@ -580,7 +580,7 @@ class MediaStory final : public Media, public base::has_weak_ptr {
std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override;

FullStoryId storyId() const override;
bool storyExpired() const override;
bool storyExpired(bool revalidate = false) override;
bool storyMention() const override;

TextWithEntities notificationText() const override;
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/data/data_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3917,6 +3917,11 @@ void Session::refreshStoryItemViews(FullStoryId id) {
const auto i = _storyItems.find(id);
if (i != _storyItems.end()) {
for (const auto item : i->second) {
if (const auto media = item->media()) {
if (media->storyMention()) {
item->updateStoryMentionText();
}
}
requestItemViewRefresh(item);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/history/history_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4825,7 +4825,7 @@ PreparedServiceText HistoryItem::prepareStoryMentionText() {
auto result = PreparedServiceText();
const auto peer = history()->peer;
result.links.push_back(peer->createOpenLink());
const auto phrase = (this->media() && this->media()->storyExpired())
const auto phrase = (this->media() && this->media()->storyExpired(true))
? (out()
? tr::lng_action_story_mention_me_unavailable
: tr::lng_action_story_mention_unavailable)
Expand Down

0 comments on commit 68fa3e3

Please sign in to comment.