on af19266 help sign in
bridge/src/store/lib/usePointStore.js
58 lines 1.7 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';
10export default function usePointStore() {
11 const { syncDetails, ...details } = useDetailsStore();
12 const { syncBirthday, ...birthdays } = useBirthdaysStore();
13 const { syncRekeyDate, ...rekeyDates } = useRekeyDateStore();
14 const { syncInvites, ...invites } = useInvitesStore();
15 const {
16 syncControlledPoints,
17 ...controlledPoints
18 } = useControlledPointsStore();
19 const ecliptic = useEclipticOwnerStore();
21 // sync all of the on-chain info required to display a known point
22 const syncKnownPoint = useCallback(
23 point => {
24 syncBirthday(point);
25 syncRekeyDate(point);
26 },
27 [syncBirthday, syncRekeyDate]
28 );
30 // sync all of the on-chain info required to display a foreign point
31 const syncForeignPoint = useCallback(point => {}, []);
33 // sync all of the on-chain info required for a point that the user owns
34 const syncOwnedPoint = useCallback(
35 point => {
36 syncForeignPoint(point);
37 syncKnownPoint(point);
38 //
39 syncDetails(point);
40 syncInvites(point);
41 },
42 [syncForeignPoint, syncKnownPoint, syncDetails, syncInvites]
43 );
45 return {
46 ...details,
47 ...birthdays,
48 ...rekeyDates,
49 ...invites,
50 ...controlledPoints,
51 ...ecliptic,
52 syncInvites,
53 syncControlledPoints,
54 syncKnownPoint,
55 syncOwnedPoint,
56 syncForeignPoint,
57 };