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