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