aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/util/formatter.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/common/util/formatter.js')
-rw-r--r--modern/src/common/util/formatter.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/modern/src/common/util/formatter.js b/modern/src/common/util/formatter.js
index 47bd2cd0..ea18713d 100644
--- a/modern/src/common/util/formatter.js
+++ b/modern/src/common/util/formatter.js
@@ -97,3 +97,22 @@ export const getBatteryStatus = (batteryLevel) => {
}
return 'negative';
};
+
+export const formatNotificationTitle = (t, notification, includeId) => {
+ let title = t(prefixString('event', notification.type));
+ if (notification.type === 'alarm') {
+ const alarmString = notification.attributes.alarms;
+ if (alarmString) {
+ const alarms = alarmString.split(',');
+ if (alarms.length > 1) {
+ title += ` (${alarms.length})`;
+ } else {
+ title += ` ${formatAlarm(alarms[0], t)}`;
+ }
+ }
+ }
+ if (includeId) {
+ title += ` [${notification.id}]`;
+ }
+ return title;
+};