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

@ -301,14 +301,12 @@ QString MediaPhoto::notificationText() const {
return WithCaptionNotificationText( return WithCaptionNotificationText(
lang(lng_in_dlg_photo), lang(lng_in_dlg_photo),
parent()->originalText().text); parent()->originalText().text);
//return WithCaptionNotificationText(lang(lng_in_dlg_album), _caption);
} }
QString MediaPhoto::chatListText() const { QString MediaPhoto::chatListText() const {
return WithCaptionDialogsText( return WithCaptionDialogsText(
lang(lng_in_dlg_photo), lang(lng_in_dlg_photo),
parent()->originalText().text); parent()->originalText().text);
//return WithCaptionDialogsText(lang(lng_in_dlg_album), _caption);
} }
QString MediaPhoto::pinnedTextSubstring() const { QString MediaPhoto::pinnedTextSubstring() const {

View File

@ -706,6 +706,9 @@ QString HistoryItem::notificationText() const {
QString HistoryItem::inDialogsText(DrawInDialog way) const { QString HistoryItem::inDialogsText(DrawInDialog way) const {
auto getText = [this]() { auto getText = [this]() {
if (_media) { if (_media) {
if (_groupId) {
return textcmdLink(1, TextUtilities::Clean(lang(lng_in_dlg_album)));
}
return _media->chatListText(); return _media->chatListText();
} else if (!emptyText()) { } else if (!emptyText()) {
return TextUtilities::Clean(_text.originalText()); return TextUtilities::Clean(_text.originalText());

View File

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