feature: hide notifications count when 0 (#338)
* fix: hide notifications count when 0 * feat: add settings to control earlier behavious * fix: lints and formatting * Update widget/settings/pages/config/bar/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * fix: notifications css * Update modules/bar/notifications/index.ts --------- Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
@@ -7,7 +7,7 @@ import Button from 'types/widgets/button.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
|
||||
|
||||
const { show_total, rightClick, middleClick, scrollUp, scrollDown } = options.bar.notifications;
|
||||
const { show_total, rightClick, middleClick, scrollUp, scrollDown, hideCountWhenZero } = options.bar.notifications;
|
||||
const { ignore } = options.notifications;
|
||||
|
||||
const notifs = await Service.import('notifications');
|
||||
@@ -32,8 +32,14 @@ export const Notifications = (): BarBoxChild => {
|
||||
hpack: 'start',
|
||||
class_name: 'bar-notifications',
|
||||
children: Utils.merge(
|
||||
[notifs.bind('notifications'), notifs.bind('dnd'), show_total.bind('value'), ignore.bind('value')],
|
||||
(notif, dnd, showTotal, ignoredNotifs) => {
|
||||
[
|
||||
notifs.bind('notifications'),
|
||||
notifs.bind('dnd'),
|
||||
show_total.bind('value'),
|
||||
ignore.bind('value'),
|
||||
hideCountWhenZero.bind('value'),
|
||||
],
|
||||
(notif, dnd, showTotal, ignoredNotifs, hideCountForZero) => {
|
||||
const filteredNotifications = filterNotifications(notif, ignoredNotifs);
|
||||
|
||||
const notifIcon = Widget.Label({
|
||||
@@ -49,6 +55,9 @@ export const Notifications = (): BarBoxChild => {
|
||||
});
|
||||
|
||||
if (showTotal) {
|
||||
if (hideCountForZero && filteredNotifications.length === 0) {
|
||||
return [notifIcon];
|
||||
}
|
||||
return [notifIcon, notifLabel];
|
||||
}
|
||||
return [notifIcon];
|
||||
|
||||
Reference in New Issue
Block a user