Merge pull request #2380 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes up to 1cb978bcc3
local
commit
8eb09466aa
160 changed files with 402 additions and 729 deletions
@ -0,0 +1,27 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
class Settings::PrivacyController < Settings::BaseController |
||||||
|
before_action :set_account |
||||||
|
|
||||||
|
def show; end |
||||||
|
|
||||||
|
def update |
||||||
|
if UpdateAccountService.new.call(@account, account_params.except(:settings)) |
||||||
|
current_user.update!(settings_attributes: account_params[:settings]) |
||||||
|
ActivityPub::UpdateDistributionWorker.perform_async(@account.id) |
||||||
|
redirect_to settings_privacy_path, notice: I18n.t('generic.changes_saved_msg') |
||||||
|
else |
||||||
|
render :show |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def account_params |
||||||
|
params.require(:account).permit(:discoverable, :unlocked, :show_collections, settings: UserSettings.keys) |
||||||
|
end |
||||||
|
|
||||||
|
def set_account |
||||||
|
@account = current_account |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,50 @@ |
|||||||
|
import PropTypes from 'prop-types'; |
||||||
|
import { useMemo, useState, useCallback } from 'react'; |
||||||
|
|
||||||
|
import { FormattedMessage } from 'react-intl'; |
||||||
|
|
||||||
|
import { Link } from 'react-router-dom'; |
||||||
|
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes'; |
||||||
|
|
||||||
|
const domParser = new DOMParser(); |
||||||
|
|
||||||
|
// About two lines on desktop |
||||||
|
const VISIBLE_HASHTAGS = 7; |
||||||
|
|
||||||
|
export const HashtagBar = ({ hashtags, text }) => { |
||||||
|
const renderedHashtags = useMemo(() => { |
||||||
|
const body = domParser.parseFromString(text, 'text/html').documentElement; |
||||||
|
return [].filter.call(body.querySelectorAll('a[href]'), link => link.textContent[0] === '#' || (link.previousSibling?.textContent?.[link.previousSibling.textContent.length - 1] === '#')).map(node => node.textContent); |
||||||
|
}, [text]); |
||||||
|
|
||||||
|
const invisibleHashtags = useMemo(() => ( |
||||||
|
hashtags.filter(hashtag => !renderedHashtags.some(textContent => textContent.localeCompare(`#${hashtag.get('name')}`, undefined, { sensitivity: 'accent' }) === 0 || textContent.localeCompare(hashtag.get('name'), undefined, { sensitivity: 'accent' }) === 0)) |
||||||
|
), [hashtags, renderedHashtags]); |
||||||
|
|
||||||
|
const [expanded, setExpanded] = useState(false); |
||||||
|
const handleClick = useCallback(() => setExpanded(true), []); |
||||||
|
|
||||||
|
if (invisibleHashtags.isEmpty()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
const revealedHashtags = expanded ? invisibleHashtags : invisibleHashtags.take(VISIBLE_HASHTAGS); |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className='hashtag-bar'> |
||||||
|
{revealedHashtags.map(hashtag => ( |
||||||
|
<Link key={hashtag.get('name')} to={`/tags/${hashtag.get('name')}`}> |
||||||
|
#{hashtag.get('name')} |
||||||
|
</Link> |
||||||
|
))} |
||||||
|
|
||||||
|
{!expanded && invisibleHashtags.size > VISIBLE_HASHTAGS && <button className='link-button' onClick={handleClick}><FormattedMessage id='hashtags.and_other' defaultMessage='…and {count, plural, other {# more}}' values={{ count: invisibleHashtags.size - VISIBLE_HASHTAGS }} /></button>} |
||||||
|
</div> |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
HashtagBar.propTypes = { |
||||||
|
hashtags: ImmutablePropTypes.list, |
||||||
|
text: PropTypes.string, |
||||||
|
}; |
@ -0,0 +1,47 @@ |
|||||||
|
- content_for :page_title do |
||||||
|
= t('privacy.title') |
||||||
|
|
||||||
|
- content_for :heading do |
||||||
|
%h2= t('settings.profile') |
||||||
|
= render partial: 'settings/shared/profile_navigation' |
||||||
|
|
||||||
|
= simple_form_for @account, url: settings_privacy_path, html: { method: :put } do |f| |
||||||
|
= render 'shared/error_messages', object: @account |
||||||
|
|
||||||
|
%p.lead= t('privacy.hint_html') |
||||||
|
|
||||||
|
%h4= t('privacy.reach') |
||||||
|
|
||||||
|
%p.lead= t('privacy.reach_hint_html') |
||||||
|
|
||||||
|
.fields-group |
||||||
|
= f.input :discoverable, as: :boolean, wrapper: :with_label, recommended: true |
||||||
|
|
||||||
|
.fields-group |
||||||
|
= f.input :unlocked, as: :boolean, wrapper: :with_label |
||||||
|
|
||||||
|
%h4= t('privacy.search') |
||||||
|
|
||||||
|
%p.lead= t('privacy.search_hint_html') |
||||||
|
|
||||||
|
= f.simple_fields_for :settings, current_user.settings do |ff| |
||||||
|
.fields-group |
||||||
|
= ff.input :indexable, wrapper: :with_label |
||||||
|
|
||||||
|
%h4= t('privacy.privacy') |
||||||
|
|
||||||
|
%p.lead= t('privacy.privacy_hint_html') |
||||||
|
|
||||||
|
.fields-group |
||||||
|
= f.input :show_collections, as: :boolean, wrapper: :with_label |
||||||
|
|
||||||
|
= f.simple_fields_for :settings, current_user.settings do |ff| |
||||||
|
- unless Setting.hide_followers_count |
||||||
|
.fields-group |
||||||
|
= ff.input :show_followers_count, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_show_followers_count'), hint: I18n.t('simple_form.hints.defaults.setting_show_followers_count'), glitch_only: true |
||||||
|
|
||||||
|
.fields-group |
||||||
|
= ff.input :show_application, wrapper: :with_label |
||||||
|
|
||||||
|
.actions |
||||||
|
= f.button :button, t('generic.save_changes'), type: :submit |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue