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