mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-22 18:27:17 +00:00
Improve pending rating info.
This commit is contained in:
parent
667822ca08
commit
0bbfe20089
@ -1878,8 +1878,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
"lng_stars_rating_title" = "Rating";
|
"lng_stars_rating_title" = "Rating";
|
||||||
"lng_stars_rating_future" = "Future Rating";
|
"lng_stars_rating_future" = "Future Rating";
|
||||||
"lng_stars_rating_pending#one" = "The rating updates in 21 days after purchases.\n{count} point is pending. {link}";
|
"lng_stars_rating_updates#one" = "in {count} day";
|
||||||
"lng_stars_rating_pending#other" = "The rating updates in 21 days after purchases.\n{count} points are pending. {link}";
|
"lng_stars_rating_updates#other" = "in {count} days";
|
||||||
|
"lng_stars_rating_pending#one" = "The rating will update {when}.\n{count} point is pending. {link}";
|
||||||
|
"lng_stars_rating_pending#other" = "The rating will update {when}.\n{count} points are pending. {link}";
|
||||||
"lng_stars_rating_pending_preview" = "Preview {arrow}";
|
"lng_stars_rating_pending_preview" = "Preview {arrow}";
|
||||||
"lng_stars_rating_pending_back" = "Back {arrow}";
|
"lng_stars_rating_pending_back" = "Back {arrow}";
|
||||||
"lng_stars_rating_negative_label" = "Negative Rating";
|
"lng_stars_rating_negative_label" = "Negative Rating";
|
||||||
|
@ -154,6 +154,7 @@ ListWidget::ListWidget(
|
|||||||
_provider->type(),
|
_provider->type(),
|
||||||
[=] { scrollDateCheck(); },
|
[=] { scrollDateCheck(); },
|
||||||
[=] { scrollDateHide(); }))
|
[=] { scrollDateHide(); }))
|
||||||
|
, _selectedLimit(MaxSelectedItems)
|
||||||
, _storiesAddToAlbumId(controller->storiesAddToAlbumId())
|
, _storiesAddToAlbumId(controller->storiesAddToAlbumId())
|
||||||
, _hiddenMark(std::make_unique<StickerPremiumMark>(
|
, _hiddenMark(std::make_unique<StickerPremiumMark>(
|
||||||
&_controller->session(),
|
&_controller->session(),
|
||||||
@ -275,6 +276,7 @@ void ListWidget::setupStoriesTrackIds() {
|
|||||||
}
|
}
|
||||||
const auto peerId = _controller->storiesPeer()->id;
|
const auto peerId = _controller->storiesPeer()->id;
|
||||||
const auto stories = &session().data().stories();
|
const auto stories = &session().data().stories();
|
||||||
|
|
||||||
constexpr auto kArchive = Data::kStoriesAlbumIdArchive;
|
constexpr auto kArchive = Data::kStoriesAlbumIdArchive;
|
||||||
const auto key = Data::StoryAlbumIdsKey{ peerId, kArchive };
|
const auto key = Data::StoryAlbumIdsKey{ peerId, kArchive };
|
||||||
rpl::single(rpl::empty) | rpl::then(
|
rpl::single(rpl::empty) | rpl::then(
|
||||||
@ -302,6 +304,32 @@ void ListWidget::setupStoriesTrackIds() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
if (!stories->albumIdsCountKnown(peerId, _storiesAddToAlbumId)) {
|
||||||
|
stories->albumIdsLoadMore(peerId, _storiesAddToAlbumId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto akey = Data::StoryAlbumIdsKey{ peerId, _storiesAddToAlbumId };
|
||||||
|
rpl::single(rpl::empty) | rpl::then(
|
||||||
|
stories->albumIdsChanged() | rpl::filter(
|
||||||
|
rpl::mappers::_1 == akey
|
||||||
|
) | rpl::to_empty
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
_storiesAddToAlbumTotal = stories->albumIdsCount(
|
||||||
|
peerId,
|
||||||
|
_storiesAddToAlbumId);
|
||||||
|
|
||||||
|
const auto albumId = _storiesAddToAlbumId;
|
||||||
|
const auto &ids = stories->albumKnownInArchive(peerId, albumId);
|
||||||
|
const auto loadedCount = int(ids.size());
|
||||||
|
const auto total = std::max(_storiesAddToAlbumTotal, loadedCount);
|
||||||
|
const auto nonLoadedInAlbum = total - loadedCount;
|
||||||
|
|
||||||
|
const auto appConfig = &_controller->session().appConfig();
|
||||||
|
const auto totalLimit = appConfig->storiesAlbumLimit();
|
||||||
|
|
||||||
|
_selectedLimit = std::max(totalLimit - nonLoadedInAlbum, 0);
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> ListWidget::scrollToRequests() const {
|
rpl::producer<int> ListWidget::scrollToRequests() const {
|
||||||
@ -603,8 +631,6 @@ void ListWidget::markStoryMsgsSelected() {
|
|||||||
pushSelectedItems();
|
pushSelectedItems();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const auto &appConfig = _controller->session().appConfig();
|
|
||||||
const auto selectLimit = appConfig.storiesAlbumLimit();
|
|
||||||
const auto selection = FullSelection;
|
const auto selection = FullSelection;
|
||||||
for (const auto §ion : _sections) {
|
for (const auto §ion : _sections) {
|
||||||
for (const auto &entry : section.items()) {
|
for (const auto &entry : section.items()) {
|
||||||
@ -616,7 +642,7 @@ void ListWidget::markStoryMsgsSelected() {
|
|||||||
_selected,
|
_selected,
|
||||||
item,
|
item,
|
||||||
_provider->computeSelectionData(item, selection),
|
_provider->computeSelectionData(item, selection),
|
||||||
selectLimit);
|
_selectedLimit);
|
||||||
repaintItem(item);
|
repaintItem(item);
|
||||||
_storyMsgsToMarkSelected.erase(i);
|
_storyMsgsToMarkSelected.erase(i);
|
||||||
if (_storyMsgsToMarkSelected.empty()) {
|
if (_storyMsgsToMarkSelected.empty()) {
|
||||||
@ -1263,7 +1289,7 @@ void ListWidget::showContextMenu(
|
|||||||
crl::guard(this, [=] {
|
crl::guard(this, [=] {
|
||||||
if (hasSelectedText()) {
|
if (hasSelectedText()) {
|
||||||
clearSelected();
|
clearSelected();
|
||||||
} else if (_selected.size() == MaxSelectedItems) {
|
} else if (_selected.size() == _selectedLimit) {
|
||||||
return;
|
return;
|
||||||
} else if (_selected.empty()) {
|
} else if (_selected.empty()) {
|
||||||
update();
|
update();
|
||||||
@ -1583,15 +1609,12 @@ void ListWidget::switchToWordSelection() {
|
|||||||
void ListWidget::applyItemSelection(
|
void ListWidget::applyItemSelection(
|
||||||
HistoryItem *item,
|
HistoryItem *item,
|
||||||
TextSelection selection) {
|
TextSelection selection) {
|
||||||
const auto selectLimit = _storiesAddToAlbumId
|
|
||||||
? _controller->session().appConfig().storiesAlbumLimit()
|
|
||||||
: MaxSelectedItems;
|
|
||||||
if (item
|
if (item
|
||||||
&& ChangeItemSelection(
|
&& ChangeItemSelection(
|
||||||
_selected,
|
_selected,
|
||||||
item,
|
item,
|
||||||
_provider->computeSelectionData(item, selection),
|
_provider->computeSelectionData(item, selection),
|
||||||
selectLimit)) {
|
_selectedLimit)) {
|
||||||
repaintItem(item);
|
repaintItem(item);
|
||||||
pushSelectedItems();
|
pushSelectedItems();
|
||||||
}
|
}
|
||||||
@ -2133,15 +2156,12 @@ void ListWidget::applyDragSelection() {
|
|||||||
|
|
||||||
void ListWidget::applyDragSelection(SelectedMap &applyTo) const {
|
void ListWidget::applyDragSelection(SelectedMap &applyTo) const {
|
||||||
if (_dragSelectAction == DragSelectAction::Selecting) {
|
if (_dragSelectAction == DragSelectAction::Selecting) {
|
||||||
const auto selectLimit = _storiesAddToAlbumId
|
|
||||||
? _controller->session().appConfig().storiesAlbumLimit()
|
|
||||||
: MaxSelectedItems;
|
|
||||||
for (auto &[item, data] : _dragSelected) {
|
for (auto &[item, data] : _dragSelected) {
|
||||||
ChangeItemSelection(
|
ChangeItemSelection(
|
||||||
applyTo,
|
applyTo,
|
||||||
item,
|
item,
|
||||||
_provider->computeSelectionData(item, FullSelection),
|
_provider->computeSelectionData(item, FullSelection),
|
||||||
selectLimit);
|
_selectedLimit);
|
||||||
}
|
}
|
||||||
} else if (_dragSelectAction == DragSelectAction::Deselecting) {
|
} else if (_dragSelectAction == DragSelectAction::Deselecting) {
|
||||||
for (auto &[item, data] : _dragSelected) {
|
for (auto &[item, data] : _dragSelected) {
|
||||||
|
@ -310,7 +310,9 @@ private:
|
|||||||
|
|
||||||
const std::unique_ptr<DateBadge> _dateBadge;
|
const std::unique_ptr<DateBadge> _dateBadge;
|
||||||
|
|
||||||
|
int _selectedLimit = 0;
|
||||||
int _storiesAddToAlbumId = 0;
|
int _storiesAddToAlbumId = 0;
|
||||||
|
int _storiesAddToAlbumTotal = 0;
|
||||||
base::flat_set<StoryId> _storiesInAlbum;
|
base::flat_set<StoryId> _storiesInAlbum;
|
||||||
base::flat_set<MsgId> _storyMsgsToMarkSelected;
|
base::flat_set<MsgId> _storyMsgsToMarkSelected;
|
||||||
std::unique_ptr<StickerPremiumMark> _hiddenMark;
|
std::unique_ptr<StickerPremiumMark> _hiddenMark;
|
||||||
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
*/
|
*/
|
||||||
#include "ui/controls/stars_rating.h"
|
#include "ui/controls/stars_rating.h"
|
||||||
|
|
||||||
|
#include "base/unixtime.h"
|
||||||
#include "info/profile/info_profile_icon.h"
|
#include "info/profile/info_profile_icon.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/effects/premium_bubble.h"
|
#include "ui/effects/premium_bubble.h"
|
||||||
@ -335,23 +336,19 @@ void AboutRatingBox(
|
|||||||
object_ptr<Ui::FlatLabel>(box, std::move(title), st::infoStarsTitle),
|
object_ptr<Ui::FlatLabel>(box, std::move(title), st::infoStarsTitle),
|
||||||
st::boxRowPadding + QMargins(0, st::boostTitleSkip / 2, 0, 0));
|
st::boxRowPadding + QMargins(0, st::boostTitleSkip / 2, 0, 0));
|
||||||
|
|
||||||
AssertIsDebug();
|
|
||||||
pending = {
|
|
||||||
.value = {
|
|
||||||
.level = 10,
|
|
||||||
.stars = 100,
|
|
||||||
.thisLevelStars = 90,
|
|
||||||
.nextLevelStars = 110,
|
|
||||||
},
|
|
||||||
.date = 86400,
|
|
||||||
};
|
|
||||||
if (pending) {
|
if (pending) {
|
||||||
|
const auto now = base::unixtime::now();
|
||||||
|
const auto days = std::max((pending.date - now + 43200) / 86400, 1);
|
||||||
auto text = state->pending.value(
|
auto text = state->pending.value(
|
||||||
) | rpl::map([=](bool value) {
|
) | rpl::map([=](bool value) {
|
||||||
return tr::lng_stars_rating_pending(
|
return tr::lng_stars_rating_pending(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count_decimal,
|
lt_count_decimal,
|
||||||
pending.value.stars - data.stars,
|
pending.value.stars - data.stars,
|
||||||
|
lt_when,
|
||||||
|
TextWithEntities{
|
||||||
|
tr::lng_stars_rating_updates(tr::now, lt_count, days),
|
||||||
|
},
|
||||||
lt_link,
|
lt_link,
|
||||||
Ui::Text::Link((value
|
Ui::Text::Link((value
|
||||||
? tr::lng_stars_rating_pending_back
|
? tr::lng_stars_rating_pending_back
|
||||||
|
Loading…
x
Reference in New Issue
Block a user