on f660f7b help sign in
bridge/src/store/lib/usePointStore.js
61 lines 1.9 kB history raw
1import { useCallback } from 'react';
3import useDetailsStore from './useDetailsStore';
4import useBirthdaysStore from './useBirthdaysStore';
5import useRekeyDateStore from './useRekeyDateStore';
6import useInvitesStore from './useInvitesStore';
7import useControlledPointsStore from './useControlledPointsStore';
8import useEclipticOwnerStore from './useEclipticOwnerStore';
9import useOptimisticPointDetailsStore from './useOptimisticDetailsStore';
11export default function usePointStore() {
12 const { syncDetails, ...details } = useDetailsStore();
13 const { syncBirthday, ...birthdays } = useBirthdaysStore();
14 const { syncRekeyDate, ...rekeyDates } = useRekeyDateStore();
15 const { syncInvites, ...invites } = useInvitesStore();
16 const {
17 syncControlledPoints,
18 ...controlledPoints
19 } = useControlledPointsStore();
20 const ecliptic = useEclipticOwnerStore();
21 const optimistic = useOptimisticPointDetailsStore();
23 // sync all of the on-chain info required to display a known point
24 const syncKnownPoint = useCallback(
25 point => {
26 syncBirthday(point);
27 syncRekeyDate(point);
28 },
29 [syncBirthday, syncRekeyDate]
30 );
32 // sync all of the on-chain info required to display a foreign point
33 const syncForeignPoint = useCallback(point => {}, []);
35 // sync all of the on-chain info required for a point that the user owns
36 const syncOwnedPoint = useCallback(
37 point => {
38 syncForeignPoint(point);
39 syncKnownPoint(point);
40 //
41 syncDetails(point);
42 syncInvites(point);
43 },
44 [syncForeignPoint, syncKnownPoint, syncDetails, syncInvites]
45 );
47 return {
48 ...details,
49 ...birthdays,
50 ...rekeyDates,
51 ...invites,
52 ...controlledPoints,
53 ...ecliptic,
54 ...optimistic,
55 syncInvites,
56 syncControlledPoints,
57 syncKnownPoint,
58 syncOwnedPoint,
59 syncForeignPoint,
60 };