WWDC icon indicating copy to clipboard operation
WWDC copied to clipboard

Add-remove-add favorite results in a permanently favorited session

Open allenhumphreys opened this issue 7 years ago • 6 comments

The problem has to do with this code and the soft-deletion of Favorites. Could probably be remedied by changing removeFavorite to soft delete all the favorites and createFavorite to only add a favorite object if one isn't already there, otherwise it should undelete it.

I'm not fixing this right now because I'm not really sure why soft deletion and an array of objects is even needed.

public func removeFavorite(for session: Session) {
    guard let favorite = session.favorites.first else { return }

    modify(favorite) { bgFavorite in
        bgFavorite.isDeleted = true
    }
}

allenhumphreys avatar Jul 18 '18 14:07 allenhumphreys

*only happens when favoriting from the session actions. Using the table context menu appears to have a different implementation.

allenhumphreys avatar Jul 18 '18 14:07 allenhumphreys

only add a favorite object if one isn't already there, otherwise it should undelete it

This seems like a good solution

I'm not fixing this right now because I'm not really sure why soft deletion and an array of objects is even needed.

That combination made syncing significantly easier to implement.

insidegui avatar Jul 18 '18 15:07 insidegui

Is work on this issue needed? I cannot tell reading your comments :)

dinesharjani avatar Aug 07 '18 15:08 dinesharjani

Yes, this is still a bug. A minor logic update should be all that is needed. I think there are 2 places where add/remove favorite logic is implemented. 1 for the session list and another for the session detail. The table menu handles things correctly.

  • [ ] Must unify logic for (un)favoriting a session if possible
  • [ ] Must ensure both places can correctly (un)favorite sessions

allenhumphreys avatar Aug 07 '18 15:08 allenhumphreys

Alright. I think I can pick this up once #499 is approved / merged.

dinesharjani avatar Aug 07 '18 15:08 dinesharjani

Must unify logic for (un)favoriting a session if possible

It should be possible to abstract this to ConfCore and have a single implementation that's just a simple method to favorite/unfavorite which just does the right thing.

insidegui avatar Aug 07 '18 16:08 insidegui