From 815e8563df64806edb12a300a587576152ecf74b Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Wed, 28 Nov 2012 15:45:23 -0800 Subject: [PATCH] gilding: Document the gildComment / thingupdater interaction. --- r2/r2/public/static/js/gold.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/r2/r2/public/static/js/gold.js b/r2/r2/public/static/js/gold.js index f11c862fd..9e9fd70c0 100644 --- a/r2/r2/public/static/js/gold.js +++ b/r2/r2/public/static/js/gold.js @@ -64,7 +64,7 @@ r.gold = { return false }, - gildComment: function (comment_id, new_title, gilding_count) { + gildComment: function (comment_id, new_title, specified_gilding_count) { var comment = $('.id-' + comment_id) if (!comment.length) { @@ -75,7 +75,17 @@ r.gold = { var tagline = comment.children('.entry').find('p.tagline'), icon = tagline.find('.gilded-comment-icon') - if (gilding_count == null) { + // when a comment is gilded interactively, we need to increment the + // gilding count displayed by the UI. however, when gildings are + // instantiated from a cached comment page via thingupdater, we can't + // simply increment the gilding count because we do not know if the + // cached comment page already includes the gilding in its count. To + // resolve this ambiguity, thingupdater will provide the correct + // gilding count as specified_gilding_count when calling this function. + var gilding_count + if (specified_gilding_count != null) { + gilding_count = specified_gilding_count + } else { gilding_count = icon.data('count') || 0 gilding_count++ }