summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-10-06 13:17:43 +0200
committerThomas F. K. Jorna <[email protected]>2021-10-06 13:17:43 +0200
commitbae6487afd5e6eec9f04b38b235bbac24042ca62 (patch)
treedf6a72d934f8731f86524f2812481b8bcdfebd25 /pages
parent0f22a091900c803fbca5023c56be923a2bafc248 (diff)
feat: filter dailes (#68)
Diffstat (limited to 'pages')
-rw-r--r--pages/index.tsx18
1 files changed, 16 insertions, 2 deletions
diff --git a/pages/index.tsx b/pages/index.tsx
index 4f01de8..a40f942 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -89,6 +89,7 @@ export function GraphPage() {
const linksByNodeIdRef = useRef<LinksByNodeId>({})
const tagsRef = useRef<Tags>([])
const graphRef = useRef<any>(null)
+ const variablesRef = useRef<{ [variable: string]: string }>({})
const currentGraphDataRef = useRef<GraphData>({ nodes: [], links: [] })
@@ -358,6 +359,10 @@ export function GraphPage() {
switch (message.type) {
case 'graphdata':
return updateGraphData(message.data)
+ case 'variables':
+ variablesRef.current = message.data
+ console.log(message.data)
+ return
case 'theme':
return setEmacsTheme(['custom', message.data])
case 'command':
@@ -432,6 +437,7 @@ export function GraphPage() {
nodeById={nodeByIdRef.current!}
linksByNodeId={linksByNodeIdRef.current!}
webSocket={WebSocketRef.current}
+ variables={variablesRef.current}
{...{
physics,
graphData,
@@ -466,6 +472,7 @@ export interface GraphProps {
setScope: any
webSocket: any
tagColors: { [tag: string]: string }
+ variables: { [variable: string]: string }
}
export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
@@ -484,8 +491,10 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
setScope,
webSocket,
tagColors,
+ variables,
} = props
+ const { dailyDir, roamDir } = variables
// react-force-graph does not track window size
// https://github.com/vasturiano/react-force-graph/issues/233
// does not work below a certain width
@@ -605,14 +614,14 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
const node = nodeArg as OrgRoamNode
if (
filter.tagsBlacklist.length &&
- filter.tagsBlacklist.some((tag) => node.tags.indexOf(tag) > -1)
+ filter.tagsBlacklist.some((tag) => node?.tags?.indexOf(tag) > -1)
) {
hiddenNodeIdsRef.current = { ...hiddenNodeIdsRef.current, [node.id]: node }
return false
}
if (
filter.tagsWhitelist.length > 0 &&
- !filter.tagsWhitelist.some((tag) => node.tags.indexOf(tag) > -1)
+ !filter.tagsWhitelist.some((tag) => node?.tags?.indexOf(tag) > -1)
) {
hiddenNodeIdsRef.current = { ...hiddenNodeIdsRef.current, [node.id]: node }
return false
@@ -625,6 +634,11 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
hiddenNodeIdsRef.current = { ...hiddenNodeIdsRef.current, [node.id]: node }
return false
}
+
+ if (filter.dailies && dailyDir?.length !== 0 && node.file.includes(dailyDir)) {
+ hiddenNodeIdsRef.current = { ...hiddenNodeIdsRef.current, [node.id]: node }
+ return false
+ }
return true
})
.filter((node) => {