@@ -1,6 +1,7 @@
11import { useCallback } from 'react';
22import { Just, Nothing } from 'folktale/maybe';
33import * as azimuth from 'azimuth-js';
4+import { chain } from 'lodash';
45
56import { useNetwork } from '../network';
67import useSetState from 'lib/useSetState';
@@ -10,6 +11,8 @@ const EMPTY_INVITES = {
1011 availableInvites: Nothing(),
1112 sentInvites: Nothing(),
1213 acceptedInvites: Nothing(),
14+ acceptedPoints: Nothing(),
15+ pendingPoints: Nothing(),
1316};
1417
1518export default function useInvitesStore() {
@@ -42,11 +45,23 @@ export default function useInvitesStore() {
4245 const sentInvites = invitedPoints.length;
4346 const acceptedInvites = activity.filter(i => !!i).length;
4447
48+ console.log(invitedPoints);
49+
50+ const [acceptedPoints, pendingPoints] = chain(invitedPoints)
51+ .zipWith(activity, (point, active) => ({
52+ point,
53+ active: !!active,
54+ }))
55+ .partition('active')
56+ .map(arr => arr.map(x => x.point));
57+
4558 addToInvitesCache({
4659 [point]: {
4760 availableInvites: Just(availableInvites),
4861 sentInvites: Just(sentInvites),
4962 acceptedInvites: Just(acceptedInvites),
63+ pendingPoints: Just(pendingPoints),
64+ acceptedPoints: Just(acceptedPoints),
5065 },
5166 });
5267 },