diff --git a/app/assets/javascripts/initializers/initNotifications.js b/app/assets/javascripts/initializers/initNotifications.js index 8a3796366..a2a44d12a 100644 --- a/app/assets/javascripts/initializers/initNotifications.js +++ b/app/assets/javascripts/initializers/initNotifications.js @@ -23,7 +23,7 @@ function markNotificationsAsRead() { xmlhttp.setRequestHeader('X-CSRF-Token', csrfToken); xmlhttp.send(); } - }, 380); + }, 450); } function fetchNotificationsCount() { diff --git a/app/assets/javascripts/serviceworker.js.erb b/app/assets/javascripts/serviceworker.js.erb index 8cdd26c4f..c37aa0a36 100644 --- a/app/assets/javascripts/serviceworker.js.erb +++ b/app/assets/javascripts/serviceworker.js.erb @@ -1,4 +1,4 @@ -var CACHE_VERSION = 'v2.6.3'; +var CACHE_VERSION = 'v2.6.4'; var CACHE_NAME = CACHE_VERSION + ':sw-cache::'; var REQUESTS_LIMIT = 70; diff --git a/app/assets/stylesheets/articles.scss b/app/assets/stylesheets/articles.scss index 077d77a81..70f45654f 100644 --- a/app/assets/stylesheets/articles.scss +++ b/app/assets/stylesheets/articles.scss @@ -68,6 +68,33 @@ max-width:604px; float:left; } + .notifications-mobile-filters { + padding-bottom: 8px; + @media screen and ( min-width: 950px ){ + display: none; + } + .query-filter-button{ + font-size: 12px; + font-weight: bold; + background: transparent; + border: 0px; + display:inline-block; + width: 27%; + padding: 6px 0px; + text-align:left; + border-radius: 100px; + color: $black; + text-align: center; + margin: 1%; + &:hover{ + background: lighten($bold-blue, 38%); + } + &.selected{ + background: lighten($bold-blue, 8%); + color: white; + } + } + } .on-page-nav-controls{ height:45px; position:relative; @@ -913,6 +940,14 @@ border-radius:3px; border: 1px solid $outline-color; box-shadow: $bold-shadow; + &.fixed-widget { + position: fixed; + width: 254px; + top: 80px; + header { + padding-left: 6px; + } + } &:hover{ opacity:1; } @@ -1126,14 +1161,16 @@ border: 0px; display:block; padding: 6px 8px; - width: 100%; + width: calc(100% - 16px); text-align:left; border-radius: 0px; + color: $black; &:hover{ - background: lighten($yellow, 15%); + background: lighten($bold-blue, 38%); } &.selected{ - background: lighten($yellow, 2%); + background: lighten($bold-blue, 10%); + color: white; } &.query-type-filter-button{ &:hover{ diff --git a/app/assets/stylesheets/user-profile-header.scss b/app/assets/stylesheets/user-profile-header.scss index c9f352724..c2694ddf3 100644 --- a/app/assets/stylesheets/user-profile-header.scss +++ b/app/assets/stylesheets/user-profile-header.scss @@ -104,16 +104,6 @@ a{ color:rgb(97, 97, 97); } - .notifications-header{ - font-size:calc(26px + 0.2vw); - padding-bottom:13px; - font-weight:600; - img{ - width: calc(27px + 0.2vw); - margin-right: 9px; - vertical-align:-3px; - } - } .profile-pic-wrapper{ float:left; width:calc(14.5vw + 60px); diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d7c8fec4d..3517de2f3 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -63,7 +63,7 @@ class CommentsController < ApplicationController current_user.update(checked_code_of_conduct: true) end Mention.create_all(@comment) - Notification.send_new_comment_notifications(@comment) + Notification.send_new_comment_notifications_without_delay(@comment) if @comment.invalid? @comment.destroy render json: { status: "comment already exists" } diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 842b5a367..f1c2821bd 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -8,9 +8,19 @@ class NotificationsController < ApplicationController else current_user end - @notifications = NotificationDecorator. + if params[:filter].to_s.downcase == "posts" + @notifications = NotificationDecorator. + decorate_collection(Notification.where(user_id: current_user.id, notifiable_type: "Article", action: "Published"). + order("notified_at DESC").limit(55).to_a) + elsif params[:filter].to_s.downcase == "comments" + @notifications = NotificationDecorator. + decorate_collection(Notification.where(user_id: current_user.id, notifiable_type: "Comment"). + order("notified_at DESC").limit(55).to_a) + else + @notifications = NotificationDecorator. decorate_collection(Notification.where(user_id: current_user.id). - order("notified_at DESC").limit(60).to_a) + order("notified_at DESC").limit(55).to_a) + end @last_user_reaction = @user.reactions.last&.id @last_user_comment = @user.comments.last&.id end diff --git a/app/models/notification.rb b/app/models/notification.rb index e83a9f347..617fedcf5 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -106,7 +106,7 @@ class Notification < ApplicationRecord } } if aggregated_reaction_siblings.size.zero? - Notification.where(notifiable_type: notifiable.reactable.class.name, notifiable_id: notifiable.reactable.id, action: "reaction").destroy_all + Notification.where(notifiable_type: notifiable.reactable.class.name, notifiable_id: notifiable.reactable.id, action: "Reaction").destroy_all else previous_siblings_size = 0 notification = Notification.find_or_create_by(notifiable_type: notifiable.reactable.class.name, notifiable_id: notifiable.reactable.id, action: "Reaction") @@ -221,7 +221,9 @@ class Notification < ApplicationRecord name: user.name, username: user.username, path: user.path, - profile_image_90: user.profile_image_90 + profile_image_90: user.profile_image_90, + comments_count: user.comments_count, + created_at: user.created_at } end diff --git a/app/views/articles/_sidebar.html.erb b/app/views/articles/_sidebar.html.erb index 502424742..82f375383 100644 --- a/app/views/articles/_sidebar.html.erb +++ b/app/views/articles/_sidebar.html.erb @@ -77,16 +77,16 @@ <% end %> <% elsif @query %> -
+
- <FILTERS> + search results
- - - -
- + POSTS + PODCASTS + PEOPLE +
+ ONLY MY POSTS
<% elsif @tag %> diff --git a/app/views/notifications/_aggregated_reactions.html.erb b/app/views/notifications/_aggregated_reactions.html.erb index 39a8a3626..515198c57 100644 --- a/app/views/notifications/_aggregated_reactions.html.erb +++ b/app/views/notifications/_aggregated_reactions.html.erb @@ -1,5 +1,5 @@ <%# TODO: change to map of IDs %> -<% siblings = notification.json_data["reaction"]["aggregated_siblings"] %> +<% siblings = notification.json_data["reaction"]["aggregated_siblings"].select{|n| n["created_at"] > 24.hours.ago } %> <% cache "activity-aggregated-reactions-#{siblings}_#{siblings}" do %> <% actors = siblings.map { |n| n["user"] }.uniq %> <% reactable_data = notification.json_data["reaction"]["reactable"] %> @@ -27,7 +27,7 @@ with - <% reaction_categories = siblings.select{|n| n["created_at"] > 24.hours.ago }.map { |n| n["category"] } %> + <% reaction_categories = siblings.map { |n| n["category"] } %> <% reaction_categories.each do |cat| %> <% if ReactionImage.new(cat).path.present? %> <%= image_tag ReactionImage.new(cat).path, class: "reaction-image", alt: "#{cat}" %> diff --git a/app/views/notifications/_comment.html.erb b/app/views/notifications/_comment.html.erb index 6e86eb146..7bad67ab5 100644 --- a/app/views/notifications/_comment.html.erb +++ b/app/views/notifications/_comment.html.erb @@ -1,38 +1,42 @@ -<% json_data = notification.json_data %> -<% cache "activity-profile-pic-#{json_data["user"]["id"]}-#{json_data["user"]["profile_image_90"]}" do %> - " class="small-pic-link-wrapper"> -
- " alt="link to <%= json_data["user"]["username"] %>'s profile"> -
-
-<% end %> -
- <% if notification.action.blank? %> - "><%= json_data["user"]["name"] %> - commented on - "> - <%= sanitize(json_data["comment"]["commentable"]["title"]) %> - - <%= render "notifications/shared/comment_box", json_data: json_data, notification: notification, context: "default" %> - <% elsif notification.action == "Moderation" %> - Hey there! <%= image_tag "emoji/apple-hugging-face.png", class: "reaction-image" %> As a trusted member, could you react to this comment - so we know it fits our community code of conduct? -

- Here's the article for context: - "> - <%= sanitize(json_data["comment"]["commentable"]["title"]) %> - - <%= render "notifications/shared/comment_box", json_data: json_data, notification: notification, context: "moderation" %> -
-
All negative reactions are 100% private. If it is a good comment, consider also replying with some positive reinforcement or adding to the conversation.
- <% elsif notification.action == "First" %> - "><%= json_data["user"]["name"] %> - wrote their first comment on: - "> - <%= sanitize(json_data["comment"]["commentable"]["title"]) %> +<% if notification.action == "Reaction" %> + <%= render "reaction", notification: notification %> +<% else %> + <% json_data = notification.json_data %> + <% cache "activity-profile-pic-#{json_data["user"]["id"]}-#{json_data["user"]["profile_image_90"]}" do %> + " class="small-pic-link-wrapper"> +
+ " alt="link to <%= json_data["user"]["username"] %>'s profile"> +
- <%= render "notifications/activity/activities/shared/comment_box", activity: activity, context: "moderation" %> - Give them their first reply! 🎉 -
<% end %> -
+
+ <% if notification.action.blank? %> + "><%= json_data["user"]["name"] %> + commented on + "> + <%= sanitize(json_data["comment"]["commentable"]["title"]) %> + + <%= render "notifications/shared/comment_box", json_data: json_data, notification: notification, context: "default" %> + <% elsif notification.action == "Moderation" %> + Hey there! <%= image_tag "emoji/apple-hugging-face.png", class: "reaction-image" %> As a trusted member, could you react to this comment + so we know it fits our community code of conduct? +

+ Here's the article for context: + "> + <%= sanitize(json_data["comment"]["commentable"]["title"]) %> + + <%= render "notifications/shared/comment_box", json_data: json_data, notification: notification, context: "moderation" %> +
+
All negative reactions are 100% private. If it is a good comment, consider also replying with some positive reinforcement or adding to the conversation.
+ <% elsif notification.action == "First" %> + "><%= json_data["user"]["name"] %> + wrote their first comment on: + "> + <%= sanitize(json_data["comment"]["commentable"]["title"]) %> + + <%= render "notifications/activity/activities/shared/comment_box", activity: activity, context: "moderation" %> + Give them their first reply! 🎉 +
+ <% end %> +
+<% end %> diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index f60b38e00..d62485eb9 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -20,17 +20,28 @@
- +
<% if user_signed_in? %> + <% notification_count = 0 %> <% @notifications.each do |notification| %> <% next if (notification.notified_at < 24.hours.ago && notification.aggregated?) %> diff --git a/config/routes.rb b/config/routes.rb index 94156b3b8..270cab818 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -123,7 +123,7 @@ Rails.application.routes.draw do resources :html_variant_successes, only: [:create] resources :push_notification_subscriptions, only: [:create] - get "/notifications/:username" => "notifications#index" + get "/notifications/:filter" => "notifications#index" patch "/onboarding_update" => "users#onboarding_update" get "email_subscriptions/unsubscribe" post "/chat_channels/:id/moderate" => "chat_channels#moderate"