logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe
commit: f971bcd06e842f8149ebec7fe2aa6e7152ea3f47
parent: 6b33a05340563dd9a7d543e5c47e1f0cb96edcf6
Author: Morgan Bazalgette <the@howl.moe>
Date:   Fri, 30 Mar 2018 23:52:41 +0200

remove pinned posts

Diffstat:

Mapp/javascript/mastodon/actions/interactions.js80-------------------------------------------------------------------------------
Dapp/javascript/mastodon/actions/pin_statuses.js42------------------------------------------
Mapp/javascript/mastodon/actions/timelines.js1-
Mapp/javascript/mastodon/components/status.js11++---------
Mapp/javascript/mastodon/components/status_action_bar.js6------
Mapp/javascript/mastodon/components/status_list.js15+--------------
Mapp/javascript/mastodon/containers/status_container.js10----------
Mapp/javascript/mastodon/features/account_timeline/index.js13++-----------
Mapp/javascript/mastodon/features/getting_started/index.js2--
Dapp/javascript/mastodon/features/pinned_statuses/index.js59-----------------------------------------------------------
Mapp/javascript/mastodon/features/status/components/action_bar.js6------
Mapp/javascript/mastodon/features/status/index.js11-----------
Mapp/javascript/mastodon/features/ui/index.js8--------
Mapp/javascript/mastodon/features/ui/util/async-components.js4----
Mapp/javascript/mastodon/reducers/status_lists.js11-----------
15 files changed, 5 insertions(+), 274 deletions(-)

diff --git a/app/javascript/mastodon/actions/interactions.js b/app/javascript/mastodon/actions/interactions.js @@ -29,10 +29,6 @@ export const PIN_REQUEST = 'PIN_REQUEST'; export const PIN_SUCCESS = 'PIN_SUCCESS'; export const PIN_FAIL = 'PIN_FAIL'; -export const UNPIN_REQUEST = 'UNPIN_REQUEST'; -export const UNPIN_SUCCESS = 'UNPIN_SUCCESS'; -export const UNPIN_FAIL = 'UNPIN_FAIL'; - export function reblog(status) { return function (dispatch, getState) { dispatch(reblogRequest(status)); @@ -256,79 +252,3 @@ export function fetchFavouritesFail(id, error) { error, }; }; - -export function pin(status) { - return (dispatch, getState) => { - dispatch(pinRequest(status)); - - api(getState).post(`/api/v1/statuses/${status.get('id')}/pin`).then(response => { - dispatch(importFetchedStatus(response.data)); - dispatch(pinSuccess(status)); - }).catch(error => { - dispatch(pinFail(status, error)); - }); - }; -}; - -export function pinRequest(status) { - return { - type: PIN_REQUEST, - status, - skipLoading: true, - }; -}; - -export function pinSuccess(status) { - return { - type: PIN_SUCCESS, - status, - skipLoading: true, - }; -}; - -export function pinFail(status, error) { - return { - type: PIN_FAIL, - status, - error, - skipLoading: true, - }; -}; - -export function unpin (status) { - return (dispatch, getState) => { - dispatch(unpinRequest(status)); - - api(getState).post(`/api/v1/statuses/${status.get('id')}/unpin`).then(response => { - dispatch(importFetchedStatus(response.data)); - dispatch(unpinSuccess(status)); - }).catch(error => { - dispatch(unpinFail(status, error)); - }); - }; -}; - -export function unpinRequest(status) { - return { - type: UNPIN_REQUEST, - status, - skipLoading: true, - }; -}; - -export function unpinSuccess(status) { - return { - type: UNPIN_SUCCESS, - status, - skipLoading: true, - }; -}; - -export function unpinFail(status, error) { - return { - type: UNPIN_FAIL, - status, - error, - skipLoading: true, - }; -}; diff --git a/app/javascript/mastodon/actions/pin_statuses.js b/app/javascript/mastodon/actions/pin_statuses.js @@ -1,42 +0,0 @@ -import api from '../api'; -import { importFetchedStatuses } from './importer'; - -export const PINNED_STATUSES_FETCH_REQUEST = 'PINNED_STATUSES_FETCH_REQUEST'; -export const PINNED_STATUSES_FETCH_SUCCESS = 'PINNED_STATUSES_FETCH_SUCCESS'; -export const PINNED_STATUSES_FETCH_FAIL = 'PINNED_STATUSES_FETCH_FAIL'; - -import { me } from '../initial_state'; - -export function fetchPinnedStatuses() { - return (dispatch, getState) => { - dispatch(fetchPinnedStatusesRequest()); - - api(getState).get(`/api/v1/accounts/${me}/statuses`, { params: { pinned: true } }).then(response => { - dispatch(importFetchedStatuses(response.data)); - dispatch(fetchPinnedStatusesSuccess(response.data, null)); - }).catch(error => { - dispatch(fetchPinnedStatusesFail(error)); - }); - }; -}; - -export function fetchPinnedStatusesRequest() { - return { - type: PINNED_STATUSES_FETCH_REQUEST, - }; -}; - -export function fetchPinnedStatusesSuccess(statuses, next) { - return { - type: PINNED_STATUSES_FETCH_SUCCESS, - statuses, - next, - }; -}; - -export function fetchPinnedStatusesFail(error) { - return { - type: PINNED_STATUSES_FETCH_FAIL, - error, - }; -}; diff --git a/app/javascript/mastodon/actions/timelines.js b/app/javascript/mastodon/actions/timelines.js @@ -88,7 +88,6 @@ export const expandHomeTimeline = ({ maxId } = {}) => expandTimeline('ho export const expandPublicTimeline = ({ maxId } = {}) => expandTimeline('public', '/api/v1/timelines/public', { max_id: maxId }); export const expandCommunityTimeline = ({ maxId } = {}) => expandTimeline('community', '/api/v1/timelines/public', { local: true, max_id: maxId }); export const expandAccountTimeline = (accountId, { maxId, withReplies } = {}) => expandTimeline(`account:${accountId}${withReplies ? ':with_replies' : ''}`, `/api/v1/accounts/${accountId}/statuses`, { exclude_replies: !withReplies, max_id: maxId }); -export const expandAccountFeaturedTimeline = accountId => expandTimeline(`account:${accountId}:pinned`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true }); export const expandAccountMediaTimeline = (accountId, { maxId } = {}) => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { max_id: maxId, only_media: true }); export const expandHashtagTimeline = (hashtag, { maxId } = {}) => expandTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`, { max_id: maxId }); export const expandListTimeline = (id, { maxId } = {}) => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`, { max_id: maxId }); diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js @@ -134,7 +134,7 @@ export default class Status extends ImmutablePureComponent { let media = null; let statusAvatar, prepend; - const { hidden, featured } = this.props; + const { hidden } = this.props; let { status, account, ...other } = this.props; @@ -151,14 +151,7 @@ export default class Status extends ImmutablePureComponent { ); } - if (featured) { - prepend = ( - <div className='status__prepend'> - <div className='status__prepend-icon-wrapper'><i className='fa fa-fw fa-thumb-tack status__prepend-icon' /></div> - <FormattedMessage id='status.pinned' defaultMessage='Pinned toot' /> - </div> - ); - } else if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') { + if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') { const display_name_html = { __html: status.getIn(['account', 'display_name_html']) }; prepend = ( diff --git a/app/javascript/mastodon/components/status_action_bar.js b/app/javascript/mastodon/components/status_action_bar.js @@ -23,8 +23,6 @@ const messages = defineMessages({ report: { id: 'status.report', defaultMessage: 'Report @{name}' }, muteConversation: { id: 'status.mute_conversation', defaultMessage: 'Mute conversation' }, unmuteConversation: { id: 'status.unmute_conversation', defaultMessage: 'Unmute conversation' }, - pin: { id: 'status.pin', defaultMessage: 'Pin on profile' }, - unpin: { id: 'status.unpin', defaultMessage: 'Unpin from profile' }, embed: { id: 'status.embed', defaultMessage: 'Embed' }, }); @@ -140,10 +138,6 @@ export default class StatusActionBar extends ImmutablePureComponent { } if (status.getIn(['account', 'id']) === me) { - if (publicStatus) { - menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); - } - menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick }); } else { menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick }); diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js @@ -31,7 +31,6 @@ export default class StatusList extends ImmutablePureComponent { static propTypes = { scrollKey: PropTypes.string.isRequired, statusIds: ImmutablePropTypes.list.isRequired, - featuredStatusIds: ImmutablePropTypes.list, onLoadMore: PropTypes.func, onScrollToTop: PropTypes.func, onScroll: PropTypes.func, @@ -75,7 +74,7 @@ export default class StatusList extends ImmutablePureComponent { } render () { - const { statusIds, featuredStatusIds, onLoadMore, ...other } = this.props; + const { statusIds, onLoadMore, ...other } = this.props; const { isLoading, isPartial } = other; if (isPartial) { @@ -109,18 +108,6 @@ export default class StatusList extends ImmutablePureComponent { )) ) : null; - if (scrollableContent && featuredStatusIds) { - scrollableContent = featuredStatusIds.map(statusId => ( - <StatusContainer - key={`f-${statusId}`} - id={statusId} - featured - onMoveUp={this.handleMoveUp} - onMoveDown={this.handleMoveDown} - /> - )).concat(scrollableContent); - } - return ( <ScrollableList {...other} onLoadMore={onLoadMore && this.handleLoadOlder} ref={this.setRef}> {scrollableContent} diff --git a/app/javascript/mastodon/containers/status_container.js b/app/javascript/mastodon/containers/status_container.js @@ -11,8 +11,6 @@ import { favourite, unreblog, unfavourite, - pin, - unpin, } from '../actions/interactions'; import { blockAccount } from '../actions/accounts'; import { @@ -74,14 +72,6 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ } }, - onPin (status) { - if (status.get('pinned')) { - dispatch(unpin(status)); - } else { - dispatch(pin(status)); - } - }, - onEmbed (status) { dispatch(openModal('EMBED', { url: status.get('url') })); }, diff --git a/app/javascript/mastodon/features/account_timeline/index.js b/app/javascript/mastodon/features/account_timeline/index.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import { fetchAccount } from '../../actions/accounts'; -import { expandAccountFeaturedTimeline, expandAccountTimeline } from '../../actions/timelines'; +import { expandAccountTimeline } from '../../actions/timelines'; import StatusList from '../../components/status_list'; import LoadingIndicator from '../../components/loading_indicator'; import Column from '../ui/components/column'; @@ -17,7 +17,6 @@ const mapStateToProps = (state, { params: { accountId }, withReplies = false }) return { statusIds: state.getIn(['timelines', `account:${path}`, 'items'], ImmutableList()), - featuredStatusIds: withReplies ? ImmutableList() : state.getIn(['timelines', `account:${accountId}:pinned`, 'items'], ImmutableList()), isLoading: state.getIn(['timelines', `account:${path}`, 'isLoading']), hasMore: state.getIn(['timelines', `account:${path}`, 'hasMore']), }; @@ -30,7 +29,6 @@ export default class AccountTimeline extends ImmutablePureComponent { params: PropTypes.object.isRequired, dispatch: PropTypes.func.isRequired, statusIds: ImmutablePropTypes.list, - featuredStatusIds: ImmutablePropTypes.list, isLoading: PropTypes.bool, hasMore: PropTypes.bool, withReplies: PropTypes.bool, @@ -40,18 +38,12 @@ export default class AccountTimeline extends ImmutablePureComponent { const { params: { accountId }, withReplies } = this.props; this.props.dispatch(fetchAccount(accountId)); - if (!withReplies) { - this.props.dispatch(expandAccountFeaturedTimeline(accountId)); - } this.props.dispatch(expandAccountTimeline(accountId, { withReplies })); } componentWillReceiveProps (nextProps) { if ((nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) || nextProps.withReplies !== this.props.withReplies) { this.props.dispatch(fetchAccount(nextProps.params.accountId)); - if (!nextProps.withReplies) { - this.props.dispatch(expandAccountFeaturedTimeline(nextProps.params.accountId)); - } this.props.dispatch(expandAccountTimeline(nextProps.params.accountId, { withReplies: nextProps.params.withReplies })); } } @@ -61,7 +53,7 @@ export default class AccountTimeline extends ImmutablePureComponent { } render () { - const { statusIds, featuredStatusIds, isLoading, hasMore } = this.props; + const { statusIds, isLoading, hasMore } = this.props; if (!statusIds && isLoading) { return ( @@ -79,7 +71,6 @@ export default class AccountTimeline extends ImmutablePureComponent { prepend={<HeaderContainer accountId={this.props.params.accountId} />} scrollKey='account_timeline' statusIds={statusIds} - featuredStatusIds={featuredStatusIds} isLoading={isLoading} hasMore={hasMore} onLoadMore={this.handleLoadMore} diff --git a/app/javascript/mastodon/features/getting_started/index.js b/app/javascript/mastodon/features/getting_started/index.js @@ -26,7 +26,6 @@ const messages = defineMessages({ blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' }, mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' }, info: { id: 'navigation_bar.info', defaultMessage: 'Extended information' }, - pins: { id: 'navigation_bar.pins', defaultMessage: 'Pinned toots' }, lists: { id: 'navigation_bar.lists', defaultMessage: 'Lists' }, keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Keyboard shortcuts' }, }); @@ -118,7 +117,6 @@ export default class GettingStarted extends ImmutablePureComponent { <ColumnSubheading text={intl.formatMessage(messages.navigation_subheading)} /> {navItems} <ColumnSubheading text={intl.formatMessage(messages.settings_subheading)} /> - <ColumnLink icon='thumb-tack' text={intl.formatMessage(messages.pins)} to='/pinned' /> <ColumnLink icon='volume-off' text={intl.formatMessage(messages.mutes)} to='/mutes' /> <ColumnLink icon='ban' text={intl.formatMessage(messages.blocks)} to='/blocks' /> <ColumnLink icon='cog' text={intl.formatMessage(messages.preferences)} href='/settings/preferences' /> diff --git a/app/javascript/mastodon/features/pinned_statuses/index.js b/app/javascript/mastodon/features/pinned_statuses/index.js @@ -1,59 +0,0 @@ -import React from 'react'; -import { connect } from 'react-redux'; -import PropTypes from 'prop-types'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import { fetchPinnedStatuses } from '../../actions/pin_statuses'; -import Column from '../ui/components/column'; -import ColumnBackButtonSlim from '../../components/column_back_button_slim'; -import StatusList from '../../components/status_list'; -import { defineMessages, injectIntl } from 'react-intl'; -import ImmutablePureComponent from 'react-immutable-pure-component'; - -const messages = defineMessages({ - heading: { id: 'column.pins', defaultMessage: 'Pinned toot' }, -}); - -const mapStateToProps = state => ({ - statusIds: state.getIn(['status_lists', 'pins', 'items']), - hasMore: !!state.getIn(['status_lists', 'pins', 'next']), -}); - -@connect(mapStateToProps) -@injectIntl -export default class PinnedStatuses extends ImmutablePureComponent { - - static propTypes = { - dispatch: PropTypes.func.isRequired, - statusIds: ImmutablePropTypes.list.isRequired, - intl: PropTypes.object.isRequired, - hasMore: PropTypes.bool.isRequired, - }; - - componentWillMount () { - this.props.dispatch(fetchPinnedStatuses()); - } - - handleHeaderClick = () => { - this.column.scrollTop(); - } - - setRef = c => { - this.column = c; - } - - render () { - const { intl, statusIds, hasMore } = this.props; - - return ( - <Column icon='thumb-tack' heading={intl.formatMessage(messages.heading)} ref={this.setRef}> - <ColumnBackButtonSlim /> - <StatusList - statusIds={statusIds} - scrollKey='pinned_statuses' - hasMore={hasMore} - /> - </Column> - ); - } - -} diff --git a/app/javascript/mastodon/features/status/components/action_bar.js b/app/javascript/mastodon/features/status/components/action_bar.js @@ -19,8 +19,6 @@ const messages = defineMessages({ block: { id: 'status.block', defaultMessage: 'Block @{name}' }, report: { id: 'status.report', defaultMessage: 'Report @{name}' }, share: { id: 'status.share', defaultMessage: 'Share' }, - pin: { id: 'status.pin', defaultMessage: 'Pin on profile' }, - unpin: { id: 'status.unpin', defaultMessage: 'Unpin from profile' }, embed: { id: 'status.embed', defaultMessage: 'Embed' }, }); @@ -111,10 +109,6 @@ export default class ActionBar extends React.PureComponent { } if (me === status.getIn(['account', 'id'])) { - if (publicStatus) { - menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); - } - menu.push(null); menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick }); menu.push(null); diff --git a/app/javascript/mastodon/features/status/index.js b/app/javascript/mastodon/features/status/index.js @@ -13,8 +13,6 @@ import { unfavourite, reblog, unreblog, - pin, - unpin, } from '../../actions/interactions'; import { replyCompose, @@ -106,14 +104,6 @@ export default class Status extends ImmutablePureComponent { } } - handlePin = (status) => { - if (status.get('pinned')) { - this.props.dispatch(unpin(status)); - } else { - this.props.dispatch(pin(status)); - } - } - handleReplyClick = (status) => { this.props.dispatch(replyCompose(status, this.context.router.history)); } @@ -384,7 +374,6 @@ export default class Status extends ImmutablePureComponent { onMuteConversation={this.handleConversationMuteClick} onBlock={this.handleBlockClick} onReport={this.handleReport} - onPin={this.handlePin} onEmbed={this.handleEmbed} /> </div> diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js @@ -38,7 +38,6 @@ import { ListTimeline, Blocks, Mutes, - PinnedStatuses, Lists, } from './util/async-components'; import { HotKeys } from 'react-hotkeys'; @@ -80,7 +79,6 @@ const keyMap = { goToFederated: 'g t', goToStart: 'g s', goToFavourites: 'g f', - goToPinned: 'g p', goToProfile: 'g u', goToBlocked: 'g b', goToMuted: 'g m', @@ -143,7 +141,6 @@ class SwitchingColumnsArea extends React.PureComponent { <WrappedRoute path='/notifications' component={Notifications} content={children} /> <WrappedRoute path='/favourites' component={FavouritedStatuses} content={children} /> - <WrappedRoute path='/pinned' component={PinnedStatuses} content={children} /> <WrappedRoute path='/statuses/new' component={Compose} content={children} /> <WrappedRoute path='/statuses/:statusId' exact component={Status} content={children} /> @@ -389,10 +386,6 @@ export default class UI extends React.PureComponent { this.context.router.history.push('/favourites'); } - handleHotkeyGoToPinned = () => { - this.context.router.history.push('/pinned'); - } - handleHotkeyGoToProfile = () => { this.context.router.history.push(`/accounts/${me}`); } @@ -422,7 +415,6 @@ export default class UI extends React.PureComponent { goToFederated: this.handleHotkeyGoToFederated, goToStart: this.handleHotkeyGoToStart, goToFavourites: this.handleHotkeyGoToFavourites, - goToPinned: this.handleHotkeyGoToPinned, goToProfile: this.handleHotkeyGoToProfile, goToBlocked: this.handleHotkeyGoToBlocked, goToMuted: this.handleHotkeyGoToMuted, diff --git a/app/javascript/mastodon/features/ui/util/async-components.js b/app/javascript/mastodon/features/ui/util/async-components.js @@ -46,10 +46,6 @@ export function KeyboardShortcuts () { return import(/* webpackChunkName: "features/keyboard_shortcuts" */'../../keyboard_shortcuts'); } -export function PinnedStatuses () { - return import(/* webpackChunkName: "features/pinned_statuses" */'../../pinned_statuses'); -} - export function AccountTimeline () { return import(/* webpackChunkName: "features/account_timeline" */'../../account_timeline'); } diff --git a/app/javascript/mastodon/reducers/status_lists.js b/app/javascript/mastodon/reducers/status_lists.js @@ -6,15 +6,10 @@ import { FAVOURITED_STATUSES_EXPAND_SUCCESS, FAVOURITED_STATUSES_EXPAND_FAIL, } from '../actions/favourites'; -import { - PINNED_STATUSES_FETCH_SUCCESS, -} from '../actions/pin_statuses'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; import { FAVOURITE_SUCCESS, UNFAVOURITE_SUCCESS, - PIN_SUCCESS, - UNPIN_SUCCESS, } from '../actions/interactions'; const initialState = ImmutableMap({ @@ -75,12 +70,6 @@ export default function statusLists(state = initialState, action) { return prependOneToList(state, 'favourites', action.status); case UNFAVOURITE_SUCCESS: return removeOneFromList(state, 'favourites', action.status); - case PINNED_STATUSES_FETCH_SUCCESS: - return normalizeList(state, 'pins', action.statuses, action.next); - case PIN_SUCCESS: - return prependOneToList(state, 'pins', action.status); - case UNPIN_SUCCESS: - return removeOneFromList(state, 'pins', action.status); default: return state; }