forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into temp2_for-ffxiv-mastodon
# Conflicts: # config/locales/simple_form.en.yml # config/locales/simple_form.ja.yml # config/locales/simple_form.vi.yml
- Loading branch information
Showing
175 changed files
with
737 additions
and
922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, :locked, :hide_collections, settings: UserSettings.keys) | ||
end | ||
|
||
def set_account | ||
@account = current_account | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [].map.call(body.querySelectorAll('[rel=tag]'), node => node.textContent.toLowerCase()); | ||
}, [text]); | ||
|
||
const invisibleHashtags = useMemo(() => ( | ||
hashtags.filter(hashtag => !renderedHashtags.some(textContent => textContent === `#${hashtag.get('name')}` || textContent === hashtag.get('name'))) | ||
), [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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.