Skip to content

Commit

Permalink
manager: smoother fetch items (fixes #7463) (#7464)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Mutugiii and dogi authored May 22, 2024
1 parent f1bfd98 commit a60d6d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.14.33",
"version": "0.14.34",
"myplanet": {
"latest": "v0.15.34",
"min": "v0.14.34"
"latest": "v0.15.36",
"min": "v0.14.36"
},
"scripts": {
"ng": "ng",
Expand Down
7 changes: 5 additions & 2 deletions src/app/shared/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { Validators } from '@angular/forms';
import { CouchService } from '../shared/couchdb.service';
import { forkJoin, Observable, throwError, of } from 'rxjs';
import { switchMap, map, takeWhile, catchError } from 'rxjs/operators';
import { switchMap, map, takeWhile, catchError, take } from 'rxjs/operators';
import { environment } from '../../environments/environment';
import { StateService } from './state.service';
import { TagsService } from './forms/tags.service';
Expand Down Expand Up @@ -136,8 +136,11 @@ export class SyncService {
};
}

// hack: we take the first observable from the array on initialization since we get 2 as opposed to 1
replicatorsArrayWithTags(items, type: 'pull' | 'push', planetField: 'local' | 'parent') {
return this.stateService.getCouchState('tags', planetField).pipe(map(tags => this.createReplicatorsArray(items, type, tags)));
return this.stateService.getCouchState('tags', planetField).pipe(
take(1),
map(tags => this.createReplicatorsArray(items, type, tags)));
}

createReplicatorsArray(items, type: 'pull' | 'push', allTags: any[] = [], replicators = []) {
Expand Down

0 comments on commit a60d6d6

Please sign in to comment.