@@ -4,7 +4,7 @@ import DataBrowserSidebar from "./DataBrowserSidebar";
44import { useLazyQuery } from "@apollo/client" ;
55import { DATA_SLICES , GET_RECORD_COMMENTS , GET_UNIQUE_VALUES_BY_ATTRIBUTES , SEARCH_RECORDS_EXTENDED } from "@/src/services/gql/queries/data-browser" ;
66import { useCallback , useEffect , useState } from "react" ;
7- import { expandRecordList , selectRecords , setActiveDataSlice , setDataSlices , setRecordComments , setSearchRecordsExtended , setUniqueValuesDict , setUsersMapCount , updateAdditionalDataState } from "@/src/reduxStore/states/pages/data-browser" ;
7+ import { expandRecordList , selectActiveSearchParams , selectConfiguration , selectFullSearchStore , selectRecords , setActiveDataSlice , setDataSlices , setRecordComments , setSearchRecordsExtended , setUniqueValuesDict , setUsersMapCount , updateAdditionalDataState } from "@/src/reduxStore/states/pages/data-browser" ;
88import { postProcessRecordsExtended , postProcessUniqueValues , postProcessUsersCount } from "@/src/util/components/projects/projectId/data-browser/data-browser-helper" ;
99import { GET_ATTRIBUTES_BY_PROJECT_ID , GET_EMBEDDING_SCHEMA_BY_PROJECT_ID , GET_LABELING_TASKS_BY_PROJECT_ID } from "@/src/services/gql/queries/project-setting" ;
1010import { selectAttributes , selectLabelingTasksAll , setAllAttributes , setAllEmbeddings , setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings" ;
@@ -18,6 +18,8 @@ import { CommentType } from "@/src/types/shared/comments";
1818import { CommentDataManager } from "@/src/util/classes/comments" ;
1919import { REQUEST_COMMENTS } from "@/src/services/gql/queries/projects" ;
2020import { useWebsocket } from "@/src/services/base/web-sockets/useWebsocket" ;
21+ import { parseFilterToExtended } from "@/src/util/components/projects/projectId/data-browser/filter-parser-helper" ;
22+ import { SearchGroup } from "@/submodules/javascript-functions/enums/enums" ;
2123
2224const SEARCH_REQUEST = { offset : 0 , limit : 20 } ;
2325
@@ -30,7 +32,10 @@ export default function DataBrowser() {
3032 const attributes = useSelector ( selectAttributes ) ;
3133 const user = useSelector ( selectUser ) ;
3234 const recordList = useSelector ( selectRecords ) . recordList ;
33-
35+ const activeSearchParams = useSelector ( selectActiveSearchParams ) ;
36+ const configuration = useSelector ( selectConfiguration ) ;
37+ const fullSearchStore = useSelector ( selectFullSearchStore ) ;
38+ const fullCount = useSelector ( selectRecords ) . fullCount ;
3439
3540 const [ searchRequest , setSearchRequest ] = useState ( SEARCH_REQUEST ) ;
3641
@@ -61,15 +66,16 @@ export default function DataBrowser() {
6166 } , [ projectId , labelingTasks , recordList ] ) ;
6267
6368 useEffect ( ( ) => {
64- if ( ! projectId ) return ;
69+ if ( ! projectId || ! labelingTasks || ! attributes ) return ;
6570 if ( ! searchRequest ) return ;
66- if ( searchRequest . offset == 0 ) return ;
67- refetchExtendedRecord ( { variables : { projectId : projectId , filterData : JSON . stringify ( { } ) , offset : searchRequest . offset , limit : searchRequest . limit } } ) . then ( ( res ) => {
71+ if ( searchRequest . offset == 0 || searchRequest . offset > fullCount ) return ;
72+ const filterData = parseFilterToExtended ( activeSearchParams , attributes , configuration , labelingTasks , user , fullSearchStore [ SearchGroup . DRILL_DOWN ] )
73+ refetchExtendedRecord ( { variables : { projectId : projectId , filterData : filterData , offset : searchRequest . offset , limit : searchRequest . limit } } ) . then ( ( res ) => {
6874 const parsedRecordData = postProcessRecordsExtended ( res . data [ 'searchRecordsExtended' ] , labelingTasks ) ;
6975 dispatch ( expandRecordList ( parsedRecordData ) ) ;
7076 refetchRecordCommentsAndProcess ( parsedRecordData . recordList ) ;
7177 } ) ;
72- } , [ searchRequest ] ) ;
78+ } , [ searchRequest , activeSearchParams , projectId , attributes , configuration , labelingTasks , user , fullSearchStore ] ) ;
7379
7480 useEffect ( ( ) => {
7581 if ( ! projectId || users . length == 0 ) return ;
@@ -139,6 +145,7 @@ export default function DataBrowser() {
139145 }
140146
141147 function getNextRecords ( ) {
148+ console . log ( 'getNextRecords?' )
142149 setSearchRequest ( { offset : searchRequest . offset + searchRequest . limit , limit : searchRequest . limit } ) ;
143150 }
144151
@@ -148,6 +155,10 @@ export default function DataBrowser() {
148155 } ) ;
149156 }
150157
158+ const setSearchRequestToInit = useCallback ( ( ) => {
159+ setSearchRequest ( SEARCH_REQUEST ) ;
160+ } , [ ] ) ;
161+
151162 const handleWebsocketNotification = useCallback ( ( msgParts : string [ ] ) => {
152163 if ( [ 'data_slice_created' , 'data_slice_updated' , 'data_slice_deleted' ] . includes ( msgParts [ 1 ] ) ) {
153164 refetchDataSlicesAndProcess ( msgParts [ 2 ] ) ;
@@ -169,7 +180,7 @@ export default function DataBrowser() {
169180 return ( < >
170181 { projectId && < div className = "flex flex-row h-full" >
171182 < DataBrowserSidebar />
172- < DataBrowserRecords refetchNextRecords = { getNextRecords } />
183+ < DataBrowserRecords refetchNextRecords = { getNextRecords } clearSearchRequest = { setSearchRequestToInit } />
173184 </ div > }
174185 </ > )
175186}
0 commit comments