Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Favorite star doesn't un-fav when filled and clicked

#34

So you've got a favorite, and the star is filled, but if you click the star it actually tries to re-fav the status, rather than toggle off the fav state.

Reported by Ed Finkler · April 21st, 2010 @ 10:11 PM

State: resolved
Milestone: Version 0.10
Assigned to: Ed Finkler Ed Finkler

Activity

  1. Mark Armendariz
    Mark Armendariz
    • Assigned user set to Ed Finkler

    Just downloaded your codebase moments ago to see if i could offer any help. Still trying to wrap my head around things, but I found a fix for this - although it's far too early for me to suggest it as a change as I've no idea what it could Possibly break. At any rate...

    In Spaz.Data.makeFavorite(), you are explicitly adding the "favorited" class directly:

    $('.timeline-entry[data-status-id='+postid+']').addClass('favorited');
    

    But in spaz.controller, under '.status-action-fav', you're using the Spaz.UI.getElementFromStatusId() method to get the element meant to be un/favorited. I'm not sure what it's returning, but it's definitely returning the wrong element, and hence, the $(element).hasClass('favorited') always returns false.

    In Spaz.UI.getElementFromStatusId(), I replaced the current line (which is far less precise) with the one from Spaz.Data.makeFavorite():

    Spaz.UI.getElementFromStatusId = function(id) {
        // var element = $('.entry-id:contains('+id+')').parent().get()[0];  // Original
        var element = $('.timeline-entry[data-status-id='+id+']')
        if (element) {
            sch.dump(element.id);
            return element
        }
        return false;
    };
    

    And now it works great, although there's no telling what that may have shattered.

    I don't really use spaz much, but I'm a fan of the project. Rock on.

    Mark (enobrev)

    April 23rd, 2010 @ 10:31 PM

  2. Mark Armendariz
  3. Ed Finkler
    Ed Finkler
    • Assigned user set to Ed Finkler

    May 10th, 2010 @ 01:26 PM

  4. Ed Finkler
    Ed Finkler
    • State changed from new to resolved

    Finally got this fixed up. Thanks Mark!

    June 14th, 2010 @ 09:27 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.