aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-25 11:10:52 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-25 13:23:40 +0900
commit52aadc68d73d7e590ab7ec3f8b4382483a50bcf1 (patch)
treef19af82f8f3e828aa810e2f7aab52e2ac8fca670
parentb4e699a0076fc7827fa89af33d8774d43eb017ce (diff)
downloadlibquotient-52aadc68d73d7e590ab7ec3f8b4382483a50bcf1.tar.gz
libquotient-52aadc68d73d7e590ab7ec3f8b4382483a50bcf1.zip
Room::Private::toJson: don't save zero numbers
-rw-r--r--room.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/room.cpp b/room.cpp
index ab7f7a8f..e3e0fb47 100644
--- a/room.cpp
+++ b/room.cpp
@@ -1499,9 +1499,12 @@ QJsonObject Room::Private::toJson() const
}
QJsonObject unreadNotificationsObj;
- unreadNotificationsObj.insert("highlight_count", highlightCount);
- unreadNotificationsObj.insert("notification_count", notificationCount);
- result.insert("unread_notifications", unreadNotificationsObj);
+ if (highlightCount > 0)
+ unreadNotificationsObj.insert("highlight_count", highlightCount);
+ if (notificationCount > 0)
+ unreadNotificationsObj.insert("notification_count", notificationCount);
+ if (!unreadNotificationsObj.isEmpty())
+ result.insert("unread_notifications", unreadNotificationsObj);
return result;
}