Skip to content

Commit

Permalink
Fix action bar issue and adjust cache_buster (forem#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
benhalpern authored Nov 7, 2018
1 parent 76f6a8f commit 119b86c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function setReactionCount(reactionName, newCount) {
}
}

function showUserReaction(reactionName) {
document.getElementById("reaction-butt-" + reactionName).classList.add("user-activated", "user-animated");
function showUserReaction(reactionName, animatedClass) {
document.getElementById("reaction-butt-" + reactionName).classList.add("user-activated", animatedClass);
}

function hideUserReaction(reactionName) {
Expand Down Expand Up @@ -56,7 +56,7 @@ function initializeArticleReactions() {
})
json.reactions.forEach(function (reaction) {
if (document.getElementById("reaction-butt-" + reaction.category)) {
showUserReaction(reaction.category);
showUserReaction(reaction.category, "not-user-animated");
}
})

Expand Down Expand Up @@ -92,7 +92,7 @@ function reactToArticle(articleId, reaction) {
hideUserReaction(reaction);
setReactionCount(reaction, currentNum - 1);
} else {
showUserReaction(reaction);
showUserReaction(reaction, "user-animated");
setReactionCount(reaction, currentNum + 1);
}
}
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/initializers/initializeTouchDevice.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

function initializeTouchDevice() {
var isTouchDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
var isTouchDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|DEV-Native-ios/i.test(navigator.userAgent);
if (navigator.userAgent === 'DEV-Native-ios') {
document.getElementsByTagName("body")[0].classList.add("dev-ios-native-body");
}
setTimeout(function(){
removeShowingMenu();
if (isTouchDevice) {
Expand Down
18 changes: 16 additions & 2 deletions app/assets/stylesheets/article-show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ header{
color: darken($bold-blue, 40%);
}
&.user-animated{
animation: reaction 0.3s;
animation: reaction 0.25s;
}
}
}
Expand Down Expand Up @@ -836,6 +836,15 @@ header{
}
}

.dev-ios-native-body {
.container{
.article-actions{
padding:6px 0px;
transition: padding 0.33s;
}
}
}

.showpage-reaction-cta{
width: 390px;
max-width:78%;
Expand Down Expand Up @@ -1007,8 +1016,13 @@ header{
padding-right: calc(0.88vw + 3px);
}
50% {
padding-top: 6px;
padding-bottom: 4px;
padding-left: calc(1.1vw + 3px);
padding-left: calc(1.1vw + 3px);
padding-right: calc(1.1vw + 3px);
margin: 0px 0vw;
margin-top: -4px;
margin-bottom: -1px;
}
100% {
padding-left: calc(0.88vw + 3px);
Expand Down
20 changes: 8 additions & 12 deletions app/labor/cache_buster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ def bust(path)
end

def bust_comment(commentable, username)
if commentable.featured_number.to_i > 5.hours.ago.to_i
if Article.where(published: true).order("hotness_score DESC").limit(3).pluck(:id).include?(commentable.id)
bust("/")
bust("/?i=i")
bust("?i=i")
end
if commentable.decorate.cached_tag_list_array.include?("discuss") &&
commentable.featured_number.to_i > 35.hours.ago.to_i
Expand Down Expand Up @@ -69,16 +67,14 @@ def bust_home_pages(article)
bust("/top/#{timeframe[1]}?i=i")
bust("/top/#{timeframe[1]}/?i=i")
end
if Article.where(published: true).where("published_at > ?", timeframe[0]).
order("hotness_score DESC").limit(2).pluck(:id).include?(article.id)
bust("/")
bust("?i=i")
end
end
if article.published && article.published_at > 1.hour.ago
bust("/latest")
bust("/latest?i=i")
end
if Article.where(published: true).order("hotness_score DESC").limit(4).pluck(:id).include?(article.id)
bust("/")
end
end

def bust_tag_pages(article)
Expand All @@ -98,10 +94,10 @@ def bust_tag_pages(article)
bust("/api/articles?tag=#{tag}&top=#{i}")
end
end
if Article.where(published: true).where("published_at > ?", timeframe[0]).tagged_with(tag).
order("hotness_score DESC").limit(3).pluck(:id).include?(article.id)
bust("/")
bust("?i=i")
if Article.where(published: true).tagged_with(tag).
order("hotness_score DESC").limit(2).pluck(:id).include?(article.id)
bust("/t/#{tag}")
bust("/t/#{tag}?i=i")
end
end
end
Expand Down

0 comments on commit 119b86c

Please sign in to comment.