mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Fix scheduled notifications on inbox read.
This commit is contained in:
parent
d95e54cb1a
commit
3715fa4b1e
13 changed files with 60 additions and 46 deletions
|
@ -1977,7 +1977,7 @@ void Session::updateNotifySettingsLocal(not_null<PeerData*> peer) {
|
|||
_mutedPeers.emplace(peer);
|
||||
unmuteByFinishedDelayed(changesIn);
|
||||
if (history) {
|
||||
_session->notifications().clearFromHistory(history);
|
||||
_session->notifications().clearIncomingFromHistory(history);
|
||||
}
|
||||
} else {
|
||||
_mutedPeers.erase(peer);
|
||||
|
|
|
@ -1658,10 +1658,7 @@ void History::inboxRead(MsgId upTo, std::optional<int> stillUnread) {
|
|||
}
|
||||
|
||||
_firstUnreadView = nullptr;
|
||||
if (!peer->isSelf()) {
|
||||
// Only reminders generate notifications in Saved Messages.
|
||||
session().notifications().clearFromHistory(this);
|
||||
}
|
||||
session().notifications().clearIncomingFromHistory(this);
|
||||
}
|
||||
|
||||
void History::inboxRead(not_null<const HistoryItem*> wasRead) {
|
||||
|
@ -2175,6 +2172,14 @@ void History::clearNotifications() {
|
|||
_notifications.clear();
|
||||
}
|
||||
|
||||
void History::clearIncomingNotifications() {
|
||||
if (!peer->isSelf()) {
|
||||
_notifications.erase(
|
||||
ranges::remove(_notifications, false, &HistoryItem::out),
|
||||
end(_notifications));
|
||||
}
|
||||
}
|
||||
|
||||
bool History::loadedAtBottom() const {
|
||||
return _loadedAtBottom;
|
||||
}
|
||||
|
|
|
@ -168,34 +168,36 @@ public:
|
|||
void inboxRead(not_null<const HistoryItem*> wasRead);
|
||||
void outboxRead(MsgId upTo);
|
||||
void outboxRead(not_null<const HistoryItem*> wasRead);
|
||||
bool isServerSideUnread(not_null<const HistoryItem*> item) const;
|
||||
MsgId loadAroundId() const;
|
||||
[[nodiscard]] bool isServerSideUnread(
|
||||
not_null<const HistoryItem*> item) const;
|
||||
[[nodiscard]] MsgId loadAroundId() const;
|
||||
|
||||
int unreadCount() const;
|
||||
bool unreadCountKnown() const;
|
||||
[[nodiscard]] int unreadCount() const;
|
||||
[[nodiscard]] bool unreadCountKnown() const;
|
||||
void setUnreadCount(int newUnreadCount);
|
||||
void setUnreadMark(bool unread);
|
||||
bool unreadMark() const;
|
||||
int unreadCountForBadge() const; // unreadCount || unreadMark ? 1 : 0.
|
||||
bool mute() const;
|
||||
[[nodiscard]] bool unreadMark() const;
|
||||
[[nodiscard]] int unreadCountForBadge() const; // unreadCount || unreadMark ? 1 : 0.
|
||||
[[nodiscard]] bool mute() const;
|
||||
bool changeMute(bool newMute);
|
||||
void addUnreadBar();
|
||||
void destroyUnreadBar();
|
||||
bool hasNotFreezedUnreadBar() const;
|
||||
Element *unreadBar() const;
|
||||
[[nodiscard]] bool hasNotFreezedUnreadBar() const;
|
||||
[[nodiscard]] Element *unreadBar() const;
|
||||
void calculateFirstUnreadMessage();
|
||||
void unsetFirstUnreadMessage();
|
||||
Element *firstUnreadMessage() const;
|
||||
[[nodiscard]] Element *firstUnreadMessage() const;
|
||||
void clearNotifications();
|
||||
void clearIncomingNotifications();
|
||||
|
||||
bool loadedAtBottom() const; // last message is in the list
|
||||
[[nodiscard]] bool loadedAtBottom() const; // last message is in the list
|
||||
void setNotLoadedAtBottom();
|
||||
bool loadedAtTop() const; // nothing was added after loading history back
|
||||
bool isReadyFor(MsgId msgId); // has messages for showing history at msgId
|
||||
[[nodiscard]] bool loadedAtTop() const; // nothing was added after loading history back
|
||||
[[nodiscard]] bool isReadyFor(MsgId msgId); // has messages for showing history at msgId
|
||||
void getReadyFor(MsgId msgId);
|
||||
|
||||
HistoryItem *lastMessage() const;
|
||||
bool lastMessageKnown() const;
|
||||
[[nodiscard]] HistoryItem *lastMessage() const;
|
||||
[[nodiscard]] bool lastMessageKnown() const;
|
||||
void unknownMessageDeleted(MsgId messageId);
|
||||
void applyDialogTopMessage(MsgId topMessageId);
|
||||
void applyDialog(Data::Folder *requestFolder, const MTPDdialog &data);
|
||||
|
|
|
@ -313,7 +313,7 @@ public:
|
|||
bool hideNameAndPhoto,
|
||||
bool hideReplyButton);
|
||||
void clearAll();
|
||||
void clearFromHistory(History *history);
|
||||
void clearFromHistory(not_null<History*> history);
|
||||
void clearNotification(PeerId peerId, MsgId msgId);
|
||||
|
||||
bool hasPoorSupport() const {
|
||||
|
@ -494,7 +494,7 @@ void Manager::Private::clearAll() {
|
|||
}
|
||||
}
|
||||
|
||||
void Manager::Private::clearFromHistory(History *history) {
|
||||
void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||
for (auto i = _queuedNotifications.begin(); i != _queuedNotifications.end();) {
|
||||
if (i->peer == history->peer) {
|
||||
i = _queuedNotifications.erase(i);
|
||||
|
@ -573,7 +573,7 @@ void Manager::doClearAllFast() {
|
|||
_private->clearAll();
|
||||
}
|
||||
|
||||
void Manager::doClearFromHistory(History *history) {
|
||||
void Manager::doClearFromHistory(not_null<History*> history) {
|
||||
_private->clearFromHistory(history);
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
|
|
@ -45,7 +45,7 @@ protected:
|
|||
bool hideNameAndPhoto,
|
||||
bool hideReplyButton) override;
|
||||
void doClearAllFast() override;
|
||||
void doClearFromHistory(History *history) override;
|
||||
void doClearFromHistory(not_null<History*> history) override;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
|||
bool hideNameAndPhoto,
|
||||
bool hideReplyButton) override;
|
||||
void doClearAllFast() override;
|
||||
void doClearFromHistory(History *history) override;
|
||||
void doClearFromHistory(not_null<History*> history) override;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
|
|
@ -170,7 +170,7 @@ public:
|
|||
bool hideNameAndPhoto,
|
||||
bool hideReplyButton);
|
||||
void clearAll();
|
||||
void clearFromHistory(History *history);
|
||||
void clearFromHistory(not_null<History*> history);
|
||||
void updateDelegate();
|
||||
|
||||
~Private();
|
||||
|
@ -321,7 +321,7 @@ void Manager::Private::clearAll() {
|
|||
putClearTask(ClearAll());
|
||||
}
|
||||
|
||||
void Manager::Private::clearFromHistory(History *history) {
|
||||
void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||
putClearTask(ClearFromHistory { history->peer->id });
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ void Manager::doClearAllFast() {
|
|||
_private->clearAll();
|
||||
}
|
||||
|
||||
void Manager::doClearFromHistory(History *history) {
|
||||
void Manager::doClearFromHistory(not_null<History*> history) {
|
||||
_private->clearFromHistory(history);
|
||||
}
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ public:
|
|||
bool hideNameAndPhoto,
|
||||
bool hideReplyButton);
|
||||
void clearAll();
|
||||
void clearFromHistory(History *history);
|
||||
void clearFromHistory(not_null<History*> history);
|
||||
void beforeNotificationActivated(PeerId peerId, MsgId msgId);
|
||||
void afterNotificationActivated(PeerId peerId, MsgId msgId);
|
||||
void clearNotification(PeerId peerId, MsgId msgId);
|
||||
|
@ -420,7 +420,7 @@ void Manager::Private::clearAll() {
|
|||
}
|
||||
}
|
||||
|
||||
void Manager::Private::clearFromHistory(History *history) {
|
||||
void Manager::Private::clearFromHistory(not_null<History*> history) {
|
||||
if (!_notifier) return;
|
||||
|
||||
auto i = _notifications.find(history->peer->id);
|
||||
|
@ -600,7 +600,7 @@ void Manager::doClearAllFast() {
|
|||
_private->clearAll();
|
||||
}
|
||||
|
||||
void Manager::doClearFromHistory(History *history) {
|
||||
void Manager::doClearFromHistory(not_null<History*> history) {
|
||||
_private->clearFromHistory(history);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
|||
bool hideNameAndPhoto,
|
||||
bool hideReplyButton) override;
|
||||
void doClearAllFast() override;
|
||||
void doClearFromHistory(History *history) override;
|
||||
void doClearFromHistory(not_null<History*> history) override;
|
||||
void onBeforeNotificationActivated(PeerId peerId, MsgId msgId) override;
|
||||
void onAfterNotificationActivated(PeerId peerId, MsgId msgId) override;
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ void System::clearAll() {
|
|||
_settingWaiters.clear();
|
||||
}
|
||||
|
||||
void System::clearFromHistory(History *history) {
|
||||
void System::clearFromHistory(not_null<History*> history) {
|
||||
_manager->clearFromHistory(history);
|
||||
|
||||
history->clearNotifications();
|
||||
|
@ -167,7 +167,13 @@ void System::clearFromHistory(History *history) {
|
|||
showNext();
|
||||
}
|
||||
|
||||
void System::clearFromItem(HistoryItem *item) {
|
||||
void System::clearIncomingFromHistory(not_null<History*> history) {
|
||||
_manager->clearFromHistory(history);
|
||||
history->clearIncomingNotifications();
|
||||
_whenAlerts.remove(history);
|
||||
}
|
||||
|
||||
void System::clearFromItem(not_null<HistoryItem*> item) {
|
||||
_manager->clearFromItem(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,9 @@ public:
|
|||
|
||||
void checkDelayed();
|
||||
void schedule(not_null<HistoryItem*> item);
|
||||
void clearFromHistory(History *history);
|
||||
void clearFromItem(HistoryItem *item);
|
||||
void clearFromHistory(not_null<History*> history);
|
||||
void clearIncomingFromHistory(not_null<History*> history);
|
||||
void clearFromItem(not_null<HistoryItem*> item);
|
||||
void clearAll();
|
||||
void clearAllFast();
|
||||
void updateAll();
|
||||
|
@ -148,10 +149,10 @@ public:
|
|||
void clearAllFast() {
|
||||
doClearAllFast();
|
||||
}
|
||||
void clearFromItem(HistoryItem *item) {
|
||||
void clearFromItem(not_null<HistoryItem*> item) {
|
||||
doClearFromItem(item);
|
||||
}
|
||||
void clearFromHistory(History *history) {
|
||||
void clearFromHistory(not_null<History*> history) {
|
||||
doClearFromHistory(history);
|
||||
}
|
||||
|
||||
|
@ -181,8 +182,8 @@ protected:
|
|||
int forwardedCount) = 0;
|
||||
virtual void doClearAll() = 0;
|
||||
virtual void doClearAllFast() = 0;
|
||||
virtual void doClearFromItem(HistoryItem *item) = 0;
|
||||
virtual void doClearFromHistory(History *history) = 0;
|
||||
virtual void doClearFromItem(not_null<HistoryItem*> item) = 0;
|
||||
virtual void doClearFromHistory(not_null<History*> history) = 0;
|
||||
virtual void onBeforeNotificationActivated(PeerId peerId, MsgId msgId) {
|
||||
}
|
||||
virtual void onAfterNotificationActivated(PeerId peerId, MsgId msgId) {
|
||||
|
@ -207,7 +208,7 @@ protected:
|
|||
void doClearAll() override {
|
||||
doClearAllFast();
|
||||
}
|
||||
void doClearFromItem(HistoryItem *item) override {
|
||||
void doClearFromItem(not_null<HistoryItem*> item) override {
|
||||
}
|
||||
void doShowNotification(
|
||||
not_null<HistoryItem*> item,
|
||||
|
|
|
@ -317,7 +317,7 @@ void Manager::doClearAllFast() {
|
|||
base::take(_hideAll);
|
||||
}
|
||||
|
||||
void Manager::doClearFromHistory(History *history) {
|
||||
void Manager::doClearFromHistory(not_null<History*> history) {
|
||||
for (auto i = _queuedNotifications.begin(); i != _queuedNotifications.cend();) {
|
||||
if (i->history == history) {
|
||||
i = _queuedNotifications.erase(i);
|
||||
|
@ -333,8 +333,8 @@ void Manager::doClearFromHistory(History *history) {
|
|||
showNextFromQueue();
|
||||
}
|
||||
|
||||
void Manager::doClearFromItem(HistoryItem *item) {
|
||||
_queuedNotifications.erase(std::remove_if(_queuedNotifications.begin(), _queuedNotifications.end(), [item](auto &queued) {
|
||||
void Manager::doClearFromItem(not_null<HistoryItem*> item) {
|
||||
_queuedNotifications.erase(std::remove_if(_queuedNotifications.begin(), _queuedNotifications.end(), [&](auto &queued) {
|
||||
return (queued.item == item);
|
||||
}), _queuedNotifications.cend());
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ private:
|
|||
int forwardedCount) override;
|
||||
void doClearAll() override;
|
||||
void doClearAllFast() override;
|
||||
void doClearFromHistory(History *history) override;
|
||||
void doClearFromItem(HistoryItem *item) override;
|
||||
void doClearFromHistory(not_null<History*> history) override;
|
||||
void doClearFromItem(not_null<HistoryItem*> item) override;
|
||||
|
||||
void showNextFromQueue();
|
||||
void unlinkFromShown(Notification *remove);
|
||||
|
|
Loading…
Add table
Reference in a new issue