yuuvis® RAD Q&A

0 votes
by (380 points)

Hello yuuvis-team,

I am trying to delete an item out of the users`s favorites while being subscribed to userService.favorites$ and userService.getFavorites().

userService.removeFavorite() succeeds returning "null", then the subscriptions deliver a new array of favorites - but one still containing the removed favorite!

Adding a new favorite using userService.createFavorite() does not show this phenomenon - after success, the subscriptions return a new array of favorites containing the newly created one.

This is really annoying:
The user still sees the (removed) favorite. Trying to remove it again results in an error (404 not found - sounds reasonable though, it was removed!)

Is this a bug in @eo-sdk/core (6.12.0), in yuuvis (6.16.2) or am I doing something wrong?

Thanks,
Stefan

2 Answers

0 votes
by (380 points)

Updateing @eo-sdk/core to 6.16.2 doesn`t help, btw. Seems logic, I guess the issue is in the backend.

Any clue about this anybody?

by (18.5k points)
Hi Stefan,

this seems to be a bug. I have created this internal Ticket for our analyses: DB-5366

But it could be good to report this bug to support@optimal-systems.de so that the bugfix-process will go well.

We will probably deliver the bugfix with the next hotfix.

Kind Regards
Martin
by (380 points)
Hello Martin,

thanks. I sent the bug once more, as requested.

Kind Regards,
Stefan
0 votes
by (18.5k points)

Hi Stefan,

sorry for taking some more time for analyses! It's not really bug, if you do not to call the backend via rest, but use the client's userService instead.

Peter wrote this:

"Hi, please look at our example of Favorite Action in Client

Main difference is that we use userService... that way our components subscribe to all changes on this.userService.favorites$

constructor( private userService: UserService) {

}
run(selection: DmsObject[]) { selection.forEach(item => { const

{id, typeName, title}
= item; if (!item.isFavorite) { this.userService .createFavorite(id, typeName, title || id) .subscribe(() =>

{ this.eventService.trigger(EnaioEvent.DMS_OBJECT_FAVORITE_ON, id) }
, Utils.throw(null, this.translate.instant('eo.state.settings.presence.error.title'), this.translate.instant('eo.state.settings.presence.error.description') )); // todo: add proper error messages here } else { this.userService .removeFavoritesForTarget(id) .subscribe(() =>

{ this.eventService.trigger(EnaioEvent.DMS_OBJECT_FAVORITE_OFF, id) }
, Utils.throw(null, this.translate.instant('eo.state.settings.presence.error.title'), this.translate.instant('eo.state.settings.presence.error.description') )); // todo: add proper error messages here } }); } "

If you do need some more explanations we may take an appointment then.

Kind Regards,
Martin

by (380 points)
Hello Martin,

sorry, had a few weeks of "do this NOW!" and came back to this only now.

The ony difference I see between my code and yours is the use of this.userService.removeFavoritesForTarget() instead of this.userService.removeFavorite(). I changed that in my code, the result is the same.

The favorite is removed, but still returned by the subscription immediately after that.
I still think this is a bug.

My code (shortened):

  private favoritesSubscription: Subscription;
  private favorites: any[];

 constructor(private router: Router,
    private searchService: SearchService,
    private userService: UserService) {

    this.favoritesSubscription = this.userService.favorites$.subscribe(
      favorites => {
        console.log(favorites);
        // filter favorites to only serve desired context types
        this.favorites = favorites.filter(f => this.contextTypes.indexOf(f.target.type) !== -1);
        this.listFavorites();
      }
    );
  }
 toggleFavorite(item: FileListEntry) {
    if (item.isFavorite) {
      // this.userService.removeFavorite(this.favorites.find(f => f.target.id === item.objectId).id ).subscribe(x => console.log(x));
      console.log('Remove favorite ' + item.objectId);
      this.userService.removeFavoritesForTarget(item.objectId).subscribe(console.log, console.log);
    } else {
      this.userService.createFavorite(item.objectId, item.objectType, item.title).subscribe();
    }
  }

 listFavorites() {
    this.showSearchResult = false;
    this.loading = false;
    this.files = this.favorites.map(f => {
      return {
        objectId: f.target.id,
        objectType: f.target.type,
        title: f.title,
        description: f.description,
        isFavorite: true
      };
    });
  }

 ngOnInit() {
    this.loading = true;
    this.userService.getFavorites().subscribe();
  }


Kind regards,
Stefan
by (18.5k points)
edited by
Hi Stefan,

Yes, this smells like a bug. So, please, can you take the usual way for bugs via support@optimal-systems.de for reporting and tracking the fix?

Thx Martin
by (380 points)
Hello Martin,

ok, sent another email. First mail was sent 09.04.2021, as stated above.

HTH,
Stefan
by (18.5k points)
Hi Stefan,

OK, yes, the former ticket was closed because we expected that Peters's notice will lead to the correct behavior.

BR Martin

Related questions

0 votes
1 answer
asked Jan 23, 2023 by oezdemir (120 points)
0 votes
2 answers
asked Oct 26, 2022 by EDuenkel (420 points)
0 votes
1 answer
+2 votes
1 answer
asked Jun 3, 2020 by the_s (380 points)
...