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