@@ -223,21 +223,19 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
223223 this . _loadingResourcesBtn . setVisibility ( "visible" ) ;
224224 this . __getNextStudiesRequest ( )
225225 . then ( resp => {
226- const urlParams = resp [ "params" ] [ "url" ] ;
227226 // Context might have been changed while waiting for the response.
228227 // The new call is on the way, therefore this response can be ignored.
229- if ( "workspaceId" in urlParams ) {
230- if (
231- urlParams . workspaceId !== this . getCurrentWorkspaceId ( ) ||
232- urlParams . folderId !== this . getCurrentFolderId ( )
233- ) {
234- return ;
235- }
236- } else if ( "text" in urlParams ) {
237- const currentFilterData = this . _searchBarFilter . getFilterData ( ) ;
238- if ( currentFilterData . text && urlParams . text !== encodeURIComponent ( currentFilterData . text ) ) {
239- return ;
228+ const reqParams = osparc . utils . Utils . deepCloneObject ( resp [ "params" ] [ "url" ] ) ;
229+ delete reqParams [ "limit" ] ;
230+ delete reqParams [ "offset" ] ;
231+ const currentParams = this . __getRequestParams ( ) ;
232+ if ( JSON . stringify ( reqParams ) !== JSON . stringify ( currentParams ) ) {
233+ // it did change
234+ console . log ( "context changed" ) ;
235+ if ( this . _resourcesContainer . getFlatList ( ) ) {
236+ this . _resourcesContainer . getFlatList ( ) . nextRequest = null ;
240237 }
238+ return ;
241239 }
242240
243241 const studies = resp [ "data" ] ;
@@ -629,33 +627,36 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
629627 return null ;
630628 } ,
631629
632- __getPageParams : function ( ) {
630+ __getRequestParams : function ( ) {
631+ const requestParams = { } ;
632+ requestParams . orderBy = JSON . stringify ( this . getOrderBy ( ) ) ;
633+
633634 const filterData = this . _searchBarFilter . getFilterData ( ) ;
634635 if ( filterData . text || filterData . tags . length ) {
635- const searchParams = { } ;
636- searchParams . text = "" ;
637- searchParams . tags = "" ;
636+ console . log ( "Search:" ) ;
637+ console . log ( filterData . text ) ;
638+ console . log ( filterData . tags ) ;
639+ requestParams . text = "" ;
640+ requestParams . tags = "" ;
638641 if ( filterData . text ) {
639- searchParams . text = encodeURIComponent ( filterData . text ) ; // name, description and uuid
642+ requestParams . text = encodeURIComponent ( filterData . text ) ; // name, description and uuid
640643 }
641- if ( searchParams . tags ) {
642- searchParams . tags = filterData . tags . join ( "," ) ;
644+ if ( filterData . tags . length ) {
645+ requestParams . tags = filterData . tags . join ( "," ) ;
643646 }
644- return searchParams ;
647+ return requestParams ;
645648 }
646649
647- const contextParams = { } ;
648- contextParams . workspaceId = this . getCurrentWorkspaceId ( ) ;
649- contextParams . folderId = this . getCurrentFolderId ( ) ;
650- return contextParams ;
650+ requestParams . workspaceId = this . getCurrentWorkspaceId ( ) ;
651+ requestParams . folderId = this . getCurrentFolderId ( ) ;
652+ return requestParams ;
651653 } ,
652654
653655 __getNextStudiesRequest : function ( ) {
654656 const params = {
655657 url : {
656658 offset : 0 ,
657659 limit : osparc . dashboard . ResourceBrowserBase . PAGINATED_STUDIES ,
658- orderBy : JSON . stringify ( this . getOrderBy ( ) ) ,
659660 }
660661 } ;
661662
@@ -668,11 +669,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
668669 resolveWResponse : true
669670 } ;
670671
671- const pageParams = this . __getPageParams ( ) ;
672- Object . entries ( pageParams ) . forEach ( ( [ key , value ] ) => {
672+ const requestParams = this . __getRequestParams ( ) ;
673+ Object . entries ( requestParams ) . forEach ( ( [ key , value ] ) => {
673674 params . url [ key ] = value ;
674675 } ) ;
675- if ( "text" in pageParams ) {
676+ if ( "text" in requestParams ) {
676677 return osparc . data . Resources . fetch ( "studies" , "getPageSearch" , params , undefined , options ) ;
677678 }
678679 return osparc . data . Resources . fetch ( "studies" , "getPage" , params , undefined , options ) ;
0 commit comments