mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-21 11:25:50 -05:00
feat(gui): Remember acknowledged alerts and do not show them again
This commit is contained in:
parent
bbdae0c18c
commit
65a46a4205
5 changed files with 65 additions and 12 deletions
|
|
@ -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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue