@@ -76,7 +76,7 @@ export class ManagerFetchComponent implements OnInit, AfterViewInit {
7676
7777 getPushedItem ( ) {
7878 const itemsToPull = this . selection . selected . map ( id => findByIdInArray ( this . pushedItems . data , id ) ) ;
79- const replicators = this . createRepicatorsArray ( itemsToPull , [ ] ) ;
79+ const replicators = this . syncService . createRepicatorsArray ( itemsToPull , 'pull' , [ ] ) ;
8080 const deleteItems = itemsToPull . map ( sentItem => ( { _id : sentItem . _id , _rev : sentItem . _rev , _deleted : true } ) ) ;
8181 if ( replicators . length > 0 ) {
8282 this . syncService . confirmPasswordAndRunReplicators ( replicators ) . pipe (
@@ -87,31 +87,4 @@ export class ManagerFetchComponent implements OnInit, AfterViewInit {
8787 }
8888 }
8989
90- createRepicatorsArray ( itemsToPull , replicators = [ ] ) {
91- return itemsToPull . reduce ( ( newReplicators : any [ ] , item : any ) => {
92- const pullItem = item . item ;
93- let pullObject = newReplicators . find ( ( replicator : any ) => replicator . db === item . db ) ;
94- if ( ! pullObject ) {
95- pullObject = { db : item . db , type : 'pull' , date : true , items : [ pullItem ] } ;
96- newReplicators . push ( pullObject ) ;
97- } else {
98- pullObject . items . push ( pullItem ) ;
99- }
100- if ( item . db === 'courses' ) {
101- return this . coursesItemsToPull ( pullItem , newReplicators ) ;
102- }
103- return newReplicators ;
104- } , replicators ) ;
105- }
106-
107- coursesItemsToPull ( course , replicators ) {
108- return this . createRepicatorsArray (
109- [ ] . concat . apply ( [ ] , course . steps . map ( step =>
110- step . resources . map ( r => ( { item : r , db : 'resources' } ) )
111- . concat ( step . exam ? [ { item : step . exam , db : 'exams' } ] : [ ] ) )
112- ) ,
113- replicators
114- ) ;
115- }
116-
11790}
0 commit comments