mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Apply editions in realtime, show badge.
This commit is contained in:
parent
ee507722ba
commit
12fe0a836a
8 changed files with 54 additions and 6 deletions
|
@ -260,6 +260,10 @@ bool Story::forbidsForward() const {
|
||||||
return _noForwards;
|
return _noForwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Story::edited() const {
|
||||||
|
return _edited;
|
||||||
|
}
|
||||||
|
|
||||||
bool Story::canDownload() const {
|
bool Story::canDownload() const {
|
||||||
return !forbidsForward() || _peer->isSelf();
|
return !forbidsForward() || _peer->isSelf();
|
||||||
}
|
}
|
||||||
|
@ -369,6 +373,7 @@ void Story::applyViewsSlice(
|
||||||
|
|
||||||
bool Story::applyChanges(StoryMedia media, const MTPDstoryItem &data) {
|
bool Story::applyChanges(StoryMedia media, const MTPDstoryItem &data) {
|
||||||
const auto pinned = data.is_pinned();
|
const auto pinned = data.is_pinned();
|
||||||
|
const auto edited = data.is_edited();
|
||||||
const auto isPublic = data.is_public();
|
const auto isPublic = data.is_public();
|
||||||
const auto closeFriends = data.is_close_friends();
|
const auto closeFriends = data.is_close_friends();
|
||||||
const auto noForwards = data.is_noforwards();
|
const auto noForwards = data.is_noforwards();
|
||||||
|
@ -395,6 +400,7 @@ bool Story::applyChanges(StoryMedia media, const MTPDstoryItem &data) {
|
||||||
|
|
||||||
const auto changed = (_media != media)
|
const auto changed = (_media != media)
|
||||||
|| (_pinned != pinned)
|
|| (_pinned != pinned)
|
||||||
|
|| (_edited != edited)
|
||||||
|| (_isPublic != isPublic)
|
|| (_isPublic != isPublic)
|
||||||
|| (_closeFriends != closeFriends)
|
|| (_closeFriends != closeFriends)
|
||||||
|| (_noForwards != noForwards)
|
|| (_noForwards != noForwards)
|
||||||
|
@ -405,6 +411,7 @@ bool Story::applyChanges(StoryMedia media, const MTPDstoryItem &data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_media = std::move(media);
|
_media = std::move(media);
|
||||||
|
_edited = edited;
|
||||||
_pinned = pinned;
|
_pinned = pinned;
|
||||||
_isPublic = isPublic;
|
_isPublic = isPublic;
|
||||||
_closeFriends = closeFriends;
|
_closeFriends = closeFriends;
|
||||||
|
|
|
@ -89,6 +89,7 @@ public:
|
||||||
[[nodiscard]] bool isPublic() const;
|
[[nodiscard]] bool isPublic() const;
|
||||||
[[nodiscard]] bool closeFriends() const;
|
[[nodiscard]] bool closeFriends() const;
|
||||||
[[nodiscard]] bool forbidsForward() const;
|
[[nodiscard]] bool forbidsForward() const;
|
||||||
|
[[nodiscard]] bool edited() const;
|
||||||
|
|
||||||
[[nodiscard]] bool canDownload() const;
|
[[nodiscard]] bool canDownload() const;
|
||||||
[[nodiscard]] bool canShare() const;
|
[[nodiscard]] bool canShare() const;
|
||||||
|
@ -128,6 +129,7 @@ private:
|
||||||
bool _isPublic : 1 = false;
|
bool _isPublic : 1 = false;
|
||||||
bool _closeFriends : 1 = false;
|
bool _closeFriends : 1 = false;
|
||||||
bool _noForwards : 1 = false;
|
bool _noForwards : 1 = false;
|
||||||
|
bool _edited : 1 = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -741,20 +741,24 @@ void Controller::show(
|
||||||
_slider->raise();
|
_slider->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_shown == storyId) {
|
_captionText = story->caption();
|
||||||
|
_captionFullView = nullptr;
|
||||||
|
_header->show({
|
||||||
|
.user = user,
|
||||||
|
.date = story->date(),
|
||||||
|
.edited = story->edited(),
|
||||||
|
});
|
||||||
|
if (_shown == storyId && _session == &story->session()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_shown = storyId;
|
_shown = storyId;
|
||||||
_viewed = false;
|
_viewed = false;
|
||||||
_captionText = story->caption();
|
|
||||||
_captionFullView = nullptr;
|
|
||||||
invalidate_weak_ptrs(&_viewsLoadGuard);
|
invalidate_weak_ptrs(&_viewsLoadGuard);
|
||||||
_reactions->hide();
|
_reactions->hide();
|
||||||
if (_replyFocused) {
|
if (_replyFocused) {
|
||||||
unfocusReply();
|
unfocusReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
_header->show({ .user = user, .date = story->date() });
|
|
||||||
_replyArea->show({
|
_replyArea->show({
|
||||||
.user = unsupported ? nullptr : user,
|
.user = unsupported ? nullptr : user,
|
||||||
.id = story->id(),
|
.id = story->id(),
|
||||||
|
@ -781,6 +785,14 @@ void Controller::show(
|
||||||
checkWaitingFor();
|
checkWaitingFor();
|
||||||
}
|
}
|
||||||
}, _sessionLifetime);
|
}, _sessionLifetime);
|
||||||
|
session->changes().storyUpdates(
|
||||||
|
Data::StoryUpdate::Flag::Edited
|
||||||
|
) | rpl::filter([=](const Data::StoryUpdate &update) {
|
||||||
|
return (update.story == this->story());
|
||||||
|
}) | rpl::start_with_next([=](const Data::StoryUpdate &update) {
|
||||||
|
show(update.story, _context);
|
||||||
|
_delegate->storiesRedisplay(update.story);
|
||||||
|
}, _sessionLifetime);
|
||||||
_sessionLifetime.add([=] {
|
_sessionLifetime.add([=] {
|
||||||
session->data().stories().setPreloadingInViewer({});
|
session->data().stories().setPreloadingInViewer({});
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@ struct FileChosen;
|
||||||
} // namespace ChatHelpers
|
} // namespace ChatHelpers
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
class Story;
|
||||||
struct StoriesContext;
|
struct StoriesContext;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ public:
|
||||||
-> rpl::producer<ChatHelpers::FileChosen> = 0;
|
-> rpl::producer<ChatHelpers::FileChosen> = 0;
|
||||||
[[nodiscard]] virtual auto storiesCachedReactionIconFactory()
|
[[nodiscard]] virtual auto storiesCachedReactionIconFactory()
|
||||||
-> HistoryView::Reactions::CachedIconFactory & = 0;
|
-> HistoryView::Reactions::CachedIconFactory & = 0;
|
||||||
|
virtual void storiesRedisplay(not_null<Data::Story*> story) = 0;
|
||||||
virtual void storiesJumpTo(
|
virtual void storiesJumpTo(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
FullStoryId id,
|
FullStoryId id,
|
||||||
|
|
|
@ -75,6 +75,15 @@ struct Timestamp {
|
||||||
return { Ui::FormatDateTime(whenFull) };
|
return { Ui::FormatDateTime(whenFull) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] Timestamp ComposeDetails(HeaderData data, TimeId now) {
|
||||||
|
auto result = ComposeTimestamp(data.date, now);
|
||||||
|
if (data.edited) {
|
||||||
|
result.text.append(
|
||||||
|
QString::fromUtf8(" \xE2\x80\xA2 ") + tr::lng_edited(tr::now));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Header::Header(not_null<Controller*> controller)
|
Header::Header(not_null<Controller*> controller)
|
||||||
|
@ -123,7 +132,7 @@ void Header::show(HeaderData data) {
|
||||||
raw->setGeometry(layout.header);
|
raw->setGeometry(layout.header);
|
||||||
}, raw->lifetime());
|
}, raw->lifetime());
|
||||||
}
|
}
|
||||||
auto timestamp = ComposeTimestamp(data.date, base::unixtime::now());
|
auto timestamp = ComposeDetails(data, base::unixtime::now());
|
||||||
_date = std::make_unique<Ui::FlatLabel>(
|
_date = std::make_unique<Ui::FlatLabel>(
|
||||||
_widget.get(),
|
_widget.get(),
|
||||||
std::move(timestamp.text),
|
std::move(timestamp.text),
|
||||||
|
@ -148,7 +157,7 @@ void Header::updateDateText() {
|
||||||
if (!_date || !_data || !_data->date) {
|
if (!_date || !_data || !_data->date) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto timestamp = ComposeTimestamp(_data->date, base::unixtime::now());
|
auto timestamp = ComposeDetails(*_data, base::unixtime::now());
|
||||||
_date->setText(timestamp.text);
|
_date->setText(timestamp.text);
|
||||||
if (timestamp.changes > 0) {
|
if (timestamp.changes > 0) {
|
||||||
_dateUpdateTimer.callOnce(timestamp.changes * crl::time(1000));
|
_dateUpdateTimer.callOnce(timestamp.changes * crl::time(1000));
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Controller;
|
||||||
struct HeaderData {
|
struct HeaderData {
|
||||||
not_null<UserData*> user;
|
not_null<UserData*> user;
|
||||||
TimeId date = 0;
|
TimeId date = 0;
|
||||||
|
bool edited = false;
|
||||||
|
|
||||||
friend inline auto operator<=>(HeaderData, HeaderData) = default;
|
friend inline auto operator<=>(HeaderData, HeaderData) = default;
|
||||||
friend inline bool operator==(HeaderData, HeaderData) = default;
|
friend inline bool operator==(HeaderData, HeaderData) = default;
|
||||||
|
|
|
@ -4167,6 +4167,20 @@ void OverlayWidget::storiesJumpTo(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OverlayWidget::storiesRedisplay(not_null<Data::Story*> story) {
|
||||||
|
Expects(_stories != nullptr);
|
||||||
|
|
||||||
|
clearStreaming();
|
||||||
|
_streamingStartPaused = false;
|
||||||
|
v::match(story->media().data, [&](not_null<PhotoData*> photo) {
|
||||||
|
displayPhoto(photo, anim::activation::background);
|
||||||
|
}, [&](not_null<DocumentData*> document) {
|
||||||
|
displayDocument(document, anim::activation::background);
|
||||||
|
}, [&](v::null_t) {
|
||||||
|
displayDocument(nullptr, anim::activation::background);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void OverlayWidget::storiesClose() {
|
void OverlayWidget::storiesClose() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,6 +250,7 @@ private:
|
||||||
-> rpl::producer<ChatHelpers::FileChosen> override;
|
-> rpl::producer<ChatHelpers::FileChosen> override;
|
||||||
auto storiesCachedReactionIconFactory()
|
auto storiesCachedReactionIconFactory()
|
||||||
-> HistoryView::Reactions::CachedIconFactory & override;
|
-> HistoryView::Reactions::CachedIconFactory & override;
|
||||||
|
void storiesRedisplay(not_null<Data::Story*> story) override;
|
||||||
void storiesJumpTo(
|
void storiesJumpTo(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
FullStoryId id,
|
FullStoryId id,
|
||||||
|
|
Loading…
Add table
Reference in a new issue