@@ -64,39 +64,6 @@ var HttpRepository = /** @class */ (function (_super) {
6464 this . deleteItem ( itemUUID ) ;
6565 }
6666 } ;
67- /**
68- * flush items
69- *
70- * @param itemsToUpdate
71- * @param itemsToDelete
72- *
73- * @Returns {Promise<void>}
74- */
75- HttpRepository . prototype . flushItems = function ( itemsToUpdate , itemsToDelete ) {
76- return tslib_1 . __awaiter ( this , void 0 , void 0 , function ( ) {
77- var _a , _b , _c ;
78- return tslib_1 . __generator ( this , function ( _d ) {
79- switch ( _d . label ) {
80- case 0 :
81- _b = ( _a = Promise ) . all ;
82- return [ 4 /*yield*/ , this . flushUpdateItems ( itemsToUpdate ) ] ;
83- case 1 :
84- _c = [
85- _d . sent ( )
86- ] ;
87- return [ 4 /*yield*/ , this . flushDeleteItems ( itemsToDelete ) ] ;
88- case 2 : return [ 4 /*yield*/ , _b . apply ( _a , [ _c . concat ( [
89- _d . sent ( )
90- ] ) ] ) . then ( function ( _ ) {
91- return ;
92- } ) ] ;
93- case 3 :
94- _d . sent ( ) ;
95- return [ 2 /*return*/ ] ;
96- }
97- } ) ;
98- } ) ;
99- } ;
10067 /**
10168 * Flush update items
10269 *
@@ -107,21 +74,19 @@ var HttpRepository = /** @class */ (function (_super) {
10774 HttpRepository . prototype . flushUpdateItems = function ( itemsToUpdate ) {
10875 return tslib_1 . __awaiter ( this , void 0 , void 0 , function ( ) {
10976 return tslib_1 . __generator ( this , function ( _a ) {
110- switch ( _a . label ) {
111- case 0 : return [ 4 /*yield*/ , ( itemsToUpdate . length > 0 ) ] ;
112- case 1 : return [ 2 /*return*/ , ( _a . sent ( ) )
113- ? this
114- . httpClient
115- . get ( "/items" , "post" , this . getCredentials ( ) , { } , {
116- items : itemsToUpdate . map ( function ( item ) {
117- return item . toArray ( ) ;
118- } )
119- } )
120- . then ( function ( response ) {
121- HttpRepository . throwTransportableExceptionIfNeeded ( response ) ;
122- } )
123- : null ] ;
77+ if ( itemsToUpdate . length === 0 ) {
78+ return [ 2 /*return*/ ] ;
12479 }
80+ return [ 2 /*return*/ , this
81+ . httpClient
82+ . get ( "/items" , "post" , this . getCredentials ( ) , { } , {
83+ items : itemsToUpdate . map ( function ( item ) {
84+ return item . toArray ( ) ;
85+ } )
86+ } )
87+ . then ( function ( response ) {
88+ HttpRepository . throwTransportableExceptionIfNeeded ( response ) ;
89+ } ) ] ;
12590 } ) ;
12691 } ) ;
12792 } ;
@@ -135,21 +100,19 @@ var HttpRepository = /** @class */ (function (_super) {
135100 HttpRepository . prototype . flushDeleteItems = function ( itemsToDelete ) {
136101 return tslib_1 . __awaiter ( this , void 0 , void 0 , function ( ) {
137102 return tslib_1 . __generator ( this , function ( _a ) {
138- switch ( _a . label ) {
139- case 0 : return [ 4 /*yield*/ , ( itemsToDelete . length > 0 ) ] ;
140- case 1 : return [ 2 /*return*/ , ( _a . sent ( ) )
141- ? this
142- . httpClient
143- . get ( "/items" , "delete" , this . getCredentials ( ) , { } , {
144- items : itemsToDelete . map ( function ( itemUUID ) {
145- return itemUUID . toArray ( ) ;
146- } )
147- } )
148- . then ( function ( response ) {
149- HttpRepository . throwTransportableExceptionIfNeeded ( response ) ;
150- } )
151- : null ] ;
103+ if ( itemsToDelete . length === 0 ) {
104+ return [ 2 /*return*/ ] ;
152105 }
106+ return [ 2 /*return*/ , this
107+ . httpClient
108+ . get ( "/items" , "delete" , this . getCredentials ( ) , { } , {
109+ items : itemsToDelete . map ( function ( itemUUID ) {
110+ return itemUUID . toArray ( ) ;
111+ } )
112+ } )
113+ . then ( function ( response ) {
114+ HttpRepository . throwTransportableExceptionIfNeeded ( response ) ;
115+ } ) ] ;
153116 } ) ;
154117 } ) ;
155118 } ;
0 commit comments