diff --git a/app/assets/javascripts/initializers/initScrolling.js.erb b/app/assets/javascripts/initializers/initScrolling.js.erb index 9b7411446..acf8be7f3 100644 --- a/app/assets/javascripts/initializers/initScrolling.js.erb +++ b/app/assets/javascripts/initializers/initScrolling.js.erb @@ -199,6 +199,8 @@ function algoliaPaginate(tag){ .then(function searchDone(content) { nextPage += 1; insertArticles(content.hits); + const checkBlockedContentEvent = new CustomEvent('checkBlockedContent') + window.dispatchEvent(checkBlockedContentEvent) if (content.hits.length == 0) { document.getElementById("loading-articles").style.display = "none" done = true; diff --git a/app/assets/javascripts/initializers/initializeFetchFollowedArticles.js.erb b/app/assets/javascripts/initializers/initializeFetchFollowedArticles.js.erb index 1e48a07f2..9342cf407 100644 --- a/app/assets/javascripts/initializers/initializeFetchFollowedArticles.js.erb +++ b/app/assets/javascripts/initializers/initializeFetchFollowedArticles.js.erb @@ -137,6 +137,8 @@ function algoliaFollowedArticles(){ if (user && user.followed_tag_names && user.followed_tag_names.length > 0) { insertInitialArticles(user) + const checkBlockedContentEvent = new CustomEvent('checkBlockedContent') + window.dispatchEvent(checkBlockedContentEvent) var followedUsersArray = []; if (user.followed_user_ids){ followedUsersArray = user.followed_user_ids.map(function(id){return 'user_'+id}); diff --git a/app/assets/javascripts/utilities/buildArticleHTML.js.erb b/app/assets/javascripts/utilities/buildArticleHTML.js.erb index 735288526..8a21ebd51 100644 --- a/app/assets/javascripts/utilities/buildArticleHTML.js.erb +++ b/app/assets/javascripts/utilities/buildArticleHTML.js.erb @@ -113,7 +113,7 @@ function buildArticleHTML(article) { timeAgoInWords = timeAgo(article.published_at_int); } - return '
\ + return '
\ '+videoHTML+'\ '+orgHeadline+'\
\ diff --git a/app/assets/javascripts/utilities/buildCommentHTML.js.erb b/app/assets/javascripts/utilities/buildCommentHTML.js.erb index 41518d929..546f69c01 100644 --- a/app/assets/javascripts/utilities/buildCommentHTML.js.erb +++ b/app/assets/javascripts/utilities/buildCommentHTML.js.erb @@ -34,7 +34,7 @@ function buildCommentHTML(comment) { '+detailsStartHTML+'\
\
\ + data-comment-id="'+comment.id+'" data-comment-author-id="'+comment.user.id+'" data-current-user-comment="'+comment.newly_created+'" data-content-user-id="'+comment.user.id+'">\
\
\ \ diff --git a/app/assets/javascripts/utilities/sendFetch.js b/app/assets/javascripts/utilities/sendFetch.js index 8074624e5..540694abb 100644 --- a/app/assets/javascripts/utilities/sendFetch.js +++ b/app/assets/javascripts/utilities/sendFetch.js @@ -2,7 +2,9 @@ const fetchCallback = ({ url, headers = {}, addTokenToBody = false, body }) => { return csrfToken => { - if (addTokenToBody) { body.append('authenticity_token', csrfToken) }; + if (addTokenToBody) { + body.append('authenticity_token', csrfToken); + } return window.fetch(url, { method: 'POST', headers: { @@ -24,37 +26,41 @@ function sendFetch(switchStatement, body) { Accept: 'application/json', 'Content-Type': 'application/json', }, - body + body, }); case 'reaction-creation': return fetchCallback({ url: '/reactions', addTokenToBody: true, - body + body, }); case 'image-upload': return fetchCallback({ url: '/image_uploads', addTokenToBody: true, - body + body, }); case 'follow-creation': return fetchCallback({ url: '/follows', addTokenToBody: true, - body + body, }); case 'chat-creation': return fetchCallback({ url: '/chat_channels/create_chat', addTokenToBody: true, - body + body, }); - case 'block-chat': + case 'block-user': return fetchCallback({ - url: '/chat_channels/block_chat', - addTokenToBody: true, - body + url: '/user_blocks', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + addTokenToBody: false, + body, }); case 'comment-creation': return fetchCallback({ @@ -62,7 +68,7 @@ function sendFetch(switchStatement, body) { headers: { 'Content-Type': 'application/json', }, - body + body, }); case 'comment-preview': return fetchCallback({ @@ -70,7 +76,7 @@ function sendFetch(switchStatement, body) { headers: { 'Content-Type': 'application/json', }, - body + body, }); default: console.log('A wrong switchStatement was used.'); // eslint-disable-line no-console diff --git a/app/controllers/async_info_controller.rb b/app/controllers/async_info_controller.rb index 291c4d8d2..56f5a64f3 100644 --- a/app/controllers/async_info_controller.rb +++ b/app/controllers/async_info_controller.rb @@ -43,6 +43,7 @@ class AsyncInfoController < ApplicationController followed_organization_ids: @user.cached_following_organizations_ids, followed_podcast_ids: @user.cached_following_podcasts_ids, reading_list_ids: ReadingList.new(@user).cached_ids_of_articles, + blocked_user_ids: @user.all_blocking.pluck(:blocked_id), saw_onboarding: @user.saw_onboarding, checked_code_of_conduct: @user.checked_code_of_conduct, checked_terms_and_conditions: @user.checked_terms_and_conditions, diff --git a/app/javascript/.eslintrc.js b/app/javascript/.eslintrc.js index e1a87481e..f9ff4f0ab 100644 --- a/app/javascript/.eslintrc.js +++ b/app/javascript/.eslintrc.js @@ -31,6 +31,7 @@ module.exports = { }, }, ], + 'react/jsx-no-target-blank': [2, { enforceDynamicLinks: 'always' }], }, globals: { InstantClick: false, diff --git a/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap index e88cf5625..82b3d506a 100644 --- a/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap +++ b/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap @@ -40,6 +40,7 @@ exports[` for user1 should render and test snapshot 1`] = ` > for user1 should render and test snapshot 1`] = ` for user1 should render and test snapshot 1`] = ` for user2 should render and test snapshot 1`] = ` > for user2 should render and test snapshot 1`] = ` for user2 should render and test snapshot 1`] = ` { @@ -16,9 +18,7 @@ const setUpButton = ({ modalId = '', otherModalId = '', btnName = '' }) => { ); -} +}; const userDetailsConfig = { twitter_username: { hostUrl: 'https://twitter.com/', srcImage: twitterImage, - imageAltText: 'twitter logo' + imageAltText: 'twitter logo', }, github_username: { hostUrl: 'https://github.com/', srcImage: githubImage, - imageAltText: 'github logo' + imageAltText: 'github logo', }, website_url: { className: 'external-link-img', hostUrl: '', srcImage: websiteImage, - imageAltText: 'external link icon' - } -} + imageAltText: 'external link icon', + }, +}; export default class UserDetails extends Component { render() { @@ -60,14 +60,11 @@ export default class UserDetails extends Component { const channel = this.props.activeChannel || {}; const socialIcons = []; const userMeta = ['twitter_username', 'github_username', 'website_url']; - userMeta.forEach((metaProp) => { + userMeta.forEach(metaProp => { if (user[metaProp]) { let { className, hostUrl, srcImage, imageAltText } = userDetailsConfig[metaProp]; socialIcons.push( - +
{blockButton} - { - setUpButton({ - modalId: 'userdetails__reportabuse', - otherModalId: 'userdetails__blockmsg', - btnName: 'Report Abuse' - }) - } + {setUpButton({ + modalId: 'userdetails__reportabuse', + otherModalId: 'userdetails__blockmsg', + btnName: 'Report Abuse', + })}