Files
custum-hyprpanel/src/components/menus/notifications/controls/ClearNotificationsButton.tsx
Jas Singh 6b846b9709 Remove global service declarations and change to declarations upon usage. (#761)
* Remove global service declarations and change to declarations upon usage.

* Only load cava service if cava is enabled.
2025-02-06 02:15:20 -08:00

39 lines
1.2 KiB
TypeScript

import { bind } from 'astal';
import AstalNotifd from 'gi://AstalNotifd?version=0.1';
import { clearNotifications } from 'src/globals/notification';
import { isPrimaryClick } from 'src/lib/utils';
import options from 'src/options';
const notifdService = AstalNotifd.get_default();
const { clearDelay } = options.notifications;
export const ClearNotificationsButton = (): JSX.Element => {
return (
<button
className={'clear-notifications-button'}
tooltipText={'Clear Notifications'}
onClick={(_, event) => {
if (!isPrimaryClick(event)) {
return;
}
if (removingNotifications.get()) {
return;
}
clearNotifications(notifdService.get_notifications(), clearDelay.get());
}}
>
<label
className={bind(removingNotifications).as((removing) => {
return removing
? 'clear-notifications-label txt-icon removing'
: 'clear-notifications-label txt-icon';
})}
label={''}
/>
</button>
);
};