on 5eceb4e help sign in
bridge/src/store/lib/usePointStore.js
57 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';
9import useResidents from './useResidentsStore';
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 { syncResidents, syncResidentCount, ...residents } = useResidents();
21 const ecliptic = useEclipticOwnerStore();
23 //TODO more appropriately named "syncDates" or similar
24 const syncKnownPoint = useCallback(
25 async point => Promise.all([syncBirthday(point), syncRekeyDate(point)]),
26 [syncBirthday, syncRekeyDate]
27 );
29 const syncExtras = useCallback(
30 async point =>
31 Promise.all([
32 syncKnownPoint(point),
33 //
34 syncResidentCount(point),
35 syncDetails(point),
36 syncInvites(point),
37 ]),
38 [syncKnownPoint, syncDetails, syncInvites, syncResidentCount]
39 );
41 return {
42 ...details,
43 ...birthdays,
44 ...rekeyDates,
45 ...invites,
46 ...controlledPoints,
47 ...ecliptic,
48 ...residents,
49 syncDetails,
50 syncRekeyDate,
51 syncInvites,
52 syncControlledPoints,
53 syncKnownPoint,
54 syncResidents,
55 syncExtras,
56 };