mirror of https://github.com/procxx/kepka.git
Improve phrases for loading / empty filters.
This commit is contained in:
parent
f0322cd107
commit
ad8b0387f3
|
@ -250,6 +250,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_dlg_new_channel_name" = "Channel name";
|
||||
"lng_no_contacts" = "You have no contacts";
|
||||
"lng_no_chats" = "Your chats will be here";
|
||||
"lng_no_chats_filter" = "No chats currently match this folder.";
|
||||
"lng_contacts_loading" = "Loading...";
|
||||
"lng_contacts_not_found" = "No contacts found";
|
||||
"lng_dlg_search_for_messages" = "Search for messages";
|
||||
|
|
|
@ -498,11 +498,16 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
|||
p.fillRect(dialogsClip, st::dialogsBg);
|
||||
p.setFont(st::noContactsFont);
|
||||
p.setPen(st::noContactsColor);
|
||||
const auto phrase = _filterId
|
||||
? (session().data().chatsList()->loaded()
|
||||
? tr::lng_no_chats_filter(tr::now)
|
||||
: tr::lng_contacts_loading(tr::now))
|
||||
: session().data().contactsLoaded().current()
|
||||
? tr::lng_no_chats(tr::now)
|
||||
: tr::lng_contacts_loading(tr::now);
|
||||
p.drawText(
|
||||
QRect(0, 0, fullWidth, st::noContactsHeight - (session().data().contactsLoaded().current() ? st::noContactsFont->height : 0)),
|
||||
(session().data().contactsLoaded().current()
|
||||
? tr::lng_no_chats
|
||||
: tr::lng_contacts_loading)(tr::now),
|
||||
phrase,
|
||||
style::al_center);
|
||||
}
|
||||
} else if (_state == WidgetState::Filtered) {
|
||||
|
@ -1198,6 +1203,7 @@ bool InnerWidget::updateReorderPinned(QPoint localPosition) {
|
|||
return false;
|
||||
}
|
||||
|
||||
const auto list = shownDialogs();
|
||||
auto yaddWas = _pinnedRows[_draggingIndex].yadd.current();
|
||||
auto shift = 0;
|
||||
auto now = crl::now();
|
||||
|
@ -1206,7 +1212,7 @@ bool InnerWidget::updateReorderPinned(QPoint localPosition) {
|
|||
shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex);
|
||||
|
||||
for (auto from = _draggingIndex, to = _draggingIndex + shift; from > to; --from) {
|
||||
shownDialogs()->movePinned(_dragging, -1);
|
||||
list->movePinned(_dragging, -1);
|
||||
std::swap(_pinnedRows[from], _pinnedRows[from - 1]);
|
||||
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() - rowHeight, 0);
|
||||
_pinnedRows[from].animStartTime = now;
|
||||
|
@ -1215,7 +1221,7 @@ bool InnerWidget::updateReorderPinned(QPoint localPosition) {
|
|||
shift = floorclamp(localPosition.y() - _dragStart.y() + (rowHeight / 2), rowHeight, 0, pinnedCount - _draggingIndex - 1);
|
||||
|
||||
for (auto from = _draggingIndex, to = _draggingIndex + shift; from < to; ++from) {
|
||||
shownDialogs()->movePinned(_dragging, 1);
|
||||
list->movePinned(_dragging, 1);
|
||||
std::swap(_pinnedRows[from], _pinnedRows[from + 1]);
|
||||
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() + rowHeight, 0);
|
||||
_pinnedRows[from].animStartTime = now;
|
||||
|
@ -2184,21 +2190,19 @@ void InnerWidget::refresh(bool toTop) {
|
|||
if (needCollapsedRowsRefresh()) {
|
||||
return refreshWithCollapsedRows(toTop);
|
||||
}
|
||||
const auto list = shownDialogs();
|
||||
_addContactLnk->setVisible(!_filterId
|
||||
&& (_state == WidgetState::Default)
|
||||
&& list->empty()
|
||||
&& session().data().contactsLoaded().current());
|
||||
auto h = 0;
|
||||
if (_state == WidgetState::Default) {
|
||||
if (shownDialogs()->empty()) {
|
||||
if (list->empty()) {
|
||||
h = st::noContactsHeight;
|
||||
if (session().data().contactsLoaded().current()) {
|
||||
if (_addContactLnk->isHidden()) _addContactLnk->show();
|
||||
} else {
|
||||
if (!_addContactLnk->isHidden()) _addContactLnk->hide();
|
||||
}
|
||||
} else {
|
||||
h = dialogsOffset() + shownDialogs()->size() * st::dialogsRowHeight;
|
||||
if (!_addContactLnk->isHidden()) _addContactLnk->hide();
|
||||
h = dialogsOffset() + list->size() * st::dialogsRowHeight;
|
||||
}
|
||||
} else if (_state == WidgetState::Filtered) {
|
||||
if (!_addContactLnk->isHidden()) _addContactLnk->hide();
|
||||
if (_waitingForSearch) {
|
||||
h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight) + ((_searchResults.empty() && !_searchInChat) ? -st::searchedBarHeight : 0);
|
||||
} else {
|
||||
|
@ -2556,7 +2560,6 @@ void InnerWidget::switchToFilter(FilterId filterId) {
|
|||
stopReorderPinned();
|
||||
_filterId = filterId;
|
||||
refreshWithCollapsedRows(true);
|
||||
_collapsedSelected = 0;
|
||||
}
|
||||
|
||||
bool InnerWidget::chooseHashtag() {
|
||||
|
|
|
@ -141,6 +141,7 @@ SessionController::SessionController(
|
|||
|
||||
session->data().chatsFilters().changed(
|
||||
) | rpl::start_with_next([=] {
|
||||
checkOpenedFilter();
|
||||
crl::on_main(session, [=] {
|
||||
refreshFiltersMenu();
|
||||
});
|
||||
|
@ -226,6 +227,16 @@ rpl::producer<> SessionController::filtersMenuChanged() const {
|
|||
return _filtersMenuChanged.events();
|
||||
}
|
||||
|
||||
void SessionController::checkOpenedFilter() {
|
||||
if (const auto filterId = activeChatsFilterCurrent()) {
|
||||
const auto &list = session().data().chatsFilters().list();
|
||||
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
|
||||
if (i == end(list)) {
|
||||
setActiveChatsFilter(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SessionController::uniqueChatsInSearchResults() const {
|
||||
return session().supportMode()
|
||||
&& !session().settings().supportAllSearchResults()
|
||||
|
|
|
@ -299,7 +299,6 @@ public:
|
|||
void setActiveChatsFilter(FilterId id);
|
||||
|
||||
void toggleFiltersMenu(bool enabled);
|
||||
void refreshFiltersMenu();
|
||||
[[nodiscard]] rpl::producer<> filtersMenuChanged() const;
|
||||
|
||||
rpl::lifetime &lifetime() {
|
||||
|
@ -311,6 +310,8 @@ public:
|
|||
private:
|
||||
void init();
|
||||
void initSupportMode();
|
||||
void refreshFiltersMenu();
|
||||
void checkOpenedFilter();
|
||||
|
||||
int minimalThreeColumnWidth() const;
|
||||
not_null<MainWidget*> chats() const;
|
||||
|
|
Loading…
Reference in New Issue