mirror of
https://github.com/funamitech/mastodon
synced 2024-12-13 22:29:07 +09:00
[Glitch] Add exclusive lists
Port bacb674921
to glitch-soc
Co-authored-by: Liam Cooke <liam@liamcooke.com>
Co-authored-by: John Holdun <john@johnholdun.com>
Co-authored-by: Effy Elden <effy@effy.space>
Co-authored-by: Lina Reyne <git@lina.pizza>
Co-authored-by: Lina <20880695+necropolina@users.noreply.github.com>
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
bf23afa059
commit
a8a30f1298
@ -151,10 +151,10 @@ export const createListFail = error => ({
|
|||||||
error,
|
error,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const updateList = (id, title, shouldReset, replies_policy) => (dispatch, getState) => {
|
export const updateList = (id, title, shouldReset, isExclusive, replies_policy) => (dispatch, getState) => {
|
||||||
dispatch(updateListRequest(id));
|
dispatch(updateListRequest(id));
|
||||||
|
|
||||||
api(getState).put(`/api/v1/lists/${id}`, { title, replies_policy }).then(({ data }) => {
|
api(getState).put(`/api/v1/lists/${id}`, { title, replies_policy, exclusive: typeof isExclusive === 'undefined' ? undefined : !!isExclusive }).then(({ data }) => {
|
||||||
dispatch(updateListSuccess(data));
|
dispatch(updateListSuccess(data));
|
||||||
|
|
||||||
if (shouldReset) {
|
if (shouldReset) {
|
||||||
|
@ -8,6 +8,8 @@ import { Helmet } from 'react-helmet';
|
|||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import Toggle from 'react-toggle';
|
||||||
|
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
||||||
import { fetchList, deleteList, updateList } from 'flavours/glitch/actions/lists';
|
import { fetchList, deleteList, updateList } from 'flavours/glitch/actions/lists';
|
||||||
import { openModal } from 'flavours/glitch/actions/modal';
|
import { openModal } from 'flavours/glitch/actions/modal';
|
||||||
@ -145,7 +147,13 @@ class ListTimeline extends PureComponent {
|
|||||||
handleRepliesPolicyChange = ({ target }) => {
|
handleRepliesPolicyChange = ({ target }) => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
const { id } = this.props.params;
|
const { id } = this.props.params;
|
||||||
dispatch(updateList(id, undefined, false, target.value));
|
dispatch(updateList(id, undefined, false, undefined, target.value));
|
||||||
|
};
|
||||||
|
|
||||||
|
onExclusiveToggle = ({ target }) => {
|
||||||
|
const { dispatch } = this.props;
|
||||||
|
const { id } = this.props.params;
|
||||||
|
dispatch(updateList(id, undefined, false, target.checked, undefined));
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@ -154,6 +162,7 @@ class ListTimeline extends PureComponent {
|
|||||||
const pinned = !!columnId;
|
const pinned = !!columnId;
|
||||||
const title = list ? list.get('title') : id;
|
const title = list ? list.get('title') : id;
|
||||||
const replies_policy = list ? list.get('replies_policy') : undefined;
|
const replies_policy = list ? list.get('replies_policy') : undefined;
|
||||||
|
const isExclusive = list ? list.get('exclusive') : undefined;
|
||||||
|
|
||||||
if (typeof list === 'undefined') {
|
if (typeof list === 'undefined') {
|
||||||
return (
|
return (
|
||||||
@ -191,6 +200,13 @@ class ListTimeline extends PureComponent {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='setting-toggle'>
|
||||||
|
<Toggle id={`list-${id}-exclusive`} defaultChecked={isExclusive} onChange={this.onExclusiveToggle} />
|
||||||
|
<label htmlFor={`list-${id}-exclusive`} className='setting-toggle__label'>
|
||||||
|
<FormattedMessage id='lists.exclusive' defaultMessage='Hide these posts from home' />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
{ replies_policy !== undefined && (
|
{ replies_policy !== undefined && (
|
||||||
<div role='group' aria-labelledby={`list-${id}-replies-policy`}>
|
<div role='group' aria-labelledby={`list-${id}-replies-policy`}>
|
||||||
<span id={`list-${id}-replies-policy`} className='column-settings__section'>
|
<span id={`list-${id}-replies-policy`} className='column-settings__section'>
|
||||||
|
@ -25,6 +25,7 @@ const initialState = ImmutableMap({
|
|||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
isChanged: false,
|
isChanged: false,
|
||||||
title: '',
|
title: '',
|
||||||
|
isExclusive: false,
|
||||||
|
|
||||||
accounts: ImmutableMap({
|
accounts: ImmutableMap({
|
||||||
items: ImmutableList(),
|
items: ImmutableList(),
|
||||||
@ -46,6 +47,7 @@ export default function listEditorReducer(state = initialState, action) {
|
|||||||
return state.withMutations(map => {
|
return state.withMutations(map => {
|
||||||
map.set('listId', action.list.get('id'));
|
map.set('listId', action.list.get('id'));
|
||||||
map.set('title', action.list.get('title'));
|
map.set('title', action.list.get('title'));
|
||||||
|
map.set('isExclusive', action.list.get('is_exclusive'));
|
||||||
map.set('isSubmitting', false);
|
map.set('isSubmitting', false);
|
||||||
});
|
});
|
||||||
case LIST_EDITOR_TITLE_CHANGE:
|
case LIST_EDITOR_TITLE_CHANGE:
|
||||||
|
Loading…
Reference in New Issue
Block a user