2017-05-03 00:04:16 +00:00
import React from 'react' ;
2017-01-30 20:40:55 +00:00
import ImmutablePropTypes from 'react-immutable-proptypes' ;
2017-04-21 18:05:35 +00:00
import PropTypes from 'prop-types' ;
2017-01-30 20:40:55 +00:00
import InnerHeader from '../../account/components/header' ;
import ActionBar from '../../account/components/action_bar' ;
2017-02-26 22:06:27 +00:00
import MissingIndicator from '../../../components/missing_indicator' ;
2017-05-03 00:04:16 +00:00
import ImmutablePureComponent from 'react-immutable-pure-component' ;
2017-11-18 18:39:02 +00:00
import MovedNote from './moved_note' ;
2018-03-01 01:48:44 +00:00
import { FormattedMessage } from 'react-intl' ;
import { NavLink } from 'react-router-dom' ;
2017-01-30 20:40:55 +00:00
2017-06-23 17:36:54 +00:00
export default class Header extends ImmutablePureComponent {
2017-01-30 20:40:55 +00:00
2017-05-12 12:44:10 +00:00
static propTypes = {
account : ImmutablePropTypes . map ,
onFollow : PropTypes . func . isRequired ,
onBlock : PropTypes . func . isRequired ,
onMention : PropTypes . func . isRequired ,
Allow hiding of reblogs from followed users (#5762)
* Allow hiding of reblogs from followed users
This adds a new entry to the account menu to allow users to hide
future reblogs from a user (and then if they've done that, to show
future reblogs instead).
This does not remove or add historical reblogs from/to the user's
timeline; it only affects new statuses.
The API for this operates by sending a "reblogs" key to the follow
endpoint. If this is sent when starting a new follow, it will be
respected from the beginning of the follow relationship (even if
the follow request must be approved by the followee). If this is
sent when a follow relationship already exists, it will simply
update the existing follow relationship. As with the notification
muting, this will now return an object ({reblogs: [true|false]}) or
false for each follow relationship when requesting relationship
information for an account. This should cause few issues due to an
object being truthy in many languages, but some modifications may
need to be made in pickier languages.
Database changes: adds a show_reblogs column (default true,
non-nullable) to the follows and follow_requests tables. Because
these are non-nullable, we use the existing MigrationHelpers to
perform this change without locking those tables, although the
tables are likely to be small anyway.
Tests included.
See also <https://github.com/glitch-soc/mastodon/pull/212>.
* Rubocop fixes
* Code review changes
* Test fixes
This patchset closes #648 and resolves #3271.
* Rubocop fix
* Revert reblogs defaulting in argument, fix tests
It turns out we needed this for the same reason we needed it in muting:
if nil gets passed in somehow (most usually by an API client not passing
any value), we need to detect and handle it.
We could specify a default in the parameter and then also catch nil, but
there's no great reason to duplicate the default value.
2017-11-28 14:00:35 +00:00
onReblogToggle : PropTypes . func . isRequired ,
2017-05-12 12:44:10 +00:00
onReport : PropTypes . func . isRequired ,
2017-05-19 19:05:32 +00:00
onMute : PropTypes . func . isRequired ,
onBlockDomain : PropTypes . func . isRequired ,
onUnblockDomain : PropTypes . func . isRequired ,
2018-03-04 08:19:11 +00:00
hideTabs : PropTypes . bool ,
2017-05-12 12:44:10 +00:00
} ;
static contextTypes = {
2017-05-20 15:31:47 +00:00
router : PropTypes . object ,
2017-05-12 12:44:10 +00:00
} ;
2017-01-30 20:40:55 +00:00
2017-05-12 12:44:10 +00:00
handleFollow = ( ) => {
2017-01-30 20:40:55 +00:00
this . props . onFollow ( this . props . account ) ;
2017-04-21 18:05:35 +00:00
}
2017-01-30 20:40:55 +00:00
2017-05-12 12:44:10 +00:00
handleBlock = ( ) => {
2017-01-30 20:40:55 +00:00
this . props . onBlock ( this . props . account ) ;
2017-04-21 18:05:35 +00:00
}
2017-01-30 20:40:55 +00:00
2017-05-12 12:44:10 +00:00
handleMention = ( ) => {
2017-06-20 18:40:03 +00:00
this . props . onMention ( this . props . account , this . context . router . history ) ;
2017-04-21 18:05:35 +00:00
}
2017-01-30 20:40:55 +00:00
2017-05-12 12:44:10 +00:00
handleReport = ( ) => {
2017-02-14 19:59:26 +00:00
this . props . onReport ( this . props . account ) ;
2017-04-21 18:05:35 +00:00
}
2017-02-14 19:59:26 +00:00
Allow hiding of reblogs from followed users (#5762)
* Allow hiding of reblogs from followed users
This adds a new entry to the account menu to allow users to hide
future reblogs from a user (and then if they've done that, to show
future reblogs instead).
This does not remove or add historical reblogs from/to the user's
timeline; it only affects new statuses.
The API for this operates by sending a "reblogs" key to the follow
endpoint. If this is sent when starting a new follow, it will be
respected from the beginning of the follow relationship (even if
the follow request must be approved by the followee). If this is
sent when a follow relationship already exists, it will simply
update the existing follow relationship. As with the notification
muting, this will now return an object ({reblogs: [true|false]}) or
false for each follow relationship when requesting relationship
information for an account. This should cause few issues due to an
object being truthy in many languages, but some modifications may
need to be made in pickier languages.
Database changes: adds a show_reblogs column (default true,
non-nullable) to the follows and follow_requests tables. Because
these are non-nullable, we use the existing MigrationHelpers to
perform this change without locking those tables, although the
tables are likely to be small anyway.
Tests included.
See also <https://github.com/glitch-soc/mastodon/pull/212>.
* Rubocop fixes
* Code review changes
* Test fixes
This patchset closes #648 and resolves #3271.
* Rubocop fix
* Revert reblogs defaulting in argument, fix tests
It turns out we needed this for the same reason we needed it in muting:
if nil gets passed in somehow (most usually by an API client not passing
any value), we need to detect and handle it.
We could specify a default in the parameter and then also catch nil, but
there's no great reason to duplicate the default value.
2017-11-28 14:00:35 +00:00
handleReblogToggle = ( ) => {
this . props . onReblogToggle ( this . props . account ) ;
}
2017-05-12 12:44:10 +00:00
handleMute = ( ) => {
2017-02-06 01:51:56 +00:00
this . props . onMute ( this . props . account ) ;
2017-04-21 18:05:35 +00:00
}
2017-02-06 01:51:56 +00:00
2017-05-19 19:05:32 +00:00
handleBlockDomain = ( ) => {
const domain = this . props . account . get ( 'acct' ) . split ( '@' ) [ 1 ] ;
if ( ! domain ) return ;
this . props . onBlockDomain ( domain , this . props . account . get ( 'id' ) ) ;
}
handleUnblockDomain = ( ) => {
const domain = this . props . account . get ( 'acct' ) . split ( '@' ) [ 1 ] ;
if ( ! domain ) return ;
this . props . onUnblockDomain ( domain , this . props . account . get ( 'id' ) ) ;
}
2017-01-30 20:40:55 +00:00
render ( ) {
2018-03-04 08:19:11 +00:00
const { account , hideTabs } = this . props ;
2017-01-30 20:40:55 +00:00
2017-02-26 22:06:27 +00:00
if ( account === null ) {
return < MissingIndicator / > ;
2017-01-30 20:40:55 +00:00
}
return (
2017-04-23 02:26:55 +00:00
< div className = 'account-timeline__header' >
2017-11-18 18:39:02 +00:00
{ account . get ( 'moved' ) && < MovedNote from = { account } to = { account . get ( 'moved' ) } / > }
2017-01-30 20:40:55 +00:00
< InnerHeader
account = { account }
onFollow = { this . handleFollow }
2018-03-05 04:09:35 +00:00
onBlock = { this . handleBlock }
2017-01-30 20:40:55 +00:00
/ >
< ActionBar
account = { account }
onBlock = { this . handleBlock }
onMention = { this . handleMention }
Allow hiding of reblogs from followed users (#5762)
* Allow hiding of reblogs from followed users
This adds a new entry to the account menu to allow users to hide
future reblogs from a user (and then if they've done that, to show
future reblogs instead).
This does not remove or add historical reblogs from/to the user's
timeline; it only affects new statuses.
The API for this operates by sending a "reblogs" key to the follow
endpoint. If this is sent when starting a new follow, it will be
respected from the beginning of the follow relationship (even if
the follow request must be approved by the followee). If this is
sent when a follow relationship already exists, it will simply
update the existing follow relationship. As with the notification
muting, this will now return an object ({reblogs: [true|false]}) or
false for each follow relationship when requesting relationship
information for an account. This should cause few issues due to an
object being truthy in many languages, but some modifications may
need to be made in pickier languages.
Database changes: adds a show_reblogs column (default true,
non-nullable) to the follows and follow_requests tables. Because
these are non-nullable, we use the existing MigrationHelpers to
perform this change without locking those tables, although the
tables are likely to be small anyway.
Tests included.
See also <https://github.com/glitch-soc/mastodon/pull/212>.
* Rubocop fixes
* Code review changes
* Test fixes
This patchset closes #648 and resolves #3271.
* Rubocop fix
* Revert reblogs defaulting in argument, fix tests
It turns out we needed this for the same reason we needed it in muting:
if nil gets passed in somehow (most usually by an API client not passing
any value), we need to detect and handle it.
We could specify a default in the parameter and then also catch nil, but
there's no great reason to duplicate the default value.
2017-11-28 14:00:35 +00:00
onReblogToggle = { this . handleReblogToggle }
2017-02-14 19:59:26 +00:00
onReport = { this . handleReport }
2017-02-06 01:51:56 +00:00
onMute = { this . handleMute }
2017-05-19 19:05:32 +00:00
onBlockDomain = { this . handleBlockDomain }
onUnblockDomain = { this . handleUnblockDomain }
2017-01-30 20:40:55 +00:00
/ >
2018-03-01 01:48:44 +00:00
2018-03-04 08:19:11 +00:00
{ ! hideTabs && (
< div className = 'account__section-headline' >
< NavLink exact to = { ` /accounts/ ${ account . get ( 'id' ) } ` } > < FormattedMessage id = 'account.posts' defaultMessage = 'Toots' / > < / N a v L i n k >
2018-03-24 11:51:51 +00:00
< NavLink exact to = { ` /accounts/ ${ account . get ( 'id' ) } /with_replies ` } > < FormattedMessage id = 'account.posts_with_replies' defaultMessage = 'Toots and replies' / > < / N a v L i n k >
2018-03-04 08:19:11 +00:00
< NavLink exact to = { ` /accounts/ ${ account . get ( 'id' ) } /media ` } > < FormattedMessage id = 'account.media' defaultMessage = 'Media' / > < / N a v L i n k >
< / d i v >
) }
2017-01-30 20:40:55 +00:00
< / d i v >
) ;
}
2017-04-21 18:05:35 +00:00
2017-05-12 12:44:10 +00:00
}