feat(gui): Remember acknowledged alerts and do not show them again

This commit is contained in:
Binarybaron 2025-10-05 22:51:20 +02:00
parent bbdae0c18c
commit 65a46a4205
5 changed files with 65 additions and 12 deletions

View file

@ -30,6 +30,8 @@ import {
TauriBackgroundProgress,
TauriBitcoinSyncProgress,
} from "models/tauriModel";
import { Alert } from "models/apiModel";
import { fnv1a } from "utils/hash";
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
@ -327,3 +329,17 @@ export function useTotalUnreadMessagesCount(): number {
return totalUnreadCount;
}
/// Returns all the alerts that have not been acknowledged
export function useAlerts(): Alert[] {
return useAppSelector((state) =>
state.alerts.alerts.filter(
(alert) =>
// Check if there is an acknowledgement with
// the same id and the same title hash
!state.alerts.acknowledgedAlerts.some(
(ack) => ack.id === alert.id && ack.titleHash === fnv1a(alert.title),
),
),
);
}