1import { useEffect } from 'react';
2import { isEqual } from 'lodash';
4import { usePointCache } from 'store/pointCache';
5import usePreviousValue from 'lib/usePreviousValue';
7// sync a known (i.e. mine) point to the cache (i.e display values)
8export function useSyncKnownPoints(points = []) {
9 // TBD: right now we don't need anything more than the point itself
10 // but soon we'll need to know information around "key type"
13// sync a foreign (not the user's) point to the cache
14export function useSyncForeignPoints(points = []) {
15 const { syncForeignPoint } = usePointCache();
16 const prevPoints = usePreviousValue(points);
19 if (!isEqual(prevPoints, points)) {
20 // if the actual set of points changes, sync the whole array
21 // TODO: we should get clever about caching
22 points.forEach(point => syncForeignPoint(point));
24 }, [syncForeignPoint, prevPoints, points]);
27// sync an owned point to the cache
28export function useSyncOwnedPoints(points = []) {
29 const { syncOwnedPoint } = usePointCache();
30 const prevPoints = usePreviousValue(points);
33 if (!isEqual(prevPoints, points)) {
34 // if the actual set of points changes, sync the whole array
35 // TODO: we should get clever about caching
36 points.forEach(point => syncOwnedPoint(point));
38 }, [syncOwnedPoint, prevPoints, points]);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list