File tree Expand file tree Collapse file tree 2 files changed +24
-13
lines changed
services/static-webserver/client/source/class/osparc Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,31 @@ qx.Class.define("osparc.store.Conversations", {
2222 construct : function ( ) {
2323 this . base ( arguments ) ;
2424
25- this . __pricingPlansCached = [ ] ;
25+ this . __projectConversations = { } ;
2626 } ,
2727
2828 members : {
29- __pricingPlansCached : null ,
29+ __projectConversations : null ,
30+
31+ getConversations : function ( studyId ) {
32+ const params = {
33+ url : {
34+ studyId,
35+ offset : 0 ,
36+ limit : 42 ,
37+ }
38+ } ;
39+ return osparc . data . Resources . fetch ( "conversations" , "getConversationsPage" , params )
40+ . then ( conversations => {
41+ if ( conversations . length ) {
42+ // Sort conversations by created date, oldest first (the new ones will be next to the plus button)
43+ conversations . sort ( ( a , b ) => new Date ( a [ "created" ] ) - new Date ( b [ "created" ] ) ) ;
44+ }
45+ // OM add to cache
46+ return conversations ;
47+ } )
48+ . catch ( err => osparc . FlashMessenger . logError ( err ) ) ;
49+ } ,
3050
3151 addConversation : function ( studyId , name = "new 1" , type = this . TYPES . PROJECT_STATIC ) {
3252 const params = {
@@ -39,6 +59,7 @@ qx.Class.define("osparc.store.Conversations", {
3959 }
4060 } ;
4161 return osparc . data . Resources . fetch ( "conversations" , "addConversation" , params )
62+ . then
4263 . catch ( err => osparc . FlashMessenger . logError ( err ) ) ;
4364 } ,
4465
Original file line number Diff line number Diff line change @@ -155,18 +155,9 @@ qx.Class.define("osparc.study.Conversations", {
155155 const loadMoreButton = this . getChildControl ( "loading-button" ) ;
156156 loadMoreButton . setFetching ( true ) ;
157157
158- const params = {
159- url : {
160- studyId : studyData [ "uuid" ] ,
161- offset : 0 ,
162- limit : 42 ,
163- }
164- } ;
165- osparc . data . Resources . fetch ( "conversations" , "getConversationsPage" , params )
158+ osparc . store . Conversations . getInstance ( ) . getConversations ( studyData [ "uuid" ] )
166159 . then ( conversations => {
167160 if ( conversations . length ) {
168- // Sort conversations by created date, oldest first (the new ones will be next to the plus button)
169- conversations . sort ( ( a , b ) => new Date ( a [ "created" ] ) - new Date ( b [ "created" ] ) ) ;
170161 conversations . forEach ( conversation => this . __addConversationPage ( conversation ) ) ;
171162 if ( this . __openConversationId ) {
172163 const conversationsLayout = this . getChildControl ( "conversations-layout" ) ;
@@ -180,7 +171,6 @@ qx.Class.define("osparc.study.Conversations", {
180171 this . __addTempConversationPage ( ) ;
181172 }
182173 } )
183- . catch ( err => osparc . FlashMessenger . logError ( err ) )
184174 . finally ( ( ) => {
185175 loadMoreButton . setFetching ( false ) ;
186176 loadMoreButton . exclude ( ) ;
You can’t perform that action at this time.
0 commit comments