Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Make it possible to hide boosts in list view #487

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/javascript/mastodon/actions/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_reblogs_policy) => (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_reblogs_policy }).then(({ data }) => {
dispatch(updateListSuccess(data));

if (shouldReset) {
Expand Down
10 changes: 9 additions & 1 deletion app/javascript/mastodon/features/list_timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import MissingIndicator from '../../components/missing_indicator';
import LoadingIndicator from '../../components/loading_indicator';
import Icon from 'mastodon/components/icon';
import RadioButton from 'mastodon/components/radio_button';
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?' },
Expand Down Expand Up @@ -141,11 +142,12 @@ class ListTimeline extends React.PureComponent {
}

render () {
const { hasUnread, columnId, multiColumn, list, intl } = this.props;
const { hasUnread, columnId, multiColumn, list, intl, onChange } = this.props;
const { id } = this.props.params;
const pinned = !!columnId;
const title = list ? list.get('title') : id;
const replies_policy = list ? list.get('replies_policy') : undefined;
const show_reblogs_policy = list ? list.get('show_reblogs') : undefined;

if (typeof list === 'undefined') {
return (
Expand Down Expand Up @@ -186,6 +188,12 @@ class ListTimeline extends React.PureComponent {
</button>
</div>

<span className='column-settings__section'><FormattedMessage id='home.column_settings.show_reblogs' defaultMessage='Show boosts' /></span>

<div className='column-settings__row'>
<Toggle id={id} onChange={this.onChange} />
</div>

{ replies_policy !== undefined && (
<div role='group' aria-labelledby={`list-${id}-replies-policy`}>
<span id={`list-${id}-replies-policy`} className='column-settings__section'>
Expand Down
1 change: 1 addition & 0 deletions app/models/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# replies_policy :integer default("list"), not null
# show_reblogs :boolean default(TRUE)
#

class List < ApplicationRecord
Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20230103141619_add_show_reblogs_to_lists.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddShowReblogsToLists < ActiveRecord::Migration[6.1]
def up
add_column :lists, :show_reblogs, :boolean
change_column_default :lists, :show_reblogs, true
end

def down
remove_column :lists, :show_reblogs
end
end
10 changes: 10 additions & 0 deletions db/migrate/20230103143222_backfill_add_show_reblogs_to_lists.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class BackfillAddShowReblogsToLists < ActiveRecord::Migration[6.1]
disable_ddl_transaction!

def up
List.unscoped.in_batches do |relation|
relation.update_all show_reblogs: true
sleep(0.01)
end
end
end
17 changes: 9 additions & 8 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_01_16_082923) do
ActiveRecord::Schema.define(version: 2023_01_03_143222) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -191,8 +191,8 @@
t.integer "avatar_storage_schema_version"
t.integer "header_storage_schema_version"
t.string "devices_url"
t.datetime "sensitized_at"
t.integer "suspension_origin"
t.datetime "sensitized_at"
t.integer "sponsor", default: 0
t.float "donation_amount", default: 0.0
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
Expand Down Expand Up @@ -468,7 +468,7 @@
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_follows_on_target_account_id"
end

create_table "identities", force: :cascade do |t|
t.string "provider", default: "", null: false
t.string "uid", default: "", null: false
Expand Down Expand Up @@ -506,12 +506,12 @@
end

create_table "ip_blocks", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.inet "ip", default: "0.0.0.0", null: false
t.integer "severity", default: 0, null: false
t.datetime "expires_at"
t.text "comment", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "list_accounts", force: :cascade do |t|
Expand All @@ -529,6 +529,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "replies_policy", default: 0, null: false
t.boolean "show_reblogs", default: true
t.index ["account_id"], name: "index_lists_on_account_id"
end

Expand Down Expand Up @@ -860,8 +861,8 @@
create_table "status_pins", force: :cascade do |t|
t.bigint "account_id", null: false
t.bigint "status_id", null: false
t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.datetime "created_at", default: -> { "now()" }, null: false
t.datetime "updated_at", default: -> { "now()" }, null: false
t.index ["account_id", "status_id"], name: "index_status_pins_on_account_id_and_status_id", unique: true
end

Expand Down