on master help sign in
birthdays: removing because unused
69b7547Hunter Miller
src/lib/usePointBirthday.jsdeleted−7
@@ -1,7 +0,0 @@
1−import { usePointCache } from 'store/pointCache';
2−
3−export default function usePointBirthday(point) {
4− const { getBirthday } = usePointCache();
5−
6− return getBirthday(point);
7−}
src/store/lib/useBirthdaysStore.jsdeleted−59
@@ -1,59 +0,0 @@
1−import { useCallback, useState } from 'react';
2−import { Just, Nothing } from 'folktale/maybe';
3−import * as azimuth from 'azimuth-js';
4−
5−import { useNetwork } from '../network';
6−
7−export default function useBirthdayStore() {
8− const { contracts, web3 } = useNetwork();
9− const [birthdayCache, _setBirthdayCache] = useState({});
10−
11− const addToBirthdayCache = useCallback(
12− entry =>
13− _setBirthdayCache(cache => ({
14− ...cache,
15− ...entry,
16− })),
17− [_setBirthdayCache]
18− );
19−
20− const getBirthday = useCallback(point => birthdayCache[point] || Nothing(), [
21− birthdayCache,
22− ]);
23−
24− const syncBirthday = useCallback(
25− async point => {
26− const _contracts = contracts.getOrElse(null);
27− const _web3 = web3.getOrElse(null);
28− if (!_contracts || !_web3) {
29− return;
30− }
31−
32− // birthday will not change after being set, so bail if we already know
33− if (Just.hasInstance(getBirthday(point))) {
34− return;
35− }
36−
37− const birthBlock = await azimuth.azimuth.getActivationBlock(
38− _contracts,
39− point
40− );
41−
42− if (birthBlock > 0) {
43− const block = await _web3.eth.getBlock(birthBlock);
44− addToBirthdayCache({
45− [point]: Just(new Date(block.timestamp * 1000)),
46− });
47− } else {
48− // TODO: better encoding for "no birthday" state using Result.Ok/Error
49− // if there's no birthday, just use today
50− addToBirthdayCache({
51− [point]: Just(new Date()),
52− });
53− }
54− },
55− [contracts, web3, addToBirthdayCache, getBirthday]
56− );
57−
58− return { getBirthday, syncBirthday };
59−}
src/store/lib/usePointStore.js+2−5
@@ -1,7 +1,6 @@
1import { useCallback } from 'react';
1import { useCallback } from 'react';
2
2
3import useDetailsStore from './useDetailsStore';
3import useDetailsStore from './useDetailsStore';
4−import useBirthdaysStore from './useBirthdaysStore';
5import useRekeyDateStore from './useRekeyDateStore';
4import useRekeyDateStore from './useRekeyDateStore';
6import useInvitesStore from './useInvitesStore';
5import useInvitesStore from './useInvitesStore';
7import useControlledPointsStore from './useControlledPointsStore';
6import useControlledPointsStore from './useControlledPointsStore';
@@ -10,7 +9,6 @@ import useResidents from './useResidentsStore';
10
9
11export default function usePointStore() {
10export default function usePointStore() {
12 const { syncDetails, ...details } = useDetailsStore();
11 const { syncDetails, ...details } = useDetailsStore();
13− const { syncBirthday, ...birthdays } = useBirthdaysStore();
14 const { syncRekeyDate, ...rekeyDates } = useRekeyDateStore();
12 const { syncRekeyDate, ...rekeyDates } = useRekeyDateStore();
15 const { syncInvites, ...invites } = useInvitesStore();
13 const { syncInvites, ...invites } = useInvitesStore();
16 const {
14 const {
@@ -21,8 +19,8 @@ export default function usePointStore() {
21 const ecliptic = useEclipticOwnerStore();
19 const ecliptic = useEclipticOwnerStore();
22
20
23 const syncDates = useCallback(
21 const syncDates = useCallback(
24− async point => Promise.all([syncBirthday(point), syncRekeyDate(point)]),
22+ async point => Promise.all([syncRekeyDate(point)]),
25− [syncBirthday, syncRekeyDate]
23+ [syncRekeyDate]
26 );
24 );
27
25
28 const syncExtras = useCallback(
26 const syncExtras = useCallback(
@@ -39,7 +37,6 @@ export default function usePointStore() {
39
37
40 return {
38 return {
41 ...details,
39 ...details,
42− ...birthdays,
43 ...rekeyDates,
40 ...rekeyDates,
44 ...invites,
41 ...invites,
45 ...controlledPoints,
42 ...controlledPoints,