Merge lp:~tiagosh/telephony-service/skip_notifications into lp:telephony-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Bill Filler
Approved revision: 938
Merged at revision: 938
Proposed branch: lp:~tiagosh/telephony-service/skip_notifications
Merge into: lp:telephony-service
Diff against target: 57 lines (+21/-2)
2 files modified
indicator/textchannelobserver.cpp (+20/-2)
indicator/textchannelobserver.h (+1/-0)
To merge this branch: bzr merge lp:~tiagosh/telephony-service/skip_notifications
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+235045@code.launchpad.net

Commit message

Avoid displaying on screen notifications for messages if the message thread is open.

Description of the change

Avoid displaying on screen notifications for messages if the message thread is open.

--Checklist--
Are there any related MPs required for this MP to build/function as expected? Please list.
No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/telephony-service) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
N/A

If you changed UI labels, did you update the pot file?
N/A

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
yes

Did CI run pass? If not, please explain why.
yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'indicator/textchannelobserver.cpp'
2--- indicator/textchannelobserver.cpp 2014-09-11 20:57:34 +0000
3+++ indicator/textchannelobserver.cpp 2014-09-17 20:24:21 +0000
4@@ -230,6 +230,14 @@
5
6 // add the message to the messaging menu (use hex format to avoid invalid characters)
7 QByteArray token(message.messageToken().toUtf8());
8+
9+ // if the message was already read, just play the ringtone and return
10+ // ignore logic if we are in greeter mode
11+ if (!mUnreadMessages.contains(token) && !GreeterContacts::isGreeterMode()) {
12+ Ringtone::instance()->playIncomingMessageSound();
13+ return;
14+ }
15+
16 MessagingMenu::instance()->addMessage(contact->id(), token.toHex(), message.received(), messageText);
17
18 QString title = QString::fromUtf8(C::gettext("Message from %1")).arg(contact->alias());
19@@ -381,14 +389,24 @@
20 }
21
22 if (!message.isScrollback() && !message.isDeliveryReport() && !message.isRescued()) {
23- showNotificationForMessage(message);
24- Metrics::instance()->increment(Metrics::ReceivedMessages);
25+ QTimer *timer = new QTimer(this);
26+ timer->setInterval(1500);
27+ timer->setSingleShot(true);
28+ QByteArray token(message.messageToken().toUtf8());
29+ mUnreadMessages.append(token);
30+ QObject::connect(timer, &QTimer::timeout, [=]() {
31+ showNotificationForMessage(message);
32+ Metrics::instance()->increment(Metrics::ReceivedMessages);
33+ timer->deleteLater();
34+ });
35+ timer->start();
36 }
37 }
38
39 void TextChannelObserver::onPendingMessageRemoved(const Tp::ReceivedMessage &message)
40 {
41 QByteArray token(message.messageToken().toUtf8());
42+ mUnreadMessages.removeAll(token);
43 MessagingMenu::instance()->removeMessage(token.toHex());
44 }
45
46
47=== modified file 'indicator/textchannelobserver.h'
48--- indicator/textchannelobserver.h 2014-04-07 19:19:09 +0000
49+++ indicator/textchannelobserver.h 2014-09-17 20:24:21 +0000
50@@ -57,6 +57,7 @@
51 QList<Tp::TextChannelPtr> mChannels;
52 QList<Tp::TextChannelPtr> mFlashChannels;
53 QMap<NotifyNotification*, NotificationData*> mNotifications;
54+ QList<QByteArray> mUnreadMessages;
55 };
56
57 #endif // TEXTCHANNELOBSERVER_H

Subscribers

People subscribed via source and target branches