DanBlumenfeld (@danblumenfeld)

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

  • DanBlumenfeld
    Participant

    @danblumenfeld

    @aaclayton: I agree re: scalability. I was contemplating limiting the number of topics stored to the top N, basing “top” on freshness, and assuming anything not in the top was already read…that does leave the problem of older topics that are resurrected, appearing as new topics. I dunno…perhaps a simpler throttling mechanism would be just to discard topics off the back of the map as it grows beyond a certain size? Also less than ideal, but simple and doesn’t involve extra data lookups.

    Thanks for the suggestion re: bbp_get_reply_permalink.


    DanBlumenfeld
    Participant

    @danblumenfeld

    I’m currently working with/foisting my testing on @Clicknathan (Hi, Nathan!) on a plugin to address the goals of indicating unread topics, indicating topics that have unread replies, and providing a means to jump to the first unread reply for a given topic. (This is my first foray into the wild-n-wacky world of bbPress, PHP, and WordPress plugins…very educational thus far…)

    My first cut is another solution using user metadata; I store a map of topic IDs to last-read-reply IDs. It looks like this `$TOPIC-ID:$LAST-REPLY-ID|$TOPIC-ID:$LAST-REPLY-ID|$TOPIC-ID:$LAST-REPLY-ID`.

    When rendering topics in the loop, I check the topic’s metadata for last-reply ID, and compare it to the last-read-reply ID in the user’s map. If there is no matching topic in the map, I add a CSS class for “unread topic”; if there is a matching topic, and the last-read-reply ID is less than the last-reply ID, I add a CSS class for “unread replies”.

    When handling replies, I update the map (only in memory!) as I loop through each reply, then commit the map back to user metadata after processing all replies. I also check each reply ID; if it is the first one I find greater than the last-read-reply ID from the map for the current topic, I throw in a “first-unread” anchor tag, so it can be easily jumped to on the client side.

    Currently, I don’t limit the number of topic/last-read-reply pairs I store in the user metadata; I’m quite sure there will be a point where performance suffers.

    I’m also unsure how best to handle pagination for the “jump to first unread reply” question; while dropping the anchor tag is easy enough, I’m not sure how to properly form the URL to which to append the anchor tag ref, without some fairly complex logic involving looking up the relative index of the first unread reply in the set of all replies for the topic.

    Anyway, I’d love some feedback at the conceptual level now, and I’d even more appreciate some solid criticism when I get the plugin whipped into shape and submitted.

Viewing 2 replies - 1 through 2 (of 2 total)