File tree Expand file tree Collapse file tree 4 files changed +52
-1
lines changed
react-notion-x/src/third-party Expand file tree Collapse file tree 4 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,21 @@ export class NotionAPI {
125
125
collectionId,
126
126
collectionViewId
127
127
} ) )
128
+ } else if ( block && ( block as any ) . view_ids ) {
129
+ return ( block as any ) . view_ids . map ( ( collectionViewId ) => {
130
+ if ( recordMap . collection_view [ collectionViewId ] ) {
131
+ const viewBlock =
132
+ recordMap . collection_view [ collectionViewId ] . value
133
+ const collectionId = viewBlock . format ?. collection_pointer ?. id
134
+ if ( collectionId ) {
135
+ return {
136
+ collectionId,
137
+ collectionViewId
138
+ }
139
+ }
140
+ }
141
+ return null
142
+ } )
128
143
} else {
129
144
return [ ]
130
145
}
@@ -421,6 +436,16 @@ export class NotionAPI {
421
436
}
422
437
}
423
438
439
+ //TODO: started working on the filters. This doens't seem to quite work yet.
440
+ // let filters = collectionView.format?.property_filters.map(filterObj => {
441
+ // console.log('map filter', filterObj)
442
+ // //get the inner filter
443
+ // return {
444
+ // filter: filterObj.filter.filter,
445
+ // property: filterObj.filter.property
446
+ // }
447
+ // })
448
+
424
449
const reducerLabel = isBoardType ? 'board_columns' : `${ type } _groups`
425
450
loader = {
426
451
type : 'reducer' ,
@@ -439,6 +464,11 @@ export class NotionAPI {
439
464
...collectionView ?. query2 ,
440
465
searchQuery,
441
466
userTimeZone
467
+ //TODO: add filters here
468
+ // filter: {
469
+ // filters: filters,
470
+ // operator: 'and'
471
+ // }
442
472
}
443
473
}
444
474
Original file line number Diff line number Diff line change
1
+ import {
2
+ CollectionViewBlock ,
3
+ CollectionViewPageBlock ,
4
+ ExtendedRecordMap
5
+ } from 'notion-types'
6
+
7
+ export function getBlockCollectionPointerId (
8
+ recordMap : ExtendedRecordMap ,
9
+ block : CollectionViewBlock | CollectionViewPageBlock
10
+ ) : string | null {
11
+ const collectionViewId = ( block as any ) . view_ids [ 0 ]
12
+ if ( recordMap . collection_view [ collectionViewId ] ) {
13
+ const viewBlock = recordMap . collection_view [ collectionViewId ] . value
14
+ const collectionId = viewBlock . format ?. collection_pointer ?. id
15
+ return collectionId
16
+ }
17
+ return null
18
+ }
Original file line number Diff line number Diff line change @@ -21,3 +21,4 @@ export * from './normalize-title'
21
21
export * from './merge-record-maps'
22
22
export * from './format-date'
23
23
export * from './format-notion-date-time'
24
+ export * from './get-block-collection-pointer-id'
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import * as React from 'react'
2
2
import * as types from 'notion-types'
3
3
import {
4
4
getBlockCollectionId ,
5
+ getBlockCollectionPointerId ,
5
6
getBlockParentPage ,
6
7
getTextContent
7
8
} from 'notion-utils'
@@ -83,7 +84,8 @@ const CollectionViewBlock: React.FC<{
83
84
} > = ( { block, className } ) => {
84
85
const { recordMap, showCollectionViewDropdown } = useNotionContext ( )
85
86
const { view_ids : viewIds } = block
86
- const collectionId = getBlockCollectionId ( block )
87
+ const collectionId =
88
+ getBlockCollectionId ( block ) ?? getBlockCollectionPointerId ( recordMap , block )
87
89
88
90
const [ isMounted , setIsMounted ] = React . useState ( false )
89
91
React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments