mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Rename Story::pinned to Story::inProfile.
This commit is contained in:
parent
df16e7c00b
commit
d33e3dc13a
10 changed files with 59 additions and 51 deletions
|
@ -340,7 +340,7 @@ void Stories::clearArchive(not_null<PeerData*> peer) {
|
||||||
_archive.erase(i);
|
_archive.erase(i);
|
||||||
for (const auto &id : archive.ids.list) {
|
for (const auto &id : archive.ids.list) {
|
||||||
if (const auto story = lookup({ peerId, id })) {
|
if (const auto story = lookup({ peerId, id })) {
|
||||||
if ((*story)->expired() && !(*story)->pinned()) {
|
if ((*story)->expired() && !(*story)->inProfile()) {
|
||||||
applyDeleted(peer, id);
|
applyDeleted(peer, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,8 +558,8 @@ void Stories::unregisterDependentMessage(
|
||||||
void Stories::savedStateChanged(not_null<Story*> story) {
|
void Stories::savedStateChanged(not_null<Story*> story) {
|
||||||
const auto id = story->id();
|
const auto id = story->id();
|
||||||
const auto peer = story->peer()->id;
|
const auto peer = story->peer()->id;
|
||||||
const auto pinned = story->pinned();
|
const auto inProfile = story->inProfile();
|
||||||
if (pinned) {
|
if (inProfile) {
|
||||||
auto &saved = _saved[peer];
|
auto &saved = _saved[peer];
|
||||||
const auto added = saved.ids.list.emplace(id).second;
|
const auto added = saved.ids.list.emplace(id).second;
|
||||||
if (added) {
|
if (added) {
|
||||||
|
@ -794,7 +794,7 @@ void Stories::applyDeleted(not_null<PeerData*> peer, StoryId id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (story->pinned()) {
|
if (story->inProfile()) {
|
||||||
if (const auto k = _saved.find(peerId); k != end(_saved)) {
|
if (const auto k = _saved.find(peerId); k != end(_saved)) {
|
||||||
const auto saved = &k->second;
|
const auto saved = &k->second;
|
||||||
if (saved->ids.list.remove(id)) {
|
if (saved->ids.list.remove(id)) {
|
||||||
|
@ -832,7 +832,7 @@ void Stories::applyDeleted(not_null<PeerData*> peer, StoryId id) {
|
||||||
void Stories::applyExpired(FullStoryId id) {
|
void Stories::applyExpired(FullStoryId id) {
|
||||||
if (const auto maybeStory = lookup(id)) {
|
if (const auto maybeStory = lookup(id)) {
|
||||||
const auto story = *maybeStory;
|
const auto story = *maybeStory;
|
||||||
if (!hasArchive(story->peer()) && !story->pinned()) {
|
if (!hasArchive(story->peer()) && !story->inProfile()) {
|
||||||
applyDeleted(story->peer(), id.story);
|
applyDeleted(story->peer(), id.story);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1099,7 +1099,7 @@ void Stories::markAsRead(FullStoryId id, bool viewed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto story = *maybeStory;
|
const auto story = *maybeStory;
|
||||||
if (story->expired() && story->pinned()) {
|
if (story->expired() && story->inProfile()) {
|
||||||
_incrementViewsPending[id.peer].emplace(id.story);
|
_incrementViewsPending[id.peer].emplace(id.story);
|
||||||
if (!_incrementViewsTimer.isActive()) {
|
if (!_incrementViewsTimer.isActive()) {
|
||||||
_incrementViewsTimer.callOnce(kIncrementViewsDelay);
|
_incrementViewsTimer.callOnce(kIncrementViewsDelay);
|
||||||
|
@ -1724,9 +1724,9 @@ void Stories::deleteList(const std::vector<FullStoryId> &ids) {
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stories::togglePinnedList(
|
void Stories::toggleInProfileList(
|
||||||
const std::vector<FullStoryId> &ids,
|
const std::vector<FullStoryId> &ids,
|
||||||
bool pinned) {
|
bool inProfile) {
|
||||||
if (ids.empty()) {
|
if (ids.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1745,7 +1745,7 @@ void Stories::togglePinnedList(
|
||||||
api->request(MTPstories_TogglePinned(
|
api->request(MTPstories_TogglePinned(
|
||||||
peer->input,
|
peer->input,
|
||||||
MTP_vector<MTPint>(list),
|
MTP_vector<MTPint>(list),
|
||||||
MTP_bool(pinned)
|
MTP_bool(inProfile)
|
||||||
)).done([=](const MTPVector<MTPint> &result) {
|
)).done([=](const MTPVector<MTPint> &result) {
|
||||||
const auto peerId = peer->id;
|
const auto peerId = peer->id;
|
||||||
auto &saved = _saved[peerId];
|
auto &saved = _saved[peerId];
|
||||||
|
@ -1759,8 +1759,8 @@ void Stories::togglePinnedList(
|
||||||
for (const auto &id : result.v) {
|
for (const auto &id : result.v) {
|
||||||
if (const auto maybeStory = lookup({ peerId, id.v })) {
|
if (const auto maybeStory = lookup({ peerId, id.v })) {
|
||||||
const auto story = *maybeStory;
|
const auto story = *maybeStory;
|
||||||
story->setPinned(pinned);
|
story->setInProfile(inProfile);
|
||||||
if (pinned) {
|
if (inProfile) {
|
||||||
const auto add = loaded || (id.v >= lastId);
|
const auto add = loaded || (id.v >= lastId);
|
||||||
if (!add) {
|
if (!add) {
|
||||||
dirty = true;
|
dirty = true;
|
||||||
|
|
|
@ -131,7 +131,7 @@ public:
|
||||||
explicit Stories(not_null<Session*> owner);
|
explicit Stories(not_null<Session*> owner);
|
||||||
~Stories();
|
~Stories();
|
||||||
|
|
||||||
static constexpr auto kPinnedToastDuration = 4 * crl::time(1000);
|
static constexpr auto kInProfileToastDuration = 4 * crl::time(1000);
|
||||||
|
|
||||||
[[nodiscard]] Session &owner() const;
|
[[nodiscard]] Session &owner() const;
|
||||||
[[nodiscard]] Main::Session &session() const;
|
[[nodiscard]] Main::Session &session() const;
|
||||||
|
@ -205,7 +205,9 @@ public:
|
||||||
void savedLoadMore(PeerId peerId);
|
void savedLoadMore(PeerId peerId);
|
||||||
|
|
||||||
void deleteList(const std::vector<FullStoryId> &ids);
|
void deleteList(const std::vector<FullStoryId> &ids);
|
||||||
void togglePinnedList(const std::vector<FullStoryId> &ids, bool pinned);
|
void toggleInProfileList(
|
||||||
|
const std::vector<FullStoryId> &ids,
|
||||||
|
bool inProfile);
|
||||||
void report(
|
void report(
|
||||||
std::shared_ptr<Ui::Show> show,
|
std::shared_ptr<Ui::Show> show,
|
||||||
FullStoryId id,
|
FullStoryId id,
|
||||||
|
|
|
@ -389,12 +389,12 @@ TextWithEntities Story::inReplyText() const {
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Story::setPinned(bool pinned) {
|
void Story::setInProfile(bool value) {
|
||||||
_pinned = pinned;
|
_inProfile = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::pinned() const {
|
bool Story::inProfile() const {
|
||||||
return _pinned;
|
return _inProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
StoryPrivacy Story::privacy() const {
|
StoryPrivacy Story::privacy() const {
|
||||||
|
@ -431,7 +431,9 @@ bool Story::canDownloadChecked() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::canShare() const {
|
bool Story::canShare() const {
|
||||||
return _privacyPublic && !forbidsForward() && (pinned() || !expired());
|
return _privacyPublic
|
||||||
|
&& !forbidsForward()
|
||||||
|
&& (inProfile() || !expired());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::canDelete() const {
|
bool Story::canDelete() const {
|
||||||
|
@ -447,7 +449,7 @@ bool Story::canReport() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Story::hasDirectLink() const {
|
bool Story::hasDirectLink() const {
|
||||||
if (!_privacyPublic || (!_pinned && expired())) {
|
if (!_privacyPublic || (!_inProfile && expired())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !_peer->username().isEmpty();
|
return !_peer->username().isEmpty();
|
||||||
|
@ -707,7 +709,7 @@ void Story::applyFields(
|
||||||
: data.vsent_reaction()
|
: data.vsent_reaction()
|
||||||
? Data::ReactionFromMTP(*data.vsent_reaction())
|
? Data::ReactionFromMTP(*data.vsent_reaction())
|
||||||
: Data::ReactionId();
|
: Data::ReactionId();
|
||||||
const auto pinned = data.is_pinned();
|
const auto inProfile = data.is_pinned();
|
||||||
const auto edited = data.is_edited();
|
const auto edited = data.is_edited();
|
||||||
const auto privacy = data.is_public()
|
const auto privacy = data.is_public()
|
||||||
? StoryPrivacy::Public
|
? StoryPrivacy::Public
|
||||||
|
@ -767,7 +769,7 @@ void Story::applyFields(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto pinnedChanged = (_pinned != pinned);
|
const auto inProfileChanged = (_inProfile != inProfile);
|
||||||
const auto editedChanged = (_edited != edited);
|
const auto editedChanged = (_edited != edited);
|
||||||
const auto mediaChanged = (_media != media);
|
const auto mediaChanged = (_media != media);
|
||||||
const auto captionChanged = (_caption != caption);
|
const auto captionChanged = (_caption != caption);
|
||||||
|
@ -783,7 +785,7 @@ void Story::applyFields(
|
||||||
_privacyContacts = (privacy == StoryPrivacy::Contacts);
|
_privacyContacts = (privacy == StoryPrivacy::Contacts);
|
||||||
_privacySelectedContacts = (privacy == StoryPrivacy::SelectedContacts);
|
_privacySelectedContacts = (privacy == StoryPrivacy::SelectedContacts);
|
||||||
_edited = edited;
|
_edited = edited;
|
||||||
_pinned = pinned;
|
_inProfile = inProfile;
|
||||||
_noForwards = noForwards;
|
_noForwards = noForwards;
|
||||||
if (mediaChanged) {
|
if (mediaChanged) {
|
||||||
_media = std::move(media);
|
_media = std::move(media);
|
||||||
|
@ -823,7 +825,7 @@ void Story::applyFields(
|
||||||
}
|
}
|
||||||
_peer->owner().refreshStoryItemViews(fullId());
|
_peer->owner().refreshStoryItemViews(fullId());
|
||||||
}
|
}
|
||||||
if (pinnedChanged) {
|
if (inProfileChanged) {
|
||||||
_peer->owner().stories().savedStateChanged(this);
|
_peer->owner().stories().savedStateChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,8 +153,8 @@ public:
|
||||||
[[nodiscard]] Image *replyPreview() const;
|
[[nodiscard]] Image *replyPreview() const;
|
||||||
[[nodiscard]] TextWithEntities inReplyText() const;
|
[[nodiscard]] TextWithEntities inReplyText() const;
|
||||||
|
|
||||||
void setPinned(bool pinned);
|
void setInProfile(bool value);
|
||||||
[[nodiscard]] bool pinned() const;
|
[[nodiscard]] bool inProfile() const;
|
||||||
[[nodiscard]] StoryPrivacy privacy() const;
|
[[nodiscard]] StoryPrivacy privacy() const;
|
||||||
[[nodiscard]] bool forbidsForward() const;
|
[[nodiscard]] bool forbidsForward() const;
|
||||||
[[nodiscard]] bool edited() const;
|
[[nodiscard]] bool edited() const;
|
||||||
|
@ -250,7 +250,7 @@ private:
|
||||||
const TimeId _expires = 0;
|
const TimeId _expires = 0;
|
||||||
TimeId _lastUpdateTime = 0;
|
TimeId _lastUpdateTime = 0;
|
||||||
bool _out : 1 = false;
|
bool _out : 1 = false;
|
||||||
bool _pinned : 1 = false;
|
bool _inProfile : 1 = false;
|
||||||
bool _privacyPublic : 1 = false;
|
bool _privacyPublic : 1 = false;
|
||||||
bool _privacyCloseFriends : 1 = false;
|
bool _privacyCloseFriends : 1 = false;
|
||||||
bool _privacyContacts : 1 = false;
|
bool _privacyContacts : 1 = false;
|
||||||
|
|
|
@ -1213,26 +1213,28 @@ void ListWidget::toggleStoryPin(
|
||||||
}
|
}
|
||||||
const auto channel = peerIsChannel(list.front().peer);
|
const auto channel = peerIsChannel(list.front().peer);
|
||||||
const auto count = int(list.size());
|
const auto count = int(list.size());
|
||||||
const auto pin = (_controller->storiesTab() == Stories::Tab::Archive);
|
const auto toProfile = (_controller->storiesTab() == Stories::Tab::Archive);
|
||||||
const auto controller = _controller;
|
const auto controller = _controller;
|
||||||
const auto sure = [=](Fn<void()> close) {
|
const auto sure = [=](Fn<void()> close) {
|
||||||
using namespace ::Media::Stories;
|
using namespace ::Media::Stories;
|
||||||
controller->session().data().stories().togglePinnedList(list, pin);
|
controller->session().data().stories().toggleInProfileList(
|
||||||
|
list,
|
||||||
|
toProfile);
|
||||||
controller->showToast(
|
controller->showToast(
|
||||||
PrepareTogglePinnedToast(channel, count, pin));
|
PrepareToggleInProfileToast(channel, count, toProfile));
|
||||||
close();
|
close();
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
confirmed();
|
confirmed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const auto onePhrase = pin
|
const auto onePhrase = toProfile
|
||||||
? (channel
|
? (channel
|
||||||
? tr::lng_stories_channel_save_sure
|
? tr::lng_stories_channel_save_sure
|
||||||
: tr::lng_stories_save_sure)
|
: tr::lng_stories_save_sure)
|
||||||
: (channel
|
: (channel
|
||||||
? tr::lng_stories_channel_archive_sure
|
? tr::lng_stories_channel_archive_sure
|
||||||
: tr::lng_stories_archive_sure);
|
: tr::lng_stories_archive_sure);
|
||||||
const auto manyPhrase = pin
|
const auto manyPhrase = toProfile
|
||||||
? (channel
|
? (channel
|
||||||
? tr::lng_stories_channel_save_sure_many
|
? tr::lng_stories_channel_save_sure_many
|
||||||
: tr::lng_stories_save_sure_many)
|
: tr::lng_stories_save_sure_many)
|
||||||
|
|
|
@ -1696,17 +1696,19 @@ void Controller::reportRequested() {
|
||||||
ReportRequested(uiShow(), _shown, &st::storiesReportBox);
|
ReportRequested(uiShow(), _shown, &st::storiesReportBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::togglePinnedRequested(bool pinned) {
|
void Controller::toggleInProfileRequested(bool inProfile) {
|
||||||
const auto story = this->story();
|
const auto story = this->story();
|
||||||
if (!story || !story->peer()->isSelf()) {
|
if (!story || !story->peer()->isSelf()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!pinned && v::is<Data::StoriesContextSaved>(_context.data)) {
|
if (!inProfile && v::is<Data::StoriesContextSaved>(_context.data)) {
|
||||||
moveFromShown();
|
moveFromShown();
|
||||||
}
|
}
|
||||||
story->owner().stories().togglePinnedList({ story->fullId() }, pinned);
|
story->owner().stories().toggleInProfileList(
|
||||||
|
{ story->fullId() },
|
||||||
|
inProfile);
|
||||||
const auto channel = story->peer()->isChannel();
|
const auto channel = story->peer()->isChannel();
|
||||||
uiShow()->showToast(PrepareTogglePinnedToast(channel, 1, pinned));
|
uiShow()->showToast(PrepareToggleInProfileToast(channel, 1, inProfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::moveFromShown() {
|
void Controller::moveFromShown() {
|
||||||
|
@ -1757,12 +1759,12 @@ void Controller::updatePowerSaveBlocker(const Player::TrackState &state) {
|
||||||
[=] { return _wrap->window()->windowHandle(); });
|
[=] { return _wrap->window()->windowHandle(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::Toast::Config PrepareTogglePinnedToast(
|
Ui::Toast::Config PrepareToggleInProfileToast(
|
||||||
bool channel,
|
bool channel,
|
||||||
int count,
|
int count,
|
||||||
bool pinned) {
|
bool inProfile) {
|
||||||
return {
|
return {
|
||||||
.text = (pinned
|
.text = (inProfile
|
||||||
? (count == 1
|
? (count == 1
|
||||||
? (channel
|
? (channel
|
||||||
? tr::lng_stories_channel_save_done
|
? tr::lng_stories_channel_save_done
|
||||||
|
@ -1793,8 +1795,8 @@ Ui::Toast::Config PrepareTogglePinnedToast(
|
||||||
count,
|
count,
|
||||||
Ui::Text::WithEntities))),
|
Ui::Text::WithEntities))),
|
||||||
.st = &st::storiesActionToast,
|
.st = &st::storiesActionToast,
|
||||||
.duration = (pinned
|
.duration = (inProfile
|
||||||
? Data::Stories::kPinnedToastDuration
|
? Data::Stories::kInProfileToastDuration
|
||||||
: Ui::Toast::kDefaultDuration),
|
: Ui::Toast::kDefaultDuration),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ public:
|
||||||
void shareRequested();
|
void shareRequested();
|
||||||
void deleteRequested();
|
void deleteRequested();
|
||||||
void reportRequested();
|
void reportRequested();
|
||||||
void togglePinnedRequested(bool pinned);
|
void toggleInProfileRequested(bool inProfile);
|
||||||
|
|
||||||
[[nodiscard]] bool ignoreWindowMove(QPoint position) const;
|
[[nodiscard]] bool ignoreWindowMove(QPoint position) const;
|
||||||
void tryProcessKeyInput(not_null<QKeyEvent*> e);
|
void tryProcessKeyInput(not_null<QKeyEvent*> e);
|
||||||
|
@ -328,10 +328,10 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] Ui::Toast::Config PrepareTogglePinnedToast(
|
[[nodiscard]] Ui::Toast::Config PrepareToggleInProfileToast(
|
||||||
bool channel,
|
bool channel,
|
||||||
int count,
|
int count,
|
||||||
bool pinned);
|
bool inProfile);
|
||||||
void ReportRequested(
|
void ReportRequested(
|
||||||
std::shared_ptr<Main::SessionShow> show,
|
std::shared_ptr<Main::SessionShow> show,
|
||||||
FullStoryId id,
|
FullStoryId id,
|
||||||
|
|
|
@ -103,8 +103,8 @@ void View::reportRequested() {
|
||||||
_controller->reportRequested();
|
_controller->reportRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::togglePinnedRequested(bool pinned) {
|
void View::toggleInProfileRequested(bool inProfile) {
|
||||||
_controller->togglePinnedRequested(pinned);
|
_controller->toggleInProfileRequested(inProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool View::ignoreWindowMove(QPoint position) const {
|
bool View::ignoreWindowMove(QPoint position) const {
|
||||||
|
|
|
@ -112,7 +112,7 @@ public:
|
||||||
void shareRequested();
|
void shareRequested();
|
||||||
void deleteRequested();
|
void deleteRequested();
|
||||||
void reportRequested();
|
void reportRequested();
|
||||||
void togglePinnedRequested(bool pinned);
|
void toggleInProfileRequested(bool inProfile);
|
||||||
|
|
||||||
[[nodiscard]] bool ignoreWindowMove(QPoint position) const;
|
[[nodiscard]] bool ignoreWindowMove(QPoint position) const;
|
||||||
void tryProcessKeyInput(not_null<QKeyEvent*> e);
|
void tryProcessKeyInput(not_null<QKeyEvent*> e);
|
||||||
|
|
|
@ -1498,17 +1498,17 @@ void OverlayWidget::fillContextMenuActions(const MenuCallback &addAction) {
|
||||||
&st::mediaMenuIconShowInChat);
|
&st::mediaMenuIconShowInChat);
|
||||||
}
|
}
|
||||||
if (story && story->peer()->isSelf()) {
|
if (story && story->peer()->isSelf()) {
|
||||||
const auto pinned = story->pinned();
|
const auto inProfile = story->inProfile();
|
||||||
const auto text = pinned
|
const auto text = inProfile
|
||||||
? tr::lng_mediaview_archive_story(tr::now)
|
? tr::lng_mediaview_archive_story(tr::now)
|
||||||
: tr::lng_mediaview_save_to_profile(tr::now);
|
: tr::lng_mediaview_save_to_profile(tr::now);
|
||||||
addAction(text, [=] {
|
addAction(text, [=] {
|
||||||
if (_stories) {
|
if (_stories) {
|
||||||
_stories->togglePinnedRequested(!pinned);
|
_stories->toggleInProfileRequested(!inProfile);
|
||||||
}
|
}
|
||||||
}, pinned
|
}, (inProfile
|
||||||
? &st::mediaMenuIconArchiveStory
|
? &st::mediaMenuIconArchiveStory
|
||||||
: &st::mediaMenuIconSaveStory);
|
: &st::mediaMenuIconSaveStory));
|
||||||
}
|
}
|
||||||
if ((!story || story->canDownloadChecked())
|
if ((!story || story->canDownloadChecked())
|
||||||
&& _document
|
&& _document
|
||||||
|
|
Loading…
Add table
Reference in a new issue