mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve typing status sending.
This commit is contained in:
parent
53c308c24b
commit
48dad5f477
2 changed files with 29 additions and 12 deletions
|
@ -152,7 +152,14 @@ bool SendProgressManager::skipRequest(const Key &key) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const auto recently = base::unixtime::now() - kSendTypingsToOfflineFor;
|
const auto recently = base::unixtime::now() - kSendTypingsToOfflineFor;
|
||||||
return !Data::OnlineTextActive(user->onlineTill, recently);
|
const auto online = user->onlineTill;
|
||||||
|
if (online == -2) { // last seen recently
|
||||||
|
return false;
|
||||||
|
} else if (online < 0) {
|
||||||
|
return (-online < recently);
|
||||||
|
} else {
|
||||||
|
return (online < recently);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendProgressManager::done(
|
void SendProgressManager::done(
|
||||||
|
|
|
@ -39,10 +39,16 @@ namespace {
|
||||||
constexpr int kRecentlyInSeconds = 20 * 3600;
|
constexpr int kRecentlyInSeconds = 20 * 3600;
|
||||||
const auto kPsaBadgePrefix = "cloud_lng_badge_psa_";
|
const auto kPsaBadgePrefix = "cloud_lng_badge_psa_";
|
||||||
|
|
||||||
bool ShowUserBotIcon(not_null<UserData*> user) {
|
[[nodiscard]] bool ShowUserBotIcon(not_null<UserData*> user) {
|
||||||
return user->isBot() && !user->isSupport() && !user->isRepliesChat();
|
return user->isBot() && !user->isSupport() && !user->isRepliesChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool ShowSendActionInDialogs(History *history) {
|
||||||
|
return history
|
||||||
|
&& (!history->peer->isUser()
|
||||||
|
|| history->peer->asUser()->onlineTill > 0);
|
||||||
|
}
|
||||||
|
|
||||||
void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool active, bool selected) {
|
void PaintRowTopRight(Painter &p, const QString &text, QRect &rectForName, bool active, bool selected) {
|
||||||
const auto width = st::dialogsDateFont->width(text);
|
const auto width = st::dialogsDateFont->width(text);
|
||||||
rectForName.setWidth(rectForName.width() - width - st::dialogsDateSkip);
|
rectForName.setWidth(rectForName.width() - width - st::dialogsDateSkip);
|
||||||
|
@ -362,7 +368,8 @@ void paintRow(
|
||||||
|
|
||||||
p.setFont(st::dialogsTextFont);
|
p.setFont(st::dialogsTextFont);
|
||||||
auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
|
auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
|
||||||
if (history && !history->sendActionPainter()->paint(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
|
if (ShowSendActionInDialogs(history)
|
||||||
|
&& !history->sendActionPainter()->paint(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
|
||||||
if (history->cloudDraftTextCache.isEmpty()) {
|
if (history->cloudDraftTextCache.isEmpty()) {
|
||||||
auto draftWrapped = textcmdLink(1, tr::lng_dialogs_text_from_wrapped(tr::now, lt_from, tr::lng_from_draft(tr::now)));
|
auto draftWrapped = textcmdLink(1, tr::lng_dialogs_text_from_wrapped(tr::now, lt_from, tr::lng_from_draft(tr::now)));
|
||||||
auto draftText = supportMode
|
auto draftText = supportMode
|
||||||
|
@ -389,7 +396,8 @@ void paintRow(
|
||||||
|
|
||||||
auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
|
auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
|
||||||
p.setFont(st::dialogsTextFont);
|
p.setFont(st::dialogsTextFont);
|
||||||
if (history && !history->sendActionPainter()->paint(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
|
if (ShowSendActionInDialogs(history)
|
||||||
|
&& !history->sendActionPainter()->paint(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
|
||||||
// Empty history
|
// Empty history
|
||||||
}
|
}
|
||||||
} else if (!item->isEmpty()) {
|
} else if (!item->isEmpty()) {
|
||||||
|
@ -741,14 +749,16 @@ void RowPainter::paint(
|
||||||
texttop,
|
texttop,
|
||||||
availableWidth,
|
availableWidth,
|
||||||
st::dialogsTextFont->height);
|
st::dialogsTextFont->height);
|
||||||
const auto actionWasPainted = history ? history->sendActionPainter()->paint(
|
const auto actionWasPainted = ShowSendActionInDialogs(history)
|
||||||
p,
|
? history->sendActionPainter()->paint(
|
||||||
itemRect.x(),
|
p,
|
||||||
itemRect.y(),
|
itemRect.x(),
|
||||||
itemRect.width(),
|
itemRect.y(),
|
||||||
fullWidth,
|
itemRect.width(),
|
||||||
color,
|
fullWidth,
|
||||||
ms) : false;
|
color,
|
||||||
|
ms)
|
||||||
|
: false;
|
||||||
if (const auto folder = row->folder()) {
|
if (const auto folder = row->folder()) {
|
||||||
PaintListEntryText(p, itemRect, active, selected, row);
|
PaintListEntryText(p, itemRect, active, selected, row);
|
||||||
} else if (!actionWasPainted) {
|
} else if (!actionWasPainted) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue