on 2043bfc help sign in
bridge/src/store/lib/usePointStore.js
44 lines 1.3 kB history raw
1import { useCallback } from 'react';
3import useDetailsStore from './useDetailsStore';
4import useBirthdaysStore from './useBirthdaysStore';
5import useInvitesStore from './useInvitesStore';
6import useControlledPointsStore from './useControlledPointsStore';
7import useEclipticOwnerStore from './useEclipticOwnerStore';
9export default function usePointStore() {
10 const { syncDetails, ...details } = useDetailsStore();
11 const { syncBirthday, ...birthdays } = useBirthdaysStore();
12 const { syncInvites, ...invites } = useInvitesStore();
13 const ecliptic = useEclipticOwnerStore();
14 const {
15 syncControlledPoints,
16 ...controlledPoints
17 } = useControlledPointsStore();
19 // sync all of the on-chain info required to display a foreign point
20 const syncForeignPoint = useCallback(async point => Promise.all([]), []);
22 // sync all of the on-chain info required for a point that the user owns
23 const syncOwnedPoint = useCallback(
24 async point =>
25 Promise.all([
26 syncDetails(point),
27 syncBirthday(point),
28 syncInvites(point),
29 ]),
30 [syncDetails, syncBirthday, syncInvites]
31 );
33 return {
34 ...details,
35 ...birthdays,
36 ...invites,
37 ...controlledPoints,
38 ...ecliptic,
39 syncInvites,
40 syncControlledPoints,
41 syncOwnedPoint,
42 syncForeignPoint,
43 };