2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

Added grouping of album files into a single notification.

- Added display of "Album" in inDialogsText().
This commit is contained in:
23rd
2019-03-03 12:32:01 +03:00
committed by John Preston
parent f48d8538c0
commit 2a935868a8
3 changed files with 31 additions and 21 deletions

View File

@@ -307,12 +307,14 @@ void System::showNext() {
_waitTimer.callOnce(next - ms);
break;
} else {
auto forwardedItem = notifyItem->Has<HistoryMessageForwarded>() ? notifyItem : nullptr; // forwarded notify grouping
auto forwardedCount = 1;
const auto isForwarded = notifyItem->Has<HistoryMessageForwarded>();
const auto isAlbum = notifyItem->groupId();
auto ms = crl::now();
auto history = notifyItem->history();
auto j = _whenMaps.find(history);
auto groupedItem = (isForwarded || isAlbum) ? notifyItem : nullptr; // forwarded and album notify grouping
auto forwardedCount = isForwarded ? 1 : 0;
const auto history = notifyItem->history();
const auto j = _whenMaps.find(history);
if (j == _whenMaps.cend()) {
history->clearNotifications();
} else {
@@ -323,9 +325,9 @@ void System::showNext() {
break;
}
j.value().remove((forwardedItem ? forwardedItem : notifyItem)->id);
j.value().remove((groupedItem ? groupedItem : notifyItem)->id);
do {
auto k = j.value().constFind(history->currentNotification()->id);
const auto k = j.value().constFind(history->currentNotification()->id);
if (k != j.value().cend()) {
nextNotify = history->currentNotification();
_waiters.insert(notifyHistory, Waiter(k.key(), k.value(), 0));
@@ -334,19 +336,26 @@ void System::showNext() {
history->skipNotification();
} while (history->hasNotification());
if (nextNotify) {
if (forwardedItem) {
auto nextForwarded = nextNotify->Has<HistoryMessageForwarded>() ? nextNotify : nullptr;
if (nextForwarded
&& forwardedItem->author() == nextForwarded->author()
&& qAbs(int64(nextForwarded->date()) - int64(forwardedItem->date())) < 2) {
forwardedItem = nextForwarded;
++forwardedCount;
} else {
nextNotify = nullptr;
if (groupedItem) {
const auto canNextBeGrouped = (isForwarded && nextNotify->Has<HistoryMessageForwarded>())
|| (isAlbum && nextNotify->groupId());
const auto nextItem = canNextBeGrouped ? nextNotify : nullptr;
if (nextItem
&& qAbs(int64(nextItem->date()) - int64(groupedItem->date())) < 2) {
if (isForwarded
&& groupedItem->author() == nextItem->author()) {
++forwardedCount;
groupedItem = nextItem;
continue;
}
if (isAlbum
&& groupedItem->groupId() == nextItem->groupId()) {
groupedItem = nextItem;
continue;
}
}
} else {
nextNotify = nullptr;
}
nextNotify = nullptr;
}
} while (nextNotify);
}
@@ -464,7 +473,7 @@ void NativeManager::doShowNotification(HistoryItem *item, int forwardedCount) {
const auto text = options.hideMessageText
? lang(lng_notification_preview)
: (forwardedCount < 2
? item->notificationText()
? (item->groupId() ? lang(lng_in_dlg_album) : item->notificationText())
: lng_forward_messages(lt_count, forwardedCount));
doShowNativeNotification(