Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
82ec022f
Commit
82ec022f
authored
5 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Fix notification not being cleared, when read event didn't cause a notification
parent
2b24a978
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/notifications/Manager.h
+0
-17
0 additions, 17 deletions
src/notifications/Manager.h
src/notifications/ManagerLinux.cpp
+19
-19
19 additions, 19 deletions
src/notifications/ManagerLinux.cpp
with
19 additions
and
36 deletions
src/notifications/Manager.h
+
0
−
17
View file @
82ec022f
#pragma once
#include
<QHash>
#include
<QImage>
#include
<QObject>
#include
<QString>
...
...
@@ -16,27 +15,12 @@ struct roomEventId
QString
eventId
;
};
inline
bool
operator
<
(
const
roomEventId
&
a
,
const
roomEventId
&
b
)
{
if
(
a
.
roomId
==
b
.
roomId
)
return
a
.
eventId
<
b
.
eventId
;
else
return
a
.
roomId
<
b
.
roomId
;
}
inline
bool
operator
==
(
const
roomEventId
&
a
,
const
roomEventId
&
b
)
{
return
a
.
roomId
==
b
.
roomId
&&
a
.
eventId
==
b
.
eventId
;
}
inline
uint
qHash
(
const
roomEventId
&
v
,
uint
seed
)
{
return
qHash
(
v
.
roomId
,
seed
)
^
qHash
(
v
.
eventId
,
seed
);
}
class
NotificationsManager
:
public
QObject
{
Q_OBJECT
...
...
@@ -67,7 +51,6 @@ private:
// notification ID to (room ID, event ID)
QMap
<
uint
,
roomEventId
>
notificationIds
;
QHash
<
roomEventId
,
uint
>
eventToNotificationId
;
#endif
// these slots are platform specific (D-Bus only)
...
...
This diff is collapsed.
Click to expand it.
src/notifications/ManagerLinux.cpp
+
19
−
19
View file @
82ec022f
...
...
@@ -40,7 +40,6 @@ NotificationsManager::postNotification(const QString &roomid,
{
uint
id
=
showNotification
(
roomname
,
sender
+
": "
+
text
,
icon
);
notificationIds
[
id
]
=
roomEventId
{
roomid
,
eventid
};
eventToNotificationId
[
roomEventId
{
roomid
,
eventid
}]
=
id
;
}
/**
* This function is based on code from
...
...
@@ -98,23 +97,24 @@ NotificationsManager::closeNotification(uint id)
void
NotificationsManager
::
removeNotification
(
const
QString
&
roomId
,
const
QString
&
eventId
)
{
roomEventId
reId
=
{
roomId
,
eventId
};
if
(
eventToNotificationId
.
contains
(
reId
))
{
for
(
auto
elem
=
notificationIds
.
begin
();
elem
!=
notificationIds
.
end
();
++
elem
)
{
if
(
elem
.
value
().
roomId
!=
roomId
)
continue
;
// close all notifications matching the eventId or having a lower
// notificationId
// This relies on the notificationId not wrapping around. This allows for
// approximately 2,147,483,647 notifications, so it is a bit unlikely.
// Otherwise we would need to store a 64bit counter instead.
closeNotification
(
elem
.
key
());
if
(
elem
.
value
()
==
reId
)
break
;
}
roomEventId
reId
=
{
roomId
,
eventId
};
for
(
auto
elem
=
notificationIds
.
begin
();
elem
!=
notificationIds
.
end
();
++
elem
)
{
if
(
elem
.
value
().
roomId
!=
roomId
)
continue
;
// close all notifications matching the eventId or having a lower
// notificationId
// This relies on the notificationId not wrapping around. This allows for
// approximately 2,147,483,647 notifications, so it is a bit unlikely.
// Otherwise we would need to store a 64bit counter instead.
closeNotification
(
elem
.
key
());
// FIXME: compare index of event id of the read receipt and the notification instead of just
// the id to prevent read receipts of events without notification clearing all notifications
// in that room!
if
(
elem
.
value
()
==
reId
)
break
;
}
}
...
...
@@ -131,7 +131,7 @@ void
NotificationsManager
::
notificationClosed
(
uint
id
,
uint
reason
)
{
Q_UNUSED
(
reason
);
eventToN
otificationId
.
remove
(
notificationIds
.
take
(
id
)
);
n
otificationId
s
.
remove
(
id
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment