Skip to content

Commit 0bbfe20

Browse files
committed
Improve pending rating info.
1 parent 667822c commit 0bbfe20

File tree

4 files changed

+45
-24
lines changed

4 files changed

+45
-24
lines changed

Telegram/Resources/langs/lang.strings

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,8 +1878,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
18781878

18791879
"lng_stars_rating_title" = "Rating";
18801880
"lng_stars_rating_future" = "Future Rating";
1881-
"lng_stars_rating_pending#one" = "The rating updates in 21 days after purchases.\n{count} point is pending. {link}";
1882-
"lng_stars_rating_pending#other" = "The rating updates in 21 days after purchases.\n{count} points are pending. {link}";
1881+
"lng_stars_rating_updates#one" = "in {count} day";
1882+
"lng_stars_rating_updates#other" = "in {count} days";
1883+
"lng_stars_rating_pending#one" = "The rating will update {when}.\n{count} point is pending. {link}";
1884+
"lng_stars_rating_pending#other" = "The rating will update {when}.\n{count} points are pending. {link}";
18831885
"lng_stars_rating_pending_preview" = "Preview {arrow}";
18841886
"lng_stars_rating_pending_back" = "Back {arrow}";
18851887
"lng_stars_rating_negative_label" = "Negative Rating";

Telegram/SourceFiles/info/media/info_media_list_widget.cpp

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ ListWidget::ListWidget(
154154
_provider->type(),
155155
[=] { scrollDateCheck(); },
156156
[=] { scrollDateHide(); }))
157+
, _selectedLimit(MaxSelectedItems)
157158
, _storiesAddToAlbumId(controller->storiesAddToAlbumId())
158159
, _hiddenMark(std::make_unique<StickerPremiumMark>(
159160
&_controller->session(),
@@ -275,6 +276,7 @@ void ListWidget::setupStoriesTrackIds() {
275276
}
276277
const auto peerId = _controller->storiesPeer()->id;
277278
const auto stories = &session().data().stories();
279+
278280
constexpr auto kArchive = Data::kStoriesAlbumIdArchive;
279281
const auto key = Data::StoryAlbumIdsKey{ peerId, kArchive };
280282
rpl::single(rpl::empty) | rpl::then(
@@ -302,6 +304,32 @@ void ListWidget::setupStoriesTrackIds() {
302304
}
303305
}
304306
}, lifetime());
307+
308+
if (!stories->albumIdsCountKnown(peerId, _storiesAddToAlbumId)) {
309+
stories->albumIdsLoadMore(peerId, _storiesAddToAlbumId);
310+
}
311+
312+
const auto akey = Data::StoryAlbumIdsKey{ peerId, _storiesAddToAlbumId };
313+
rpl::single(rpl::empty) | rpl::then(
314+
stories->albumIdsChanged() | rpl::filter(
315+
rpl::mappers::_1 == akey
316+
) | rpl::to_empty
317+
) | rpl::start_with_next([=] {
318+
_storiesAddToAlbumTotal = stories->albumIdsCount(
319+
peerId,
320+
_storiesAddToAlbumId);
321+
322+
const auto albumId = _storiesAddToAlbumId;
323+
const auto &ids = stories->albumKnownInArchive(peerId, albumId);
324+
const auto loadedCount = int(ids.size());
325+
const auto total = std::max(_storiesAddToAlbumTotal, loadedCount);
326+
const auto nonLoadedInAlbum = total - loadedCount;
327+
328+
const auto appConfig = &_controller->session().appConfig();
329+
const auto totalLimit = appConfig->storiesAlbumLimit();
330+
331+
_selectedLimit = std::max(totalLimit - nonLoadedInAlbum, 0);
332+
}, lifetime());
305333
}
306334

307335
rpl::producer<int> ListWidget::scrollToRequests() const {
@@ -603,8 +631,6 @@ void ListWidget::markStoryMsgsSelected() {
603631
pushSelectedItems();
604632
}
605633
});
606-
const auto &appConfig = _controller->session().appConfig();
607-
const auto selectLimit = appConfig.storiesAlbumLimit();
608634
const auto selection = FullSelection;
609635
for (const auto &section : _sections) {
610636
for (const auto &entry : section.items()) {
@@ -616,7 +642,7 @@ void ListWidget::markStoryMsgsSelected() {
616642
_selected,
617643
item,
618644
_provider->computeSelectionData(item, selection),
619-
selectLimit);
645+
_selectedLimit);
620646
repaintItem(item);
621647
_storyMsgsToMarkSelected.erase(i);
622648
if (_storyMsgsToMarkSelected.empty()) {
@@ -1263,7 +1289,7 @@ void ListWidget::showContextMenu(
12631289
crl::guard(this, [=] {
12641290
if (hasSelectedText()) {
12651291
clearSelected();
1266-
} else if (_selected.size() == MaxSelectedItems) {
1292+
} else if (_selected.size() == _selectedLimit) {
12671293
return;
12681294
} else if (_selected.empty()) {
12691295
update();
@@ -1583,15 +1609,12 @@ void ListWidget::switchToWordSelection() {
15831609
void ListWidget::applyItemSelection(
15841610
HistoryItem *item,
15851611
TextSelection selection) {
1586-
const auto selectLimit = _storiesAddToAlbumId
1587-
? _controller->session().appConfig().storiesAlbumLimit()
1588-
: MaxSelectedItems;
15891612
if (item
15901613
&& ChangeItemSelection(
15911614
_selected,
15921615
item,
15931616
_provider->computeSelectionData(item, selection),
1594-
selectLimit)) {
1617+
_selectedLimit)) {
15951618
repaintItem(item);
15961619
pushSelectedItems();
15971620
}
@@ -2133,15 +2156,12 @@ void ListWidget::applyDragSelection() {
21332156

21342157
void ListWidget::applyDragSelection(SelectedMap &applyTo) const {
21352158
if (_dragSelectAction == DragSelectAction::Selecting) {
2136-
const auto selectLimit = _storiesAddToAlbumId
2137-
? _controller->session().appConfig().storiesAlbumLimit()
2138-
: MaxSelectedItems;
21392159
for (auto &[item, data] : _dragSelected) {
21402160
ChangeItemSelection(
21412161
applyTo,
21422162
item,
21432163
_provider->computeSelectionData(item, FullSelection),
2144-
selectLimit);
2164+
_selectedLimit);
21452165
}
21462166
} else if (_dragSelectAction == DragSelectAction::Deselecting) {
21472167
for (auto &[item, data] : _dragSelected) {

Telegram/SourceFiles/info/media/info_media_list_widget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ class ListWidget final
310310

311311
const std::unique_ptr<DateBadge> _dateBadge;
312312

313+
int _selectedLimit = 0;
313314
int _storiesAddToAlbumId = 0;
315+
int _storiesAddToAlbumTotal = 0;
314316
base::flat_set<StoryId> _storiesInAlbum;
315317
base::flat_set<MsgId> _storyMsgsToMarkSelected;
316318
std::unique_ptr<StickerPremiumMark> _hiddenMark;

Telegram/SourceFiles/ui/controls/stars_rating.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ For license and copyright information please follow this link:
77
*/
88
#include "ui/controls/stars_rating.h"
99

10+
#include "base/unixtime.h"
1011
#include "info/profile/info_profile_icon.h"
1112
#include "lang/lang_keys.h"
1213
#include "ui/effects/premium_bubble.h"
@@ -335,23 +336,19 @@ void AboutRatingBox(
335336
object_ptr<Ui::FlatLabel>(box, std::move(title), st::infoStarsTitle),
336337
st::boxRowPadding + QMargins(0, st::boostTitleSkip / 2, 0, 0));
337338

338-
AssertIsDebug();
339-
pending = {
340-
.value = {
341-
.level = 10,
342-
.stars = 100,
343-
.thisLevelStars = 90,
344-
.nextLevelStars = 110,
345-
},
346-
.date = 86400,
347-
};
348339
if (pending) {
340+
const auto now = base::unixtime::now();
341+
const auto days = std::max((pending.date - now + 43200) / 86400, 1);
349342
auto text = state->pending.value(
350343
) | rpl::map([=](bool value) {
351344
return tr::lng_stars_rating_pending(
352345
tr::now,
353346
lt_count_decimal,
354347
pending.value.stars - data.stars,
348+
lt_when,
349+
TextWithEntities{
350+
tr::lng_stars_rating_updates(tr::now, lt_count, days),
351+
},
355352
lt_link,
356353
Ui::Text::Link((value
357354
? tr::lng_stars_rating_pending_back

0 commit comments

Comments
 (0)