Fix story mention text updating.

This commit is contained in:
John Preston 2023-07-20 20:49:46 +04:00
parent 150957abcd
commit 68fa3e36d7
4 changed files with 18 additions and 5 deletions

View file

@ -412,7 +412,7 @@ FullStoryId Media::storyId() const {
return {}; return {};
} }
bool Media::storyExpired() const { bool Media::storyExpired(bool revalidate) {
return false; return false;
} }
@ -2033,7 +2033,15 @@ FullStoryId MediaStory::storyId() const {
return _storyId; 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; return _expired;
} }

View file

@ -114,7 +114,7 @@ public:
virtual PollData *poll() const; virtual PollData *poll() const;
virtual const WallPaper *paper() const; virtual const WallPaper *paper() const;
virtual FullStoryId storyId() const; virtual FullStoryId storyId() const;
virtual bool storyExpired() const; virtual bool storyExpired(bool revalidate = false);
virtual bool storyMention() const; virtual bool storyMention() const;
virtual bool uploading() const; virtual bool uploading() const;
@ -580,7 +580,7 @@ public:
std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override; std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override;
FullStoryId storyId() const override; FullStoryId storyId() const override;
bool storyExpired() const override; bool storyExpired(bool revalidate = false) override;
bool storyMention() const override; bool storyMention() const override;
TextWithEntities notificationText() const override; TextWithEntities notificationText() const override;

View file

@ -3917,6 +3917,11 @@ void Session::refreshStoryItemViews(FullStoryId id) {
const auto i = _storyItems.find(id); const auto i = _storyItems.find(id);
if (i != _storyItems.end()) { if (i != _storyItems.end()) {
for (const auto item : i->second) { for (const auto item : i->second) {
if (const auto media = item->media()) {
if (media->storyMention()) {
item->updateStoryMentionText();
}
}
requestItemViewRefresh(item); requestItemViewRefresh(item);
} }
} }

View file

@ -4825,7 +4825,7 @@ PreparedServiceText HistoryItem::prepareStoryMentionText() {
auto result = PreparedServiceText(); auto result = PreparedServiceText();
const auto peer = history()->peer; const auto peer = history()->peer;
result.links.push_back(peer->createOpenLink()); result.links.push_back(peer->createOpenLink());
const auto phrase = (this->media() && this->media()->storyExpired()) const auto phrase = (this->media() && this->media()->storyExpired(true))
? (out() ? (out()
? tr::lng_action_story_mention_me_unavailable ? tr::lng_action_story_mention_me_unavailable
: tr::lng_action_story_mention_unavailable) : tr::lng_action_story_mention_unavailable)