Allow own roars to be included in lists.
parent
89e54748d7
commit
1e2977256c
|
@ -38,6 +38,6 @@ class Api::V1::ListsController < Api::BaseController
|
|||
end
|
||||
|
||||
def list_params
|
||||
params.permit(:title, :replies_policy)
|
||||
params.permit(:title, :replies_policy, :show_self)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -150,10 +150,10 @@ export const createListFail = error => ({
|
|||
error,
|
||||
});
|
||||
|
||||
export const updateList = (id, title, shouldReset, replies_policy) => (dispatch, getState) => {
|
||||
export const updateList = (id, title, shouldReset, replies_policy, show_self) => (dispatch, getState) => {
|
||||
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, show_self }).then(({ data }) => {
|
||||
dispatch(updateListSuccess(data));
|
||||
|
||||
if (shouldReset) {
|
||||
|
|
|
@ -13,10 +13,12 @@ import { fetchList, deleteList, updateList } from 'flavours/glitch/actions/lists
|
|||
import { openModal } from 'flavours/glitch/actions/modal';
|
||||
import MissingIndicator from 'flavours/glitch/components/missing_indicator';
|
||||
import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
|
||||
import Toggle from 'react-toggle';
|
||||
|
||||
const messages = defineMessages({
|
||||
deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' },
|
||||
deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' },
|
||||
show_self: { id: 'lists.show_self', defaultMessage: 'Include your own toots' },
|
||||
all_replies: { id: 'lists.replies_policy.all_replies', defaultMessage: 'any followed user' },
|
||||
no_replies: { id: 'lists.replies_policy.no_replies', defaultMessage: 'no one' },
|
||||
list_replies: { id: 'lists.replies_policy.list_replies', defaultMessage: 'members of the list' },
|
||||
|
@ -114,6 +116,14 @@ export default class ListTimeline extends React.PureComponent {
|
|||
}));
|
||||
}
|
||||
|
||||
handleShowSelfChange = ({ target }) => {
|
||||
const { dispatch, list } = this.props;
|
||||
const { id } = this.props.params;
|
||||
const replies_policy = list ? list.get('replies_policy') : undefined;
|
||||
const show_self = list ? list.get('show_self') : false;
|
||||
this.props.dispatch(updateList(id, undefined, false, replies_policy, !show_self));
|
||||
}
|
||||
|
||||
handleRepliesPolicyChange = ({ target }) => {
|
||||
const { dispatch, list } = this.props;
|
||||
const { id } = this.props.params;
|
||||
|
@ -126,6 +136,7 @@ export default class ListTimeline extends React.PureComponent {
|
|||
const pinned = !!columnId;
|
||||
const title = list ? list.get('title') : id;
|
||||
const replies_policy = list ? list.get('replies_policy') : undefined;
|
||||
const show_self = list ? list.get('show_self') : false;
|
||||
|
||||
if (typeof list === 'undefined') {
|
||||
return (
|
||||
|
@ -167,6 +178,15 @@ export default class ListTimeline extends React.PureComponent {
|
|||
</button>
|
||||
</div>
|
||||
|
||||
<div className='column-settings__row'>
|
||||
<div className='setting-toggle'>
|
||||
<Toggle id={['setting', 'toggle', id, 'show_self'].join('-')} checked={show_self === true} onChange={this.handleShowSelfChange} />
|
||||
<label htmlFor={['setting', 'toggle', id, 'show_self'].join('-')} className='setting-toggle__label'>
|
||||
<FormattedMessage id='lists.show_self' defaultMessage='Include your own toots' />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{ replies_policy !== undefined && (
|
||||
<div>
|
||||
<div className='column-settings__row'>
|
||||
|
|
|
@ -226,6 +226,7 @@
|
|||
"lists.new.title_placeholder": "New list title",
|
||||
"lists.search": "Search among monsters in your pack",
|
||||
"lists.subheading": "Your lists",
|
||||
"lists.show_self": "Include your own roars",
|
||||
"loading_indicator.label": "Loading...",
|
||||
"media_gallery.toggle_visible": "Toggle visibility",
|
||||
"missing_indicator.label": "Not found",
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# replies_policy :integer default("list_replies"), not null
|
||||
# show_self :boolean default(FALSE), not null
|
||||
#
|
||||
|
||||
class List < ApplicationRecord
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::ListSerializer < ActiveModel::Serializer
|
||||
attributes :id, :title, :replies_policy
|
||||
attributes :id, :title, :replies_policy, :show_self
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
|
|
|
@ -64,6 +64,12 @@ class FanOutOnWriteService < BaseService
|
|||
def deliver_to_lists(status)
|
||||
Rails.logger.debug "Delivering status #{status.id} to lists"
|
||||
|
||||
List.where(account_id: status.account.id, show_self: true).select(:id).reorder(nil).find_in_batches do |lists|
|
||||
FeedInsertWorker.push_bulk(lists) do |list|
|
||||
[status.id, list.id, :list]
|
||||
end
|
||||
end
|
||||
|
||||
status.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]
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddShowSelfToLists < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
safety_assured { add_column :lists, :show_self, :boolean, default: false, null: false }
|
||||
end
|
||||
end
|
|
@ -361,6 +361,7 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "replies_policy", default: 0, null: false
|
||||
t.boolean "show_self", default: false, null: false
|
||||
t.index ["account_id"], name: "index_lists_on_account_id"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue