-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathuseMakeNotification.ts
More file actions
89 lines (83 loc) · 4.4 KB
/
useMakeNotification.ts
File metadata and controls
89 lines (83 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { useCallback } from 'react';
import { idleCallback, idleQueue } from '@utils/idleCallback';
import { useConsumerNotifications } from './useConsumerNotifications';
import { useDelegatorNotifications } from './useDelegatorNotifications';
import { useGeneralNotifications } from './useGeneralNotifications';
import { useIndexerNotifications } from './useIndexerNotifications';
import { useProjectAllocationNotifications } from './useProjectAllocationNotifications';
export const useMakeNotification = () => {
// 导入所有拆分的 hooks
const indexerNotifications = useIndexerNotifications();
const delegatorNotifications = useDelegatorNotifications();
const consumerNotifications = useConsumerNotifications();
const generalNotifications = useGeneralNotifications();
const allocationNotifications = useProjectAllocationNotifications();
const initAllNotification = useCallback(() => {
idleCallback(() =>
idleQueue([
() => consumerNotifications.makeNoBoosterNotification(),
() => generalNotifications.makeConsumerRewardsProgrameNotification(),
() => indexerNotifications.makeOverAllocateAndUnStakeAllocationNotification(),
() => indexerNotifications.makeLowControllerBalanceNotification(),
() => generalNotifications.makeUnhealthyAllocationNotification(),
() => delegatorNotifications.makeInactiveOperatorNotification(),
() => consumerNotifications.makeLowBillingBalanceNotification(),
() => delegatorNotifications.makeUnlockWithdrawalNotification(),
() => generalNotifications.makeUnClaimedNotification(),
() => delegatorNotifications.makeInOrDecreaseCommissionNotification(),
() => allocationNotifications.makeOutdateAllocationProjects(),
() => generalNotifications.makeNewOperatorNotification(),
]),
);
}, [
indexerNotifications,
delegatorNotifications,
consumerNotifications,
generalNotifications,
allocationNotifications,
]);
// 返回所有方法,保持向后兼容
return {
// 基础方法
makeOverAllocateAndUnStakeAllocationNotification: () =>
idleCallback(() => indexerNotifications.makeOverAllocateAndUnStakeAllocationNotification()),
makeUnClaimedNotification: () => idleCallback(() => generalNotifications.makeUnClaimedNotification()),
makeLowBillingBalanceNotification: () =>
idleCallback(() => consumerNotifications.makeLowBillingBalanceNotification()),
makeInactiveOperatorNotification: () =>
idleCallback(() => delegatorNotifications.makeInactiveOperatorNotification()),
makeLowControllerBalanceNotification: () =>
idleCallback(() => indexerNotifications.makeLowControllerBalanceNotification()),
makeUnlockWithdrawalNotification: () =>
idleCallback(() => delegatorNotifications.makeUnlockWithdrawalNotification()),
makeOutdateAllocationProjects: () => idleCallback(() => allocationNotifications.makeOutdateAllocationProjects()),
makeUnhealthyAllocationNotification: () =>
idleCallback(() => generalNotifications.makeUnhealthyAllocationNotification()),
makeInOrDecreaseCommissionNotification: () =>
idleCallback(() => delegatorNotifications.makeInOrDecreaseCommissionNotification()),
// 刷新方法
refreshAndMakeOverAllocateNotification: () => {
// 这些需要在各自的 hooks 中实现移除逻辑
idleCallback(() => indexerNotifications.makeOverAllocateAndUnStakeAllocationNotification('reload'));
},
refreshAndMakeUnClaimedNotification: () => {
idleCallback(() => generalNotifications.makeUnClaimedNotification('reload'));
},
refreshAndMakeLowBillingBalanceNotification: () => {
idleCallback(() => consumerNotifications.makeLowBillingBalanceNotification('reload'));
},
refreshAndMakeInactiveOperatorNotification: () => {
idleCallback(() => delegatorNotifications.makeInactiveOperatorNotification('reload'));
},
refreshAndMakeInOrDecreaseCommissionNotification: () => {
idleCallback(() => delegatorNotifications.makeInOrDecreaseCommissionNotification('reload'));
},
refreshAndMakeUnlockWithdrawalNotification: () => {
idleCallback(() => delegatorNotifications.makeUnlockWithdrawalNotification('reload'));
},
refreshAndMakeOutdateAllocationProjects: () => {
idleCallback(() => allocationNotifications.makeOutdateAllocationProjects('reload'));
},
initNewNotification: () => idleCallback(initAllNotification),
};
};