From e219aaa062563202c6b723ada06f115437ab35a7 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 4 Mar 2023 14:49:15 -0300 Subject: Notifications: Permanent option and close button (#563) Co-authored-by: Ven --- src/api/Notifications/NotificationComponent.tsx | 33 +++++++++++++++++++++---- src/api/Notifications/Notifications.tsx | 2 ++ src/api/Notifications/styles.css | 33 +++++++++++++++++++++---- 3 files changed, 58 insertions(+), 10 deletions(-) (limited to 'src/api') diff --git a/src/api/Notifications/NotificationComponent.tsx b/src/api/Notifications/NotificationComponent.tsx index 036cacd..29cd68f 100644 --- a/src/api/Notifications/NotificationComponent.tsx +++ b/src/api/Notifications/NotificationComponent.tsx @@ -20,7 +20,7 @@ import "./styles.css"; import { useSettings } from "@api/settings"; import ErrorBoundary from "@components/ErrorBoundary"; -import { Forms, React, useEffect, useMemo, useState, useStateFromStores, WindowStore } from "@webpack/common"; +import { React, useEffect, useMemo, useState, useStateFromStores, WindowStore } from "@webpack/common"; import { NotificationData } from "./Notifications"; @@ -32,7 +32,8 @@ export default ErrorBoundary.wrap(function NotificationComponent({ icon, onClick, onClose, - image + image, + permanent }: NotificationData) { const { timeout, position } = useSettings(["notifications.timeout", "notifications.position"]).notifications; const hasFocus = useStateFromStores([WindowStore], () => WindowStore.isFocused()); @@ -43,7 +44,7 @@ export default ErrorBoundary.wrap(function NotificationComponent({ const start = useMemo(() => Date.now(), [timeout, isHover, hasFocus]); useEffect(() => { - if (isHover || !hasFocus || timeout === 0) return void setElapsed(0); + if (isHover || !hasFocus || timeout === 0 || permanent) return void setElapsed(0); const intervalId = setInterval(() => { const elapsed = Date.now() - start; @@ -74,14 +75,36 @@ export default ErrorBoundary.wrap(function NotificationComponent({
{icon && }
- {title} +
+

{title}

+ +
{richBody ??

{body}

}
{image && } - {timeout !== 0 && ( + {timeout !== 0 && !permanent && (