Compare commits
13 Commits
9af06720e2
...
2aa09944d4
Author | SHA1 | Date |
---|---|---|
JS Moore | 2aa09944d4 | |
Claire | 113c931cda | |
Claire | b79df709a8 | |
Claire | 0e071edccc | |
GitHub Actions | c61130af33 | |
JS Moore | 31877748b8 | |
JS Moore | 4c3486815e | |
JS Moore | a34d5c1bfe | |
JS Moore | c08dfb1e0c | |
JS Moore | 83c6600d1f | |
JS Moore | ec5ec54af3 | |
JS Moore | c811a79c9b | |
JS Moore | cc9a5c9654 |
|
@ -3,6 +3,7 @@
|
|||
class Api::BaseController < ApplicationController
|
||||
DEFAULT_STATUSES_LIMIT = 20
|
||||
DEFAULT_ACCOUNTS_LIMIT = 40
|
||||
DEFAULT_TAGS_LIMIT = 40
|
||||
|
||||
include Api::RateLimitHeaders
|
||||
include Api::AccessTokenTrackingConcern
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Lists::TagsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:show]
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:show]
|
||||
|
||||
before_action :require_user!
|
||||
before_action :set_list
|
||||
|
||||
after_action :insert_pagination_headers, only: :show
|
||||
|
||||
def show
|
||||
@tags = load_tags
|
||||
render json: @tags, each_serializer: REST::TagSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
ApplicationRecord.transaction do
|
||||
list_tags.each do |tag|
|
||||
@list.tags << tag
|
||||
end
|
||||
end
|
||||
@tags = load_tags
|
||||
render json: @tags, each_serializer: REST::TagSerializer
|
||||
end
|
||||
|
||||
def destroy
|
||||
ListTag.where(list: @list, tag_id: tag_ids).destroy_all
|
||||
render_empty
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_list
|
||||
@list = List.where(account: current_account).find(params[:list_id])
|
||||
end
|
||||
|
||||
def load_tags
|
||||
if unlimited?
|
||||
@list.tags.all
|
||||
else
|
||||
@list.tags.paginate_by_max_id(limit_param(DEFAULT_TAGS_LIMIT), params[:max_id], params[:since_id])
|
||||
end
|
||||
end
|
||||
|
||||
def list_tags
|
||||
names = tag_ids.grep_v(/\A[0-9]+\Z/)
|
||||
ids = tag_ids.grep(/\A[0-9]+\Z/)
|
||||
existing_by_name = Tag.where(name: names.map { |n| Tag.normalize(n) }).select(:id, :name)
|
||||
ids.push(*existing_by_name.map(&:id))
|
||||
not_existing_by_name = names.reject { |n| existing_by_name.any? { |e| e.name == Tag.normalize(n) } }
|
||||
created = Tag.find_or_create_by_names(not_existing_by_name)
|
||||
ids.push(*created.map(&:id))
|
||||
Tag.find(ids)
|
||||
end
|
||||
|
||||
def tag_ids
|
||||
Array(resource_params[:tag_ids])
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(tag_ids: [])
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
end
|
||||
|
||||
def next_path
|
||||
return if unlimited?
|
||||
|
||||
api_v1_list_tags_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
return if unlimited?
|
||||
|
||||
api_v1_list_tags_url pagination_params(since_id: pagination_since_id) unless @tags.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
@tags.last.id
|
||||
end
|
||||
|
||||
def pagination_since_id
|
||||
@tags.first.id
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
@tags.size == limit_param(DEFAULT_TAGS_LIMIT)
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
params.slice(:limit).permit(:limit).merge(core_params)
|
||||
end
|
||||
|
||||
def unlimited?
|
||||
params[:limit] == '0'
|
||||
end
|
||||
end
|
|
@ -6,6 +6,7 @@ export const STATUS_IMPORT = 'STATUS_IMPORT';
|
|||
export const STATUSES_IMPORT = 'STATUSES_IMPORT';
|
||||
export const POLLS_IMPORT = 'POLLS_IMPORT';
|
||||
export const FILTERS_IMPORT = 'FILTERS_IMPORT';
|
||||
export const TAGS_IMPORT = 'TAGS_IMPORT';
|
||||
|
||||
function pushUnique(array, object) {
|
||||
if (array.every(element => element.id !== object.id)) {
|
||||
|
@ -29,6 +30,10 @@ export function importPolls(polls) {
|
|||
return { type: POLLS_IMPORT, polls };
|
||||
}
|
||||
|
||||
export function importTags(tags) {
|
||||
return { type: TAGS_IMPORT, tags };
|
||||
}
|
||||
|
||||
export function importFetchedAccount(account) {
|
||||
return importFetchedAccounts([account]);
|
||||
}
|
||||
|
@ -49,6 +54,17 @@ export function importFetchedAccounts(accounts) {
|
|||
return importAccounts({ accounts: normalAccounts });
|
||||
}
|
||||
|
||||
export function importFetchedTags(tags) {
|
||||
return (dispatch) => {
|
||||
const uniqueTags = [];
|
||||
function processTag(tag) {
|
||||
pushUnique(uniqueTags, tag);
|
||||
}
|
||||
tags.forEach(processTag);
|
||||
dispatch(importTags(uniqueTags));
|
||||
};
|
||||
}
|
||||
|
||||
export function importFetchedStatus(status) {
|
||||
return importFetchedStatuses([status]);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import api from '../api';
|
||||
|
||||
import { showAlertForError } from './alerts';
|
||||
import { importFetchedAccounts } from './importer';
|
||||
import { importFetchedAccounts, importFetchedTags } from './importer';
|
||||
|
||||
export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST';
|
||||
export const LIST_FETCH_SUCCESS = 'LIST_FETCH_SUCCESS';
|
||||
|
@ -31,6 +31,10 @@ export const LIST_ACCOUNTS_FETCH_REQUEST = 'LIST_ACCOUNTS_FETCH_REQUEST';
|
|||
export const LIST_ACCOUNTS_FETCH_SUCCESS = 'LIST_ACCOUNTS_FETCH_SUCCESS';
|
||||
export const LIST_ACCOUNTS_FETCH_FAIL = 'LIST_ACCOUNTS_FETCH_FAIL';
|
||||
|
||||
export const LIST_TAGS_FETCH_REQUEST = 'LIST_TAGS_FETCH_REQUEST';
|
||||
export const LIST_TAGS_FETCH_SUCCESS = 'LIST_TAGS_FETCH_SUCCESS';
|
||||
export const LIST_TAGS_FETCH_FAIL = 'LIST_TAGS_FETCH_FAIL';
|
||||
|
||||
export const LIST_EDITOR_SUGGESTIONS_CHANGE = 'LIST_EDITOR_SUGGESTIONS_CHANGE';
|
||||
export const LIST_EDITOR_SUGGESTIONS_READY = 'LIST_EDITOR_SUGGESTIONS_READY';
|
||||
export const LIST_EDITOR_SUGGESTIONS_CLEAR = 'LIST_EDITOR_SUGGESTIONS_CLEAR';
|
||||
|
@ -118,6 +122,7 @@ export const setupListEditor = listId => (dispatch, getState) => {
|
|||
});
|
||||
|
||||
dispatch(fetchListAccounts(listId));
|
||||
dispatch(fetchListTags(listId));
|
||||
};
|
||||
|
||||
export const changeListEditorTitle = value => ({
|
||||
|
@ -234,6 +239,33 @@ export const fetchListAccountsFail = (id, error) => ({
|
|||
error,
|
||||
});
|
||||
|
||||
export const fetchListTags = listId => (dispatch, getState) => {
|
||||
dispatch(fetchListTagsRequest(listId));
|
||||
|
||||
api(getState).get(`/api/v1/lists/${listId}/tags`, { params: { limit: 0 } }).then(({ data }) => {
|
||||
dispatch(importFetchedTags(data));
|
||||
dispatch(fetchListTagsSuccess(listId, data));
|
||||
}).catch(err => dispatch(fetchListTagsFail(listId, err)));
|
||||
};
|
||||
|
||||
export const fetchListTagsFail = (id, error) => ({
|
||||
type: LIST_TAGS_FETCH_FAIL,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
export const fetchListTagsRequest = id => ({
|
||||
type: LIST_TAGS_FETCH_REQUEST,
|
||||
id,
|
||||
});
|
||||
|
||||
export const fetchListTagsSuccess = (id, tags, next) => ({
|
||||
type: LIST_TAGS_FETCH_SUCCESS,
|
||||
id,
|
||||
tags,
|
||||
next,
|
||||
});
|
||||
|
||||
export const fetchListSuggestions = q => (dispatch, getState) => {
|
||||
const params = {
|
||||
q,
|
||||
|
@ -263,65 +295,84 @@ export const changeListSuggestions = value => ({
|
|||
value,
|
||||
});
|
||||
|
||||
export const addToListEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(addToList(getState().getIn(['listEditor', 'listId']), accountId));
|
||||
export const addToListEditor = (id, type) => (dispatch, getState) => {
|
||||
dispatch(addToList(getState().getIn(['listEditor', 'listId']), id, type));
|
||||
};
|
||||
|
||||
export const addToList = (listId, accountId) => (dispatch, getState) => {
|
||||
dispatch(addToListRequest(listId, accountId));
|
||||
|
||||
api(getState).post(`/api/v1/lists/${listId}/accounts`, { account_ids: [accountId] })
|
||||
.then(() => dispatch(addToListSuccess(listId, accountId)))
|
||||
.catch(err => dispatch(addToListFail(listId, accountId, err)));
|
||||
export const addToList = (listId, id, type) => (dispatch, getState) => {
|
||||
dispatch(addToListRequest(listId, id, type));
|
||||
|
||||
if ('tags' === type) {
|
||||
api(getState).post(`/api/v1/lists/${listId}/tags`, { tag_ids: [id] })
|
||||
.then((data) => dispatch(addToListSuccess(listId, id, type, data)))
|
||||
.catch(err => dispatch(addToListFail(listId, id, type, err)));
|
||||
} else {
|
||||
api(getState).post(`/api/v1/lists/${listId}/accounts`, { account_ids: [id] })
|
||||
.then(() => dispatch(addToListSuccess(listId, id, type)))
|
||||
.catch(err => dispatch(addToListFail(listId, id, type, err)));
|
||||
}
|
||||
};
|
||||
|
||||
export const addToListRequest = (listId, accountId) => ({
|
||||
export const addToListRequest = (listId, id, type) => ({
|
||||
type: LIST_EDITOR_ADD_REQUEST,
|
||||
addType: type,
|
||||
listId,
|
||||
accountId,
|
||||
id,
|
||||
});
|
||||
|
||||
export const addToListSuccess = (listId, accountId) => ({
|
||||
export const addToListSuccess = (listId, id, type, data) => ({
|
||||
type: LIST_EDITOR_ADD_SUCCESS,
|
||||
addType: type,
|
||||
listId,
|
||||
accountId,
|
||||
id,
|
||||
data,
|
||||
});
|
||||
|
||||
export const addToListFail = (listId, accountId, error) => ({
|
||||
export const addToListFail = (listId, id, type, error) => ({
|
||||
type: LIST_EDITOR_ADD_FAIL,
|
||||
addType: type,
|
||||
listId,
|
||||
accountId,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeFromListEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(removeFromList(getState().getIn(['listEditor', 'listId']), accountId));
|
||||
export const removeFromListEditor = (id, type) => (dispatch, getState) => {
|
||||
dispatch(removeFromList(getState().getIn(['listEditor', 'listId']), id, type));
|
||||
};
|
||||
|
||||
export const removeFromList = (listId, accountId) => (dispatch, getState) => {
|
||||
dispatch(removeFromListRequest(listId, accountId));
|
||||
export const removeFromList = (listId, id, type) => (dispatch, getState) => {
|
||||
dispatch(removeFromListRequest(listId, id, type));
|
||||
|
||||
api(getState).delete(`/api/v1/lists/${listId}/accounts`, { params: { account_ids: [accountId] } })
|
||||
.then(() => dispatch(removeFromListSuccess(listId, accountId)))
|
||||
.catch(err => dispatch(removeFromListFail(listId, accountId, err)));
|
||||
if ('tags' === type) {
|
||||
api(getState).delete(`/api/v1/lists/${listId}/tags`, { params: { tag_ids: [id] } })
|
||||
.then(() => dispatch(removeFromListSuccess(listId, id, type)))
|
||||
.catch(err => dispatch(removeFromListFail(listId, id, type, err)));
|
||||
} else {
|
||||
api(getState).delete(`/api/v1/lists/${listId}/accounts`, { params: { account_ids: [id] } })
|
||||
.then(() => dispatch(removeFromListSuccess(listId, id, type)))
|
||||
.catch(err => dispatch(removeFromListFail(listId, id, type, err)));
|
||||
}
|
||||
};
|
||||
|
||||
export const removeFromListRequest = (listId, accountId) => ({
|
||||
export const removeFromListRequest = (listId, id, type) => ({
|
||||
type: LIST_EDITOR_REMOVE_REQUEST,
|
||||
removeType: type,
|
||||
listId,
|
||||
accountId,
|
||||
id,
|
||||
});
|
||||
|
||||
export const removeFromListSuccess = (listId, accountId) => ({
|
||||
export const removeFromListSuccess = (listId, id, type) => ({
|
||||
type: LIST_EDITOR_REMOVE_SUCCESS,
|
||||
removeType: type,
|
||||
listId,
|
||||
accountId,
|
||||
id,
|
||||
});
|
||||
|
||||
export const removeFromListFail = (listId, accountId, error) => ({
|
||||
export const removeFromListFail = (listId, id, type, error) => ({
|
||||
type: LIST_EDITOR_REMOVE_FAIL,
|
||||
removeType: type,
|
||||
listId,
|
||||
accountId,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ const makeMapStateToProps = () => {
|
|||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch, { accountId }) => ({
|
||||
onRemove: () => dispatch(removeFromListEditor(accountId)),
|
||||
onAdd: () => dispatch(addToListEditor(accountId)),
|
||||
onRemove: () => dispatch(removeFromListEditor(accountId, 'accounts')),
|
||||
onAdd: () => dispatch(addToListEditor(accountId, 'accounts')),
|
||||
});
|
||||
|
||||
class Account extends ImmutablePureComponent {
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import CancelIcon from '@/material-icons/400-24px/cancel.svg?react';
|
||||
import TagIcon from '@/material-icons/400-24px/tag.svg?react';
|
||||
import { Icon } from 'flavours/glitch/components/icon';
|
||||
|
||||
import { addToListEditor, changeListSuggestions } from '../../../actions/lists';
|
||||
|
||||
const messages = defineMessages({
|
||||
addtag: { id: 'lists.addtag', defaultMessage: 'Enter a tag you\'d like to follow' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
value: state.getIn(['listEditor', 'suggestions', 'value']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onSubmit: value => dispatch(addToListEditor(value, 'tags')),
|
||||
onChange: value => dispatch(changeListSuggestions(value)),
|
||||
});
|
||||
|
||||
class AddTag extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
value: PropTypes.string.isRequired,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
handleChange = e => {
|
||||
//this.props.value = e.target.value;
|
||||
this.props.onChange(e.target.value);
|
||||
};
|
||||
|
||||
handleKeyUp = e => {
|
||||
if (e.keyCode === 13) {
|
||||
this.props.onSubmit(this.props.value);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { value, intl } = this.props;
|
||||
const hasValue = value.length > 0;
|
||||
|
||||
return (
|
||||
<div className='list-editor__search search'>
|
||||
<label>
|
||||
<span style={{ display: 'none' }}>{intl.formatMessage(messages.addtag)}</span>
|
||||
<input
|
||||
className='search__input'
|
||||
type='text'
|
||||
value={value}
|
||||
onChange={this.handleChange}
|
||||
onKeyUp={this.handleKeyUp}
|
||||
placeholder={intl.formatMessage(messages.addtag)}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div role='button' tabIndex={0} className='search__icon'>
|
||||
<Icon id='add' icon={TagIcon} className={classNames({ active: !hasValue })} />
|
||||
<Icon id='times-circle' icon={CancelIcon} aria-label={intl.formatMessage(messages.addtag)} className={classNames({ active: hasValue })} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(AddTag));
|
|
@ -0,0 +1,67 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
|
||||
import TagIcon from '@/material-icons/400-24px/tag.svg?react';
|
||||
import { Icon } from 'flavours/glitch/components/icon';
|
||||
|
||||
import { removeFromListEditor, addToListEditor } from '../../../actions/lists';
|
||||
import { IconButton } from '../../../components/icon_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
remove: { id: 'lists.tag.remove', defaultMessage: 'Remove from list' },
|
||||
add: { id: 'lists.tag.add', defaultMessage: 'Add to list' },
|
||||
});
|
||||
|
||||
const makeMapStateToProps = () => {
|
||||
const mapStateToProps = (state, { tag, added }) => ({
|
||||
tag: tag,
|
||||
added: typeof added === 'undefined' ? state.getIn(['listEditor', 'tags', 'items']).includes(tag) : added,
|
||||
});
|
||||
|
||||
return mapStateToProps;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch, { tag }) => ({
|
||||
onRemove: () => dispatch(removeFromListEditor(tag.id, 'tags')),
|
||||
onAdd: () => dispatch(addToListEditor(tag.id, 'tags')),
|
||||
});
|
||||
|
||||
class Tag extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
tag: PropTypes.object.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onRemove: PropTypes.func.isRequired,
|
||||
onAdd: PropTypes.func.isRequired,
|
||||
added: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
added: false,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { tag, intl, onRemove } = this.props;
|
||||
|
||||
return (
|
||||
<div className='list_tag'>
|
||||
<Icon icon={TagIcon} />
|
||||
<div className='list_tag__display-name'>
|
||||
{tag.name}
|
||||
</div>
|
||||
|
||||
<div className='list_tag__relationship'>
|
||||
<IconButton icon='times' iconComponent={CloseIcon} title={intl.formatMessage(messages.remove)} onClick={onRemove} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(makeMapStateToProps, mapDispatchToProps)(injectIntl(Tag));
|
|
@ -1,6 +1,6 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { injectIntl } from 'react-intl';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
|
@ -12,10 +12,18 @@ import { setupListEditor, clearListSuggestions, resetListEditor } from '../../ac
|
|||
import Motion from '../ui/util/optional_motion';
|
||||
|
||||
import Account from './components/account';
|
||||
import AddTag from './components/add_tag';
|
||||
import EditListForm from './components/edit_list_form';
|
||||
import Search from './components/search';
|
||||
import Tag from './components/tag';
|
||||
|
||||
const messages = defineMessages({
|
||||
account_tab: { id: 'lists.account_tab', defaultMessage: 'Accounts' },
|
||||
tag_tab: { id: 'lists.tag_tab', defaultMessage: 'Tags' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
tags: state.getIn(['listEditor', 'tags', 'items']),
|
||||
accountIds: state.getIn(['listEditor', 'accounts', 'items']),
|
||||
searchAccountIds: state.getIn(['listEditor', 'suggestions', 'items']),
|
||||
});
|
||||
|
@ -27,6 +35,9 @@ const mapDispatchToProps = dispatch => ({
|
|||
});
|
||||
|
||||
class ListEditor extends ImmutablePureComponent {
|
||||
state = {
|
||||
currentTab: 'accounts',
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
listId: PropTypes.string.isRequired,
|
||||
|
@ -35,44 +46,70 @@ class ListEditor extends ImmutablePureComponent {
|
|||
onInitialize: PropTypes.func.isRequired,
|
||||
onClear: PropTypes.func.isRequired,
|
||||
onReset: PropTypes.func.isRequired,
|
||||
tags: ImmutablePropTypes.list.isRequired,
|
||||
accountIds: ImmutablePropTypes.list.isRequired,
|
||||
searchAccountIds: ImmutablePropTypes.list.isRequired,
|
||||
};
|
||||
|
||||
componentDidMount () {
|
||||
componentDidMount() {
|
||||
const { onInitialize, listId } = this.props;
|
||||
onInitialize(listId);
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
componentWillUnmount() {
|
||||
const { onReset } = this.props;
|
||||
onReset();
|
||||
}
|
||||
|
||||
render () {
|
||||
const { accountIds, searchAccountIds, onClear } = this.props;
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.switchToAccounts = this.switchToAccounts.bind(this);
|
||||
this.switchToTags = this.switchToTags.bind(this);
|
||||
}
|
||||
|
||||
switchToAccounts() {
|
||||
this.setState({ currentTab: 'accounts' });
|
||||
}
|
||||
|
||||
switchToTags() {
|
||||
this.setState({ currentTab: 'tags' });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { accountIds, tags, searchAccountIds, onClear, intl } = this.props;
|
||||
const showSearch = searchAccountIds.size > 0;
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal list-editor'>
|
||||
<div className='modal-root__modal list-editor'>{this.state.currentTab}
|
||||
<EditListForm />
|
||||
<div className='tab__container'>
|
||||
<button onClick={this.switchToAccounts} className={'tab ' + ('accounts' === this.state.currentTab ? 'tab__active' : '')}>{intl.formatMessage(messages.account_tab)} ({accountIds.size})</button>
|
||||
<button onClick={this.switchToTags} className={'tab ' + ('tags' === this.state.currentTab ? 'tab__active' : '')}>{intl.formatMessage(messages.tag_tab)} ({tags.size})</button>
|
||||
</div>
|
||||
<div id='list_editor_accounts' className={'accounts' === this.state.currentTab ? 'tab__active' : 'tab__inactive'}>
|
||||
<Search />
|
||||
<div className='drawer__pager'>
|
||||
<div className='drawer__inner list-editor__accounts'>
|
||||
{accountIds.map(accountId => <Account key={accountId} accountId={accountId} added />)}
|
||||
</div>
|
||||
|
||||
<Search />
|
||||
{showSearch && <div role='button' tabIndex={-1} className='drawer__backdrop' onClick={onClear} />}
|
||||
|
||||
<div className='drawer__pager'>
|
||||
<div className='drawer__inner list-editor__accounts'>
|
||||
{accountIds.map(accountId => <Account key={accountId} accountId={accountId} added />)}
|
||||
<Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
|
||||
{({ x }) => (
|
||||
<div className='drawer__inner backdrop' style={{ transform: x === 0 ? null : `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
|
||||
{searchAccountIds.map(accountId => <Account key={accountId} accountId={accountId} />)}
|
||||
</div>
|
||||
)}
|
||||
</Motion>
|
||||
</div>
|
||||
</div>
|
||||
<div id='list_editor_tags' className={'tags' === this.state.currentTab ? 'tab__active' : 'tab__inactive'}>
|
||||
<AddTag />
|
||||
<div className='drawer__pager'>
|
||||
<div className='drawer__inner list-editor__accounts'>
|
||||
{tags.map(tag => <Tag key={tag.name} tag={tag} added />)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{showSearch && <div role='button' tabIndex={-1} className='drawer__backdrop' onClick={onClear} />}
|
||||
|
||||
<Motion defaultStyle={{ x: -100 }} style={{ x: spring(showSearch ? 0 : -100, { stiffness: 210, damping: 20 }) }}>
|
||||
{({ x }) => (
|
||||
<div className='drawer__inner backdrop' style={{ transform: x === 0 ? null : `translateX(${x}%)`, visibility: x === -100 ? 'hidden' : 'visible' }}>
|
||||
{searchAccountIds.map(accountId => <Account key={accountId} accountId={accountId} />)}
|
||||
</div>
|
||||
)}
|
||||
</Motion>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { authorizeFollowRequest, rejectFollowRequest } from 'flavours/glitch/actions/accounts';
|
||||
import { makeGetAccount } from 'flavours/glitch/selectors';
|
||||
|
||||
import FollowRequest from '../components/follow_request';
|
||||
|
||||
const mapDispatchToProps = (dispatch, { account }) => ({
|
||||
const makeMapStateToProps = () => {
|
||||
const getAccount = makeGetAccount();
|
||||
|
||||
const mapStateToProps = (state, props) => ({
|
||||
account: getAccount(state, props.id),
|
||||
});
|
||||
|
||||
return mapStateToProps;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch, { id }) => ({
|
||||
onAuthorize () {
|
||||
dispatch(authorizeFollowRequest(account.get('id')));
|
||||
dispatch(authorizeFollowRequest(id));
|
||||
},
|
||||
|
||||
onReject () {
|
||||
dispatch(rejectFollowRequest(account.get('id')));
|
||||
dispatch(rejectFollowRequest(id));
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps)(FollowRequest);
|
||||
export default connect(makeMapStateToProps, mapDispatchToProps)(FollowRequest);
|
||||
|
|
|
@ -64,8 +64,6 @@
|
|||
"notification_purge.btn_invert": "Auswahl\numkehren",
|
||||
"notification_purge.btn_none": "Auswahl\naufheben",
|
||||
"notification_purge.start": "Benachrichtigungen-Aufräumen-Modus starten",
|
||||
"notifications.column_settings.filter_bar.advanced": "Zeige alle Kategorien an",
|
||||
"notifications.column_settings.filter_bar.category": "Schnellfilterleiste",
|
||||
"notifications.column_settings.filter_bar.show_bar": "Filterleiste anzeigen",
|
||||
"notifications.marked_clear": "Ausgewählte Benachrichtigungen entfernen",
|
||||
"notifications.marked_clear_confirmation": "Möchtest du wirklich alle auswählten Benachrichtigungen für immer entfernen?",
|
||||
|
|
|
@ -53,6 +53,11 @@
|
|||
"keyboard_shortcuts.bookmark": "to bookmark",
|
||||
"keyboard_shortcuts.secondary_toot": "to send toot using secondary privacy setting",
|
||||
"keyboard_shortcuts.toggle_collapse": "to collapse/uncollapse toots",
|
||||
"lists.account_tab": "Accounts",
|
||||
"lists.addtag": "Enter a tag you'd like to follow",
|
||||
"lists.tag.add": "Add to list",
|
||||
"lists.tag.remove": "Remove from list",
|
||||
"lists.tag_tab": "Tags",
|
||||
"moved_to_warning": "This account is marked as moved to {moved_to_link}, and may thus not accept new follows.",
|
||||
"navigation_bar.app_settings": "App settings",
|
||||
"navigation_bar.featured_users": "Featured users",
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
"compose.content-type.markdown_meta": "Formatear tus mensajes con Markdown",
|
||||
"compose.content-type.plain": "Texto plano",
|
||||
"compose.content-type.plain_meta": "Escribir sin formato avanzado",
|
||||
"compose.disable_threaded_mode": "Deshabilitar Modo Hilo",
|
||||
"compose.enable_threaded_mode": "Habilitar Modo Hilo",
|
||||
"compose.disable_threaded_mode": "Deshabilitar modo de hilo",
|
||||
"compose.enable_threaded_mode": "Habilitar modo de hilo",
|
||||
"compose_form.sensitive.hide": "{count, plural, one {Marca medios como sensible} other {Marca los medios como sensibles}}",
|
||||
"compose_form.sensitive.marked": "{count, plural, one {El medio está marcado como sensible} other {Los medios están marcados como sensibles}}",
|
||||
"compose_form.sensitive.unmarked": "{count, plural, one {El medio no está marcado como sensible} other {Los medios no están marcados como sensibles}}",
|
||||
|
@ -64,8 +64,6 @@
|
|||
"notification_purge.btn_invert": "Invertir\nselección",
|
||||
"notification_purge.btn_none": "Seleccionar\nnada",
|
||||
"notification_purge.start": "Entrar en modo de limpieza de notificaciones",
|
||||
"notifications.column_settings.filter_bar.advanced": "Mostrar todas las categorías",
|
||||
"notifications.column_settings.filter_bar.category": "Barra de filtrado rápido",
|
||||
"notifications.column_settings.filter_bar.show_bar": "Mostrar barra de filtros",
|
||||
"notifications.marked_clear": "Limpiar notificaciones seleccionadas",
|
||||
"notifications.marked_clear_confirmation": "¿Deseas borrar permanentemente todas las notificaciones seleccionadas?",
|
||||
|
|
|
@ -14,9 +14,17 @@
|
|||
"column_subheading.lists": "Listas",
|
||||
"column_subheading.navigation": "Navegación",
|
||||
"community.column_settings.allow_local_only": "Mostrar sólo toots locales",
|
||||
"compose.attach.doodle": "Dibujar algo",
|
||||
"compose.change_federation": "Cambiar configuración de la federación",
|
||||
"compose.content-type.change": "Cambiar opciones avanzadas de formato",
|
||||
"compose.content-type.html": "HTML",
|
||||
"compose.content-type.html_meta": "Formatear tus publicaciones con HTML",
|
||||
"compose.content-type.markdown": "Markdown",
|
||||
"compose.content-type.markdown_meta": "Formatear tus publicaciones con Markdown",
|
||||
"compose.content-type.plain": "Texto plano",
|
||||
"compose.content-type.plain_meta": "Escribir sin formato avanzado",
|
||||
"compose.disable_threaded_mode": "Deshabilitar modo de hilo",
|
||||
"compose.enable_threaded_mode": "Habilitar modo de hilo",
|
||||
"confirmation_modal.do_not_ask_again": "No preguntar por la confirmación de nuevo",
|
||||
"confirmations.deprecated_settings.confirm": "Usar las preferencias de Mastodon",
|
||||
"confirmations.deprecated_settings.message": "Algunas de las {app_settings} de glitch-soc, específicas para el dispositivo que estás usando han sido reemplazadas en las {preferences} de Mastodon y serán sobreescritas:",
|
||||
|
@ -30,6 +38,10 @@
|
|||
"direct.group_by_conversations": "Agrupar por conversación",
|
||||
"endorsed_accounts_editor.endorsed_accounts": "Cuentas destacadas",
|
||||
"favourite_modal.combo": "Puedes presionar {combo} para omitir esto la próxima vez",
|
||||
"federation.federated.long": "Permitir que esta publicación llegue a otros servidores",
|
||||
"federation.federated.short": "Federado",
|
||||
"federation.local_only.long": "Evitar que esta publicación llegue a otros servidores",
|
||||
"federation.local_only.short": "Solo local",
|
||||
"firehose.column_settings.allow_local_only": "Mostrar mensajes solo-locales en \"Todo\"",
|
||||
"home.column_settings.advanced": "Avanzado",
|
||||
"home.column_settings.filter_regex": "Filtrar por expresiones regulares",
|
||||
|
@ -112,6 +124,7 @@
|
|||
"settings.shared_settings_link": "preferencias de usuario",
|
||||
"settings.show_action_bar": "Mostrar botones de acción en toots colapsados",
|
||||
"settings.show_content_type_choice": "Mostrar selección de tipo de contenido al crear toots",
|
||||
"settings.show_published_toast": "Mostrar mensaje al publicar/guardar una publicación",
|
||||
"settings.show_reply_counter": "Mostrar un conteo estimado de respuestas",
|
||||
"settings.side_arm": "Botón secundario:",
|
||||
"settings.side_arm.none": "Ninguno",
|
||||
|
|
|
@ -14,9 +14,17 @@
|
|||
"column_subheading.lists": "Listas",
|
||||
"column_subheading.navigation": "Navegación",
|
||||
"community.column_settings.allow_local_only": "Mostrar toots solo-locales",
|
||||
"compose.attach.doodle": "Dibujar algo",
|
||||
"compose.change_federation": "Cambiar configuración de la federación",
|
||||
"compose.content-type.change": "Cambiar opciones avanzadas de formato",
|
||||
"compose.content-type.html": "HTML",
|
||||
"compose.content-type.html_meta": "Formatear tus publicaciones con HTML",
|
||||
"compose.content-type.markdown": "Markdown",
|
||||
"compose.content-type.markdown_meta": "Formatear tus publicaciones con Markdown",
|
||||
"compose.content-type.plain": "Texto plano",
|
||||
"compose.content-type.plain_meta": "Escribir sin formato avanzado",
|
||||
"compose.disable_threaded_mode": "Deshabilitar modo de hilo",
|
||||
"compose.enable_threaded_mode": "Habilitar modo de hilo",
|
||||
"confirmation_modal.do_not_ask_again": "No preguntar por la confirmación de nuevo",
|
||||
"confirmations.deprecated_settings.confirm": "Usar las preferencias de Mastodon",
|
||||
"confirmations.deprecated_settings.message": "Algunas de las {app_settings} de glitch-soc, específicas para el dispositivo que estás usando han sido reemplazadas en las {preferences} de Mastodon y serán sobreescritas:",
|
||||
|
@ -30,6 +38,10 @@
|
|||
"direct.group_by_conversations": "Agrupar por conversación",
|
||||
"endorsed_accounts_editor.endorsed_accounts": "Cuentas destacadas",
|
||||
"favourite_modal.combo": "Puedes presionar {combo} para omitir esto la próxima vez",
|
||||
"federation.federated.long": "Permitir que esta publicación llegue a otros servidores",
|
||||
"federation.federated.short": "Federado",
|
||||
"federation.local_only.long": "Evitar que esta publicación llegue a otros servidores",
|
||||
"federation.local_only.short": "Solo local",
|
||||
"firehose.column_settings.allow_local_only": "Mostrar mensajes solo-locales en \"Todo\"",
|
||||
"home.column_settings.advanced": "Avanzado",
|
||||
"home.column_settings.filter_regex": "Filtrar por expresiones regulares",
|
||||
|
@ -112,6 +124,7 @@
|
|||
"settings.shared_settings_link": "preferencias de usuario",
|
||||
"settings.show_action_bar": "Mostrar botones de acción en publicaciones colapsadas",
|
||||
"settings.show_content_type_choice": "Mostrar selección de tipo de contenido al crear publicaciones",
|
||||
"settings.show_published_toast": "Mostrar mensaje al publicar/guardar una publicación",
|
||||
"settings.show_reply_counter": "Mostrar un conteo estimado de respuestas",
|
||||
"settings.side_arm": "Botón secundario:",
|
||||
"settings.side_arm.none": "Ninguno",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"about.fork_disclaimer": "Glitch-socはMastodonからフォークされたフリーなオープンソースソフトウェアです。",
|
||||
"account.disclaimer_full": "このユーザー情報は不正確な可能性があります。",
|
||||
"account.follows": "フォロー",
|
||||
"account.follows_you": "フォローされています",
|
||||
"account.suspended_disclaimer_full": "このユーザーはモデレータにより停止されました。",
|
||||
"account.view_full_profile": "正確な情報を見る",
|
||||
"boost_modal.missing_description": "このトゥートには少なくとも1つの画像に説明が付与されていません",
|
||||
|
@ -14,8 +15,12 @@
|
|||
"column_subheading.navigation": "ナビゲーション",
|
||||
"community.column_settings.allow_local_only": "ローカル限定投稿を表示する",
|
||||
"compose.content-type.html": "HTML",
|
||||
"compose.content-type.html_meta": "投稿に HTML を使用する",
|
||||
"compose.content-type.markdown": "マークダウン",
|
||||
"compose.content-type.markdown_meta": "投稿に Markdown を使用する",
|
||||
"compose.content-type.plain": "プレーンテキスト",
|
||||
"compose.disable_threaded_mode": "スレッドモードを無効にする",
|
||||
"compose.enable_threaded_mode": "スレッドモードを有効にする",
|
||||
"confirmation_modal.do_not_ask_again": "もう1度尋ねない",
|
||||
"confirmations.deprecated_settings.confirm": "Mastodonの設定を使用",
|
||||
"confirmations.missing_media_description.confirm": "このまま投稿",
|
||||
|
@ -28,6 +33,8 @@
|
|||
"direct.group_by_conversations": "会話でグループ化",
|
||||
"endorsed_accounts_editor.endorsed_accounts": "紹介しているユーザー",
|
||||
"favourite_modal.combo": "次からは {combo} を押せば、これをスキップできます。",
|
||||
"federation.federated.short": "連合",
|
||||
"federation.local_only.short": "ローカル限定",
|
||||
"home.column_settings.advanced": "高度",
|
||||
"home.column_settings.filter_regex": "正規表現でフィルター",
|
||||
"home.column_settings.show_direct": "DMを表示",
|
||||
|
@ -97,6 +104,7 @@
|
|||
"settings.rewrite_mentions_acct": "ユーザー名とドメイン名(アカウントがリモートの場合)を表示するように書き換える",
|
||||
"settings.rewrite_mentions_no": "書き換えない",
|
||||
"settings.rewrite_mentions_username": "ユーザー名を表示するように書き換える",
|
||||
"settings.shared_settings_link": "ユーザー設定",
|
||||
"settings.show_action_bar": "アクションバーを表示",
|
||||
"settings.show_content_type_choice": "トゥートを書くときコンテンツ形式の選択ボタンを表示する",
|
||||
"settings.show_reply_counter": "投稿に対するリプライの数を表示する",
|
||||
|
|
|
@ -64,8 +64,6 @@
|
|||
"notification_purge.btn_invert": "反选",
|
||||
"notification_purge.btn_none": "取消全选",
|
||||
"notification_purge.start": "进入通知清理模式",
|
||||
"notifications.column_settings.filter_bar.advanced": "显示所有类别",
|
||||
"notifications.column_settings.filter_bar.category": "快速筛选栏",
|
||||
"notifications.column_settings.filter_bar.show_bar": "显示筛选栏",
|
||||
"notifications.marked_clear": "清除选择的通知",
|
||||
"notifications.marked_clear_confirmation": "你确定要永久清除所有选择的通知吗?",
|
||||
|
|
|
@ -60,8 +60,6 @@
|
|||
"notification_purge.btn_invert": "反向選擇",
|
||||
"notification_purge.btn_none": "取消選取",
|
||||
"notification_purge.start": "進入通知清理模式",
|
||||
"notifications.column_settings.filter_bar.advanced": "顯示所有分類",
|
||||
"notifications.column_settings.filter_bar.category": "快速過濾欄",
|
||||
"notifications.column_settings.filter_bar.show_bar": "顯示過濾器",
|
||||
"notifications.marked_clear": "清除被選取的通知訊息",
|
||||
"notifications.marked_clear_confirmation": "您確定要永久清除所有被選取的通知訊息嗎?",
|
||||
|
|
|
@ -13,6 +13,9 @@ import {
|
|||
LIST_ACCOUNTS_FETCH_REQUEST,
|
||||
LIST_ACCOUNTS_FETCH_SUCCESS,
|
||||
LIST_ACCOUNTS_FETCH_FAIL,
|
||||
LIST_TAGS_FETCH_REQUEST,
|
||||
LIST_TAGS_FETCH_SUCCESS,
|
||||
LIST_TAGS_FETCH_FAIL,
|
||||
LIST_EDITOR_SUGGESTIONS_READY,
|
||||
LIST_EDITOR_SUGGESTIONS_CLEAR,
|
||||
LIST_EDITOR_SUGGESTIONS_CHANGE,
|
||||
|
@ -33,6 +36,12 @@ const initialState = ImmutableMap({
|
|||
isLoading: false,
|
||||
}),
|
||||
|
||||
tags: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
suggestions: ImmutableMap({
|
||||
value: '',
|
||||
items: ImmutableList(),
|
||||
|
@ -80,6 +89,16 @@ export default function listEditorReducer(state = initialState, action) {
|
|||
map.set('loaded', true);
|
||||
map.set('items', ImmutableList(action.accounts.map(item => item.id)));
|
||||
}));
|
||||
case LIST_TAGS_FETCH_REQUEST:
|
||||
return state.setIn(['tags', 'isLoading'], true);
|
||||
case LIST_TAGS_FETCH_FAIL:
|
||||
return state.setIn(['tags', 'isLoading'], false);
|
||||
case LIST_TAGS_FETCH_SUCCESS:
|
||||
return state.update('tags', tags => tags.withMutations(map => {
|
||||
map.set('isLoading', false);
|
||||
map.set('loaded', true);
|
||||
map.set('items', ImmutableList(action.tags));
|
||||
}));
|
||||
case LIST_EDITOR_SUGGESTIONS_CHANGE:
|
||||
return state.setIn(['suggestions', 'value'], action.value);
|
||||
case LIST_EDITOR_SUGGESTIONS_READY:
|
||||
|
@ -90,9 +109,12 @@ export default function listEditorReducer(state = initialState, action) {
|
|||
map.set('value', '');
|
||||
}));
|
||||
case LIST_EDITOR_ADD_SUCCESS:
|
||||
return state.updateIn(['accounts', 'items'], list => list.unshift(action.accountId));
|
||||
if (action.data && action.data.data !== undefined) {
|
||||
return state.setIn([action.addType, 'items'], ImmutableList(action.data.data));
|
||||
}
|
||||
return state.updateIn([action.addType, 'items'], list => list.unshift(action.id));
|
||||
case LIST_EDITOR_REMOVE_SUCCESS:
|
||||
return state.updateIn(['accounts', 'items'], list => list.filterNot(item => item === action.accountId));
|
||||
return state.updateIn([action.removeType, 'items'], list => list.filterNot(item => item === action.id || item.id === action.id));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -116,3 +116,7 @@ export const getAccountHidden = createSelector([
|
|||
export const getStatusList = createSelector([
|
||||
(state, type) => state.getIn(['status_lists', type, 'items']),
|
||||
], (items) => items.toList());
|
||||
|
||||
export const getListEditorTagList = createSelector([
|
||||
(state) => state.getIn(['listEditor', 'tags', 'items']),
|
||||
], (items) => items.toList());
|
||||
|
|
|
@ -2152,7 +2152,8 @@ body > [data-popper-placement] {
|
|||
}
|
||||
}
|
||||
|
||||
.account__wrapper {
|
||||
.account__wrapper,
|
||||
.tag__wrapper {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
|
@ -2224,7 +2225,8 @@ a .account__avatar {
|
|||
}
|
||||
}
|
||||
|
||||
.account__relationship {
|
||||
.account__relationship,
|
||||
.tag__relationship {
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
@ -8158,11 +8160,53 @@ noscript {
|
|||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
|
||||
.tab__container {
|
||||
display: flex;
|
||||
|
||||
.tab {
|
||||
flex-grow: 1;
|
||||
flex-basis: 0;
|
||||
display: block;
|
||||
padding: 5px;
|
||||
background: $ui-base-color;
|
||||
text-align: center;
|
||||
border: 0;
|
||||
color: $primary-text-color;
|
||||
}
|
||||
|
||||
.tab.tab__active {
|
||||
font-weight: bold;
|
||||
background: lighten($ui-base-color, 13%);
|
||||
}
|
||||
}
|
||||
|
||||
.tab__inactive {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.drawer__pager {
|
||||
height: 50vh;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.list_tag {
|
||||
padding: 10px; // glitch: reduced padding
|
||||
border-bottom: 1px solid lighten($ui-base-color, 8%);
|
||||
gap: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
min-height: 36px;
|
||||
|
||||
.list_tag__display-name {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.list_tag__relationship {
|
||||
flex-grow: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.drawer__inner {
|
||||
border-radius: 0 0 8px 8px;
|
||||
|
||||
|
|
|
@ -443,13 +443,11 @@ class FeedManager
|
|||
should_filter = !crutches[:following][status.in_reply_to_account_id] # and I'm not following the person it's a reply to
|
||||
should_filter &&= receiver_id != status.in_reply_to_account_id # and it's not a reply to me
|
||||
should_filter &&= status.account_id != status.in_reply_to_account_id # and it's not a self-reply
|
||||
|
||||
return !!should_filter
|
||||
elsif status.reblog? # Filter out a reblog
|
||||
should_filter = crutches[:hiding_reblogs][status.account_id] # if the reblogger's reblogs are suppressed
|
||||
should_filter ||= crutches[:blocked_by][status.reblog.account_id] # or if the author of the reblogged status is blocking me
|
||||
should_filter ||= crutches[:domain_blocking][status.reblog.account.domain] # or the author's domain is blocked
|
||||
|
||||
return !!should_filter
|
||||
end
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ class List < ApplicationRecord
|
|||
has_many :list_accounts, inverse_of: :list, dependent: :destroy
|
||||
has_many :accounts, through: :list_accounts
|
||||
|
||||
has_many :list_tags, inverse_of: :list, dependent: :destroy
|
||||
has_many :tags, through: :list_tags
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
validates_each :account_id, on: :create do |record, _attr, value|
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: list_tag
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# list_id :bigint(8) not null
|
||||
# tag_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class ListTag < ApplicationRecord
|
||||
belongs_to :list
|
||||
belongs_to :tag
|
||||
|
||||
validates :tag_id, uniqueness: { scope: :list_id }
|
||||
end
|
|
@ -28,6 +28,9 @@ class Tag < ApplicationRecord
|
|||
has_many :featured_tags, dependent: :destroy, inverse_of: :tag
|
||||
has_many :followers, through: :passive_relationships, source: :account
|
||||
|
||||
has_many :list_tags, inverse_of: :tag, dependent: :destroy
|
||||
has_many :lists, through: :list_tags
|
||||
|
||||
HASHTAG_SEPARATORS = "_\u00B7\u30FB\u200c"
|
||||
HASHTAG_FIRST_SEQUENCE_CHUNK_ONE = "[[:word:]_][[:word:]#{HASHTAG_SEPARATORS}]*[[:alpha:]#{HASHTAG_SEPARATORS}]"
|
||||
HASHTAG_FIRST_SEQUENCE_CHUNK_TWO = "[[:word:]#{HASHTAG_SEPARATORS}]*[[:word:]_]"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class REST::TagSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :name, :url, :history
|
||||
attributes :name, :url, :history, :id
|
||||
|
||||
attribute :following, if: :current_user?
|
||||
|
||||
|
@ -15,6 +15,10 @@ class REST::TagSerializer < ActiveModel::Serializer
|
|||
object.display_name
|
||||
end
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def following
|
||||
if instance_options && instance_options[:relationships]
|
||||
instance_options[:relationships].following_map[object.id] || false
|
||||
|
|
|
@ -113,6 +113,11 @@ class FanOutOnWriteService < BaseService
|
|||
end
|
||||
|
||||
def deliver_to_lists!
|
||||
@status.tags.each do |tag|
|
||||
FeedInsertWorker.push_bulk(tag.lists) do |list|
|
||||
[@status.id, list.id, 'list', { 'update' => update? }]
|
||||
end
|
||||
end
|
||||
@account.lists_for_local_distribution.select(:id).reorder(nil).find_in_batches do |lists|
|
||||
FeedInsertWorker.push_bulk(lists) do |list|
|
||||
[@status.id, list.id, 'list', { 'update' => update? }]
|
||||
|
|
|
@ -220,6 +220,7 @@ namespace :api, format: false do
|
|||
|
||||
resources :lists, only: [:index, :create, :show, :update, :destroy] do
|
||||
resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
|
||||
resource :tags, only: [:show, :create, :destroy], controller: 'lists/tags'
|
||||
end
|
||||
|
||||
namespace :featured_tags do
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ListTags < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :list_tags do |t|
|
||||
t.belongs_to :list, foreign_key: { on_delete: :cascade }, null: false
|
||||
t.belongs_to :tag, foreign_key: { on_delete: :cascade }, null: false
|
||||
end
|
||||
|
||||
add_index :list_tags, [:tag_id, :list_id], unique: true
|
||||
add_index :list_tags, [:list_id, :tag_id]
|
||||
end
|
||||
end
|
11
db/schema.rb
11
db/schema.rb
|
@ -596,6 +596,15 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_22_161611) do
|
|||
t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
|
||||
end
|
||||
|
||||
create_table "list_tags", force: :cascade do |t|
|
||||
t.bigint "list_id", null: false
|
||||
t.bigint "tag_id", null: false
|
||||
t.index ["list_id", "tag_id"], name: "index_list_tags_on_list_id_and_tag_id"
|
||||
t.index ["list_id"], name: "index_list_tags_on_list_id"
|
||||
t.index ["tag_id", "list_id"], name: "index_list_tags_on_tag_id_and_list_id", unique: true
|
||||
t.index ["tag_id"], name: "index_list_tags_on_tag_id"
|
||||
end
|
||||
|
||||
create_table "lists", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.string "title", default: "", null: false
|
||||
|
@ -1321,6 +1330,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_22_161611) do
|
|||
add_foreign_key "list_accounts", "follow_requests", on_delete: :cascade
|
||||
add_foreign_key "list_accounts", "follows", on_delete: :cascade
|
||||
add_foreign_key "list_accounts", "lists", on_delete: :cascade
|
||||
add_foreign_key "list_tags", "lists", on_delete: :cascade
|
||||
add_foreign_key "list_tags", "tags", on_delete: :cascade
|
||||
add_foreign_key "lists", "accounts", on_delete: :cascade
|
||||
add_foreign_key "login_activities", "users", on_delete: :cascade
|
||||
add_foreign_key "markers", "users", on_delete: :cascade
|
||||
|
|
Loading…
Reference in New Issue