Merge branch 'kb_development' into kb_migration
This commit is contained in:
commit
6028c82891
86 changed files with 3035 additions and 156 deletions
|
@ -18,6 +18,7 @@ class Api::V1::Accounts::SearchController < Api::BaseController
|
|||
limit: limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||
resolve: truthy_param?(:resolve),
|
||||
following: truthy_param?(:following),
|
||||
follower: truthy_param?(:follower),
|
||||
offset: params[:offset]
|
||||
)
|
||||
end
|
||||
|
|
104
app/controllers/api/v1/antennas/exclude_accounts_controller.rb
Normal file
104
app/controllers/api/v1/antennas/exclude_accounts_controller.rb
Normal file
|
@ -0,0 +1,104 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Antennas::ExcludeAccountsController < 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_antenna
|
||||
|
||||
after_action :insert_pagination_headers, only: :show
|
||||
|
||||
def show
|
||||
@accounts = load_accounts
|
||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
new_accounts = @antenna.exclude_accounts || []
|
||||
antenna_accounts.each do |account|
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.duplicate_account') if new_accounts.include?(account.id)
|
||||
|
||||
new_accounts << account.id
|
||||
end
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.limit.accounts') if new_accounts.size > Antenna::ACCOUNTS_PER_ANTENNA_LIMIT
|
||||
|
||||
@antenna.update!(exclude_accounts: new_accounts)
|
||||
|
||||
render_empty
|
||||
end
|
||||
|
||||
def destroy
|
||||
new_accounts = @antenna.exclude_accounts || []
|
||||
new_accounts -= antenna_accounts.pluck(:id)
|
||||
|
||||
@antenna.update!(exclude_accounts: new_accounts)
|
||||
|
||||
render_empty
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_antenna
|
||||
@antenna = Antenna.where(account: current_account).find(params[:antenna_id])
|
||||
end
|
||||
|
||||
def load_accounts
|
||||
return [] if @antenna.exclude_accounts.nil?
|
||||
|
||||
if unlimited?
|
||||
Account.where(id: @antenna.exclude_accounts).without_suspended.includes(:account_stat).all
|
||||
else
|
||||
Account.where(id: @antenna.exclude_accounts).without_suspended.includes(:account_stat).paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])
|
||||
end
|
||||
end
|
||||
|
||||
def antenna_accounts
|
||||
Account.find(account_ids)
|
||||
end
|
||||
|
||||
def account_ids
|
||||
Array(resource_params[:account_ids])
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(account_ids: [])
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
end
|
||||
|
||||
def next_path
|
||||
return if unlimited?
|
||||
|
||||
api_v1_list_accounts_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
return if unlimited?
|
||||
|
||||
api_v1_list_accounts_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
@accounts.last.id
|
||||
end
|
||||
|
||||
def pagination_since_id
|
||||
@accounts.first.id
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
@accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
params.slice(:limit).permit(:limit).merge(core_params)
|
||||
end
|
||||
|
||||
def unlimited?
|
||||
params[:limit] == '0'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Antennas::ExcludeDomainsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:lists' }
|
||||
|
||||
before_action :require_user!
|
||||
before_action :set_antenna
|
||||
|
||||
def create
|
||||
new_domains = @antenna.exclude_domains || []
|
||||
domains.each do |domain|
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.duplicate_domain') if new_domains.include?(domain)
|
||||
|
||||
new_domains << domain
|
||||
end
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.limit.domains') if new_domains.size > Antenna::KEYWORDS_PER_ANTENNA_LIMIT
|
||||
|
||||
@antenna.update!(exclude_domains: new_domains)
|
||||
|
||||
render_empty
|
||||
end
|
||||
|
||||
def destroy
|
||||
new_domains = @antenna.exclude_domains || []
|
||||
new_domains -= domains
|
||||
|
||||
@antenna.update!(exclude_domains: new_domains)
|
||||
|
||||
render_empty
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_antenna
|
||||
@antenna = Antenna.where(account: current_account).find(params[:antenna_id])
|
||||
end
|
||||
|
||||
def domains
|
||||
Array(resource_params[:domains])
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(domains: [])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Antennas::ExcludeKeywordsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:lists' }
|
||||
|
||||
before_action :require_user!
|
||||
before_action :set_antenna
|
||||
|
||||
def create
|
||||
new_keywords = @antenna.exclude_keywords || []
|
||||
keywords.each do |keyword|
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.duplicate_keyword') if new_keywords.include?(keyword)
|
||||
|
||||
new_keywords << keyword
|
||||
end
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.limit.keywords') if new_keywords.size > Antenna::KEYWORDS_PER_ANTENNA_LIMIT
|
||||
|
||||
@antenna.update!(exclude_keywords: new_keywords)
|
||||
|
||||
render_empty
|
||||
end
|
||||
|
||||
def destroy
|
||||
new_keywords = @antenna.exclude_keywords || []
|
||||
new_keywords -= keywords
|
||||
|
||||
@antenna.update!(exclude_keywords: new_keywords)
|
||||
|
||||
render_empty
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_antenna
|
||||
@antenna = Antenna.where(account: current_account).find(params[:antenna_id])
|
||||
end
|
||||
|
||||
def keywords
|
||||
Array(resource_params[:keywords])
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(keywords: [])
|
||||
end
|
||||
end
|
|
@ -21,6 +21,8 @@ class Api::V1::Antennas::KeywordsController < Api::BaseController
|
|||
new_keywords << keyword
|
||||
end
|
||||
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.limit.keywords') if new_keywords.size > Antenna::KEYWORDS_PER_ANTENNA_LIMIT
|
||||
|
||||
@antenna.update!(keywords: new_keywords, any_keywords: new_keywords.empty?)
|
||||
|
||||
render_empty
|
||||
|
|
93
app/controllers/api/v1/circles/accounts_controller.rb
Normal file
93
app/controllers/api/v1/circles/accounts_controller.rb
Normal file
|
@ -0,0 +1,93 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Circles::AccountsController < 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_circle
|
||||
|
||||
after_action :insert_pagination_headers, only: :show
|
||||
|
||||
def show
|
||||
@accounts = load_accounts
|
||||
render json: @accounts, each_serializer: REST::AccountSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
ApplicationRecord.transaction do
|
||||
circle_accounts.each do |account|
|
||||
@circle.accounts << account
|
||||
end
|
||||
end
|
||||
|
||||
render_empty
|
||||
end
|
||||
|
||||
def destroy
|
||||
CircleAccount.where(circle: @circle, account_id: account_ids).destroy_all
|
||||
render_empty
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_circle
|
||||
@circle = Circle.where(account: current_account).find(params[:circle_id])
|
||||
end
|
||||
|
||||
def load_accounts
|
||||
if unlimited?
|
||||
@circle.accounts.without_suspended.includes(:account_stat).all
|
||||
else
|
||||
@circle.accounts.without_suspended.includes(:account_stat).paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])
|
||||
end
|
||||
end
|
||||
|
||||
def circle_accounts
|
||||
Account.find(account_ids)
|
||||
end
|
||||
|
||||
def account_ids
|
||||
Array(resource_params[:account_ids])
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(account_ids: [])
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
end
|
||||
|
||||
def next_path
|
||||
return if unlimited?
|
||||
|
||||
api_v1_circle_accounts_url pagination_params(max_id: pagination_max_id) if records_continue?
|
||||
end
|
||||
|
||||
def prev_path
|
||||
return if unlimited?
|
||||
|
||||
api_v1_circle_accounts_url pagination_params(since_id: pagination_since_id) unless @accounts.empty?
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
@accounts.last.id
|
||||
end
|
||||
|
||||
def pagination_since_id
|
||||
@accounts.first.id
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
@accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
params.slice(:limit).permit(:limit).merge(core_params)
|
||||
end
|
||||
|
||||
def unlimited?
|
||||
params[:limit] == '0'
|
||||
end
|
||||
end
|
47
app/controllers/api/v1/circles_controller.rb
Normal file
47
app/controllers/api/v1/circles_controller.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::CirclesController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :read, :'read:lists' }, only: [:index, :show]
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:lists' }, except: [:index, :show]
|
||||
|
||||
before_action :require_user!
|
||||
before_action :set_circle, except: [:index, :create]
|
||||
|
||||
rescue_from ArgumentError do |e|
|
||||
render json: { error: e.to_s }, status: 422
|
||||
end
|
||||
|
||||
def index
|
||||
@circles = Circle.where(account: current_account).all
|
||||
render json: @circles, each_serializer: REST::CircleSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render json: @circle, serializer: REST::CircleSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
@circle = Circle.create!(circle_params.merge(account: current_account))
|
||||
render json: @circle, serializer: REST::CircleSerializer
|
||||
end
|
||||
|
||||
def update
|
||||
@circle.update!(circle_params)
|
||||
render json: @circle, serializer: REST::CircleSerializer
|
||||
end
|
||||
|
||||
def destroy
|
||||
@circle.destroy!
|
||||
render_empty
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_circle
|
||||
@circle = Circle.where(account: current_account).find(params[:id])
|
||||
end
|
||||
|
||||
def circle_params
|
||||
params.permit(:title)
|
||||
end
|
||||
end
|
|
@ -31,7 +31,8 @@ class Api::V1::ListsController < Api::BaseController
|
|||
end
|
||||
|
||||
def destroy
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.remove_list_with_antenna') if Antenna.where(list_id: @list.id).any?
|
||||
antenna = Antenna.find_by(list_id: @list.id)
|
||||
antenna.update!(list_id: 0) if antenna.present?
|
||||
|
||||
@list.destroy!
|
||||
render_empty
|
||||
|
|
|
@ -67,6 +67,7 @@ class Api::V1::StatusesController < Api::BaseController
|
|||
visibility: status_params[:visibility],
|
||||
force_visibility: status_params[:force_visibility],
|
||||
searchability: status_params[:searchability],
|
||||
circle_id: status_params[:circle_id],
|
||||
language: status_params[:language],
|
||||
scheduled_at: status_params[:scheduled_at],
|
||||
application: doorkeeper_token.application,
|
||||
|
@ -144,6 +145,7 @@ class Api::V1::StatusesController < Api::BaseController
|
|||
:visibility,
|
||||
:force_visibility,
|
||||
:searchability,
|
||||
:circle_id,
|
||||
:language,
|
||||
:markdown,
|
||||
:scheduled_at,
|
||||
|
|
|
@ -43,6 +43,18 @@ export const ANTENNA_EDITOR_REMOVE_REQUEST = 'ANTENNA_EDITOR_REMOVE_REQUEST';
|
|||
export const ANTENNA_EDITOR_REMOVE_SUCCESS = 'ANTENNA_EDITOR_REMOVE_SUCCESS';
|
||||
export const ANTENNA_EDITOR_REMOVE_FAIL = 'ANTENNA_EDITOR_REMOVE_FAIL';
|
||||
|
||||
export const ANTENNA_EXCLUDE_ACCOUNTS_FETCH_REQUEST = 'ANTENNA_EXCLUDE_ACCOUNTS_FETCH_REQUEST';
|
||||
export const ANTENNA_EXCLUDE_ACCOUNTS_FETCH_SUCCESS = 'ANTENNA_EXCLUDE_ACCOUNTS_FETCH_SUCCESS';
|
||||
export const ANTENNA_EXCLUDE_ACCOUNTS_FETCH_FAIL = 'ANTENNA_EXCLUDE_ACCOUNTS_FETCH_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_REQUEST = 'ANTENNA_EDITOR_ADD_EXCLUDE_REQUEST';
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_SUCCESS = 'ANTENNA_EDITOR_ADD_EXCLUDE_SUCCESS';
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_FAIL = 'ANTENNA_EDITOR_ADD_EXCLUDE_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_REQUEST = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_REQUEST';
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_SUCCESS = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_SUCCESS';
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_FAIL = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_FETCH_DOMAINS_REQUEST = 'ANTENNA_EDITOR_FETCH_DOMAINS_REQUEST';
|
||||
export const ANTENNA_EDITOR_FETCH_DOMAINS_SUCCESS = 'ANTENNA_EDITOR_FETCH_DOMAINS_SUCCESS';
|
||||
export const ANTENNA_EDITOR_FETCH_DOMAINS_FAIL = 'ANTENNA_EDITOR_FETCH_DOMAINS_FAIL';
|
||||
|
@ -51,10 +63,18 @@ export const ANTENNA_EDITOR_ADD_DOMAIN_REQUEST = 'ANTENNA_EDITOR_ADD_DOMAIN_REQU
|
|||
export const ANTENNA_EDITOR_ADD_DOMAIN_SUCCESS = 'ANTENNA_EDITOR_ADD_DOMAIN_SUCCESS';
|
||||
export const ANTENNA_EDITOR_ADD_DOMAIN_FAIL = 'ANTENNA_EDITOR_ADD_DOMAIN_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_REQUEST = 'ANTENNA_EDITOR_ADD_EXCLUDEDOMAIN_REQUEST';
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_SUCCESS = 'ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_SUCCESS';
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_FAIL = 'ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_REMOVE_DOMAIN_REQUEST = 'ANTENNA_EDITOR_REMOVE_DOMAIN_REQUEST';
|
||||
export const ANTENNA_EDITOR_REMOVE_DOMAIN_SUCCESS = 'ANTENNA_EDITOR_REMOVE_DOMAIN_SUCCESS';
|
||||
export const ANTENNA_EDITOR_REMOVE_DOMAIN_FAIL = 'ANTENNA_EDITOR_REMOVE_DOMAIN_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_REQUEST = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_REQUEST';
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_SUCCESS = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_SUCCESS';
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_FAIL = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_FETCH_KEYWORDS_REQUEST = 'ANTENNA_EDITOR_FETCH_KEYWORDS_REQUEST';
|
||||
export const ANTENNA_EDITOR_FETCH_KEYWORDS_SUCCESS = 'ANTENNA_EDITOR_FETCH_KEYWORDS_SUCCESS';
|
||||
export const ANTENNA_EDITOR_FETCH_KEYWORDS_FAIL = 'ANTENNA_EDITOR_FETCH_KEYWORDS_FAIL';
|
||||
|
@ -63,10 +83,18 @@ export const ANTENNA_EDITOR_ADD_KEYWORD_REQUEST = 'ANTENNA_EDITOR_ADD_KEYWORD_RE
|
|||
export const ANTENNA_EDITOR_ADD_KEYWORD_SUCCESS = 'ANTENNA_EDITOR_ADD_KEYWORD_SUCCESS';
|
||||
export const ANTENNA_EDITOR_ADD_KEYWORD_FAIL = 'ANTENNA_EDITOR_ADD_KEYWORD_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_REQUEST = 'ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_REQUEST';
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_SUCCESS = 'ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_SUCCESS';
|
||||
export const ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_FAIL = 'ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_REMOVE_KEYWORD_REQUEST = 'ANTENNA_EDITOR_REMOVE_KEYWORD_REQUEST';
|
||||
export const ANTENNA_EDITOR_REMOVE_KEYWORD_SUCCESS = 'ANTENNA_EDITOR_REMOVE_KEYWORD_SUCCESS';
|
||||
export const ANTENNA_EDITOR_REMOVE_KEYWORD_FAIL = 'ANTENNA_EDITOR_REMOVE_KEYWORD_FAIL';
|
||||
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_REQUEST = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_REQUEST';
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_SUCCESS = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_SUCCESS';
|
||||
export const ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_FAIL = 'ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_FAIL';
|
||||
|
||||
export const ANTENNA_ADDER_RESET = 'ANTENNA_ADDER_RESET';
|
||||
export const ANTENNA_ADDER_SETUP = 'ANTENNA_ADDER_SETUP';
|
||||
|
||||
|
@ -144,6 +172,15 @@ export const setupAntennaEditor = antennaId => (dispatch, getState) => {
|
|||
dispatch(fetchAntennaAccounts(antennaId));
|
||||
};
|
||||
|
||||
export const setupExcludeAntennaEditor = antennaId => (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ANTENNA_EDITOR_SETUP,
|
||||
antenna: getState().getIn(['antennas', antennaId]),
|
||||
});
|
||||
|
||||
dispatch(fetchAntennaExcludeAccounts(antennaId));
|
||||
};
|
||||
|
||||
export const changeAntennaEditorTitle = value => ({
|
||||
type: ANTENNA_EDITOR_TITLE_CHANGE,
|
||||
value,
|
||||
|
@ -258,6 +295,33 @@ export const fetchAntennaAccountsFail = (id, error) => ({
|
|||
error,
|
||||
});
|
||||
|
||||
export const fetchAntennaExcludeAccounts = antennaId => (dispatch, getState) => {
|
||||
dispatch(fetchAntennaExcludeAccountsRequest(antennaId));
|
||||
|
||||
api(getState).get(`/api/v1/antennas/${antennaId}/exclude_accounts`, { params: { limit: 0 } }).then(({ data }) => {
|
||||
dispatch(importFetchedAccounts(data));
|
||||
dispatch(fetchAntennaExcludeAccountsSuccess(antennaId, data));
|
||||
}).catch(err => dispatch(fetchAntennaExcludeAccountsFail(antennaId, err)));
|
||||
};
|
||||
|
||||
export const fetchAntennaExcludeAccountsRequest = id => ({
|
||||
type: ANTENNA_EXCLUDE_ACCOUNTS_FETCH_REQUEST,
|
||||
id,
|
||||
});
|
||||
|
||||
export const fetchAntennaExcludeAccountsSuccess = (id, accounts, next) => ({
|
||||
type: ANTENNA_EXCLUDE_ACCOUNTS_FETCH_SUCCESS,
|
||||
id,
|
||||
accounts,
|
||||
next,
|
||||
});
|
||||
|
||||
export const fetchAntennaExcludeAccountsFail = (id, error) => ({
|
||||
type: ANTENNA_EXCLUDE_ACCOUNTS_FETCH_FAIL,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
export const fetchAntennaSuggestions = q => (dispatch, getState) => {
|
||||
const params = {
|
||||
q,
|
||||
|
@ -316,6 +380,99 @@ export const addToAntennaFail = (antennaId, accountId, error) => ({
|
|||
error,
|
||||
});
|
||||
|
||||
export const addExcludeToAntennaEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(addExcludeToAntenna(getState().getIn(['antennaEditor', 'antennaId']), accountId));
|
||||
};
|
||||
|
||||
export const addExcludeToAntenna = (antennaId, accountId) => (dispatch, getState) => {
|
||||
dispatch(addExcludeToAntennaRequest(antennaId, accountId));
|
||||
|
||||
api(getState).post(`/api/v1/antennas/${antennaId}/exclude_accounts`, { account_ids: [accountId] })
|
||||
.then(() => dispatch(addExcludeToAntennaSuccess(antennaId, accountId)))
|
||||
.catch(err => dispatch(addExcludeToAntennaFail(antennaId, accountId, err)));
|
||||
};
|
||||
|
||||
export const addExcludeToAntennaRequest = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_REQUEST,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const addExcludeToAntennaSuccess = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_SUCCESS,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const addExcludeToAntennaFail = (antennaId, accountId, error) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_FAIL,
|
||||
antennaId,
|
||||
accountId,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeFromAntennaEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(removeFromAntenna(getState().getIn(['antennaEditor', 'antennaId']), accountId));
|
||||
};
|
||||
|
||||
export const removeFromAntenna = (antennaId, accountId) => (dispatch, getState) => {
|
||||
dispatch(removeFromAntennaRequest(antennaId, accountId));
|
||||
|
||||
api(getState).delete(`/api/v1/antennas/${antennaId}/accounts`, { params: { account_ids: [accountId] } })
|
||||
.then(() => dispatch(removeFromAntennaSuccess(antennaId, accountId)))
|
||||
.catch(err => dispatch(removeFromAntennaFail(antennaId, accountId, err)));
|
||||
};
|
||||
|
||||
export const removeFromAntennaRequest = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_REQUEST,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeFromAntennaSuccess = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_SUCCESS,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeFromAntennaFail = (antennaId, accountId, error) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_FAIL,
|
||||
antennaId,
|
||||
accountId,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeExcludeFromAntennaEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(removeExcludeFromAntenna(getState().getIn(['antennaEditor', 'antennaId']), accountId));
|
||||
};
|
||||
|
||||
export const removeExcludeFromAntenna = (antennaId, accountId) => (dispatch, getState) => {
|
||||
dispatch(removeExcludeFromAntennaRequest(antennaId, accountId));
|
||||
|
||||
api(getState).delete(`/api/v1/antennas/${antennaId}/exclude_accounts`, { params: { account_ids: [accountId] } })
|
||||
.then(() => dispatch(removeExcludeFromAntennaSuccess(antennaId, accountId)))
|
||||
.catch(err => dispatch(removeExcludeFromAntennaFail(antennaId, accountId, err)));
|
||||
};
|
||||
|
||||
export const removeExcludeFromAntennaRequest = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_REQUEST,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeExcludeFromAntennaSuccess = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_SUCCESS,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeExcludeFromAntennaFail = (antennaId, accountId, error) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_FAIL,
|
||||
antennaId,
|
||||
accountId,
|
||||
error,
|
||||
});
|
||||
|
||||
export const fetchAntennaDomains = antennaId => (dispatch, getState) => {
|
||||
dispatch(fetchAntennaDomainsRequest(antennaId));
|
||||
|
||||
|
@ -368,6 +525,87 @@ export const addDomainToAntennaFail = (antennaId, domain, error) => ({
|
|||
error,
|
||||
});
|
||||
|
||||
export const removeDomainFromAntenna = (antennaId, domain) => (dispatch, getState) => {
|
||||
dispatch(removeDomainFromAntennaRequest(antennaId, domain));
|
||||
|
||||
api(getState).delete(`/api/v1/antennas/${antennaId}/domains`, { params: { domains: [domain] } })
|
||||
.then(() => dispatch(removeDomainFromAntennaSuccess(antennaId, domain)))
|
||||
.catch(err => dispatch(removeDomainFromAntennaFail(antennaId, domain, err)));
|
||||
};
|
||||
|
||||
export const removeDomainFromAntennaRequest = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_DOMAIN_REQUEST,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const removeDomainFromAntennaSuccess = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_DOMAIN_SUCCESS,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const removeDomainFromAntennaFail = (antennaId, domain, error) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_DOMAIN_FAIL,
|
||||
antennaId,
|
||||
domain,
|
||||
error,
|
||||
});
|
||||
|
||||
export const addExcludeDomainToAntenna = (antennaId, domain) => (dispatch, getState) => {
|
||||
dispatch(addExcludeDomainToAntennaRequest(antennaId, domain));
|
||||
|
||||
api(getState).post(`/api/v1/antennas/${antennaId}/exclude_domains`, { domains: [domain] })
|
||||
.then(() => dispatch(addExcludeDomainToAntennaSuccess(antennaId, domain)))
|
||||
.catch(err => dispatch(addExcludeDomainToAntennaFail(antennaId, domain, err)));
|
||||
};
|
||||
|
||||
export const addExcludeDomainToAntennaRequest = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_REQUEST,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const addExcludeDomainToAntennaSuccess = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_SUCCESS,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const addExcludeDomainToAntennaFail = (antennaId, domain, error) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_FAIL,
|
||||
antennaId,
|
||||
domain,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeExcludeDomainFromAntenna = (antennaId, domain) => (dispatch, getState) => {
|
||||
dispatch(removeExcludeDomainFromAntennaRequest(antennaId, domain));
|
||||
|
||||
api(getState).delete(`/api/v1/antennas/${antennaId}/exclude_domains`, { params: { domains: [domain] } })
|
||||
.then(() => dispatch(removeExcludeDomainFromAntennaSuccess(antennaId, domain)))
|
||||
.catch(err => dispatch(removeExcludeDomainFromAntennaFail(antennaId, domain, err)));
|
||||
};
|
||||
|
||||
export const removeExcludeDomainFromAntennaRequest = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_REQUEST,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const removeExcludeDomainFromAntennaSuccess = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_SUCCESS,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const removeExcludeDomainFromAntennaFail = (antennaId, domain, error) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_FAIL,
|
||||
antennaId,
|
||||
domain,
|
||||
error,
|
||||
});
|
||||
|
||||
export const fetchAntennaKeywords = antennaId => (dispatch, getState) => {
|
||||
dispatch(fetchAntennaKeywordsRequest(antennaId));
|
||||
|
||||
|
@ -420,64 +658,6 @@ export const addKeywordToAntennaFail = (antennaId, keyword, error) => ({
|
|||
error,
|
||||
});
|
||||
|
||||
export const removeFromAntennaEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(removeFromAntenna(getState().getIn(['antennaEditor', 'antennaId']), accountId));
|
||||
};
|
||||
|
||||
export const removeFromAntenna = (antennaId, accountId) => (dispatch, getState) => {
|
||||
dispatch(removeFromAntennaRequest(antennaId, accountId));
|
||||
|
||||
api(getState).delete(`/api/v1/antennas/${antennaId}/accounts`, { params: { account_ids: [accountId] } })
|
||||
.then(() => dispatch(removeFromAntennaSuccess(antennaId, accountId)))
|
||||
.catch(err => dispatch(removeFromAntennaFail(antennaId, accountId, err)));
|
||||
};
|
||||
|
||||
export const removeFromAntennaRequest = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_REQUEST,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeFromAntennaSuccess = (antennaId, accountId) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_SUCCESS,
|
||||
antennaId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeFromAntennaFail = (antennaId, accountId, error) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_FAIL,
|
||||
antennaId,
|
||||
accountId,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeDomainFromAntenna = (antennaId, domain) => (dispatch, getState) => {
|
||||
dispatch(removeDomainFromAntennaRequest(antennaId, domain));
|
||||
|
||||
api(getState).delete(`/api/v1/antennas/${antennaId}/domains`, { params: { domains: [domain] } })
|
||||
.then(() => dispatch(removeDomainFromAntennaSuccess(antennaId, domain)))
|
||||
.catch(err => dispatch(removeDomainFromAntennaFail(antennaId, domain, err)));
|
||||
};
|
||||
|
||||
export const removeDomainFromAntennaRequest = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_DOMAIN_REQUEST,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const removeDomainFromAntennaSuccess = (antennaId, domain) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_DOMAIN_SUCCESS,
|
||||
antennaId,
|
||||
domain,
|
||||
});
|
||||
|
||||
export const removeDomainFromAntennaFail = (antennaId, domain, error) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_DOMAIN_FAIL,
|
||||
antennaId,
|
||||
domain,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeKeywordFromAntenna = (antennaId, keyword) => (dispatch, getState) => {
|
||||
dispatch(removeKeywordFromAntennaRequest(antennaId, keyword));
|
||||
|
||||
|
@ -505,6 +685,60 @@ export const removeKeywordFromAntennaFail = (antennaId, keyword, error) => ({
|
|||
error,
|
||||
});
|
||||
|
||||
export const addExcludeKeywordToAntenna = (antennaId, keyword) => (dispatch, getState) => {
|
||||
dispatch(addExcludeKeywordToAntennaRequest(antennaId, keyword));
|
||||
|
||||
api(getState).post(`/api/v1/antennas/${antennaId}/exclude_keywords`, { keywords: [keyword] })
|
||||
.then(() => dispatch(addExcludeKeywordToAntennaSuccess(antennaId, keyword)))
|
||||
.catch(err => dispatch(addExcludeKeywordToAntennaFail(antennaId, keyword, err)));
|
||||
};
|
||||
|
||||
export const addExcludeKeywordToAntennaRequest = (antennaId, keyword) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_REQUEST,
|
||||
antennaId,
|
||||
keyword,
|
||||
});
|
||||
|
||||
export const addExcludeKeywordToAntennaSuccess = (antennaId, keyword) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_SUCCESS,
|
||||
antennaId,
|
||||
keyword,
|
||||
});
|
||||
|
||||
export const addExcludeKeywordToAntennaFail = (antennaId, keyword, error) => ({
|
||||
type: ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_FAIL,
|
||||
antennaId,
|
||||
keyword,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeExcludeKeywordFromAntenna = (antennaId, keyword) => (dispatch, getState) => {
|
||||
dispatch(removeExcludeKeywordFromAntennaRequest(antennaId, keyword));
|
||||
|
||||
api(getState).delete(`/api/v1/antennas/${antennaId}/exclude_keywords`, { params: { keywords: [keyword] } })
|
||||
.then(() => dispatch(removeExcludeKeywordFromAntennaSuccess(antennaId, keyword)))
|
||||
.catch(err => dispatch(removeExcludeKeywordFromAntennaFail(antennaId, keyword, err)));
|
||||
};
|
||||
|
||||
export const removeExcludeKeywordFromAntennaRequest = (antennaId, keyword) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_REQUEST,
|
||||
antennaId,
|
||||
keyword,
|
||||
});
|
||||
|
||||
export const removeExcludeKeywordFromAntennaSuccess = (antennaId, keyword) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_SUCCESS,
|
||||
antennaId,
|
||||
keyword,
|
||||
});
|
||||
|
||||
export const removeExcludeKeywordFromAntennaFail = (antennaId, keyword, error) => ({
|
||||
type: ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_FAIL,
|
||||
antennaId,
|
||||
keyword,
|
||||
error,
|
||||
});
|
||||
|
||||
export const resetAntennaAdder = () => ({
|
||||
type: ANTENNA_ADDER_RESET,
|
||||
});
|
||||
|
|
372
app/javascript/mastodon/actions/circles.js
Normal file
372
app/javascript/mastodon/actions/circles.js
Normal file
|
@ -0,0 +1,372 @@
|
|||
import api from '../api';
|
||||
|
||||
import { showAlertForError } from './alerts';
|
||||
import { importFetchedAccounts } from './importer';
|
||||
|
||||
export const CIRCLE_FETCH_REQUEST = 'CIRCLE_FETCH_REQUEST';
|
||||
export const CIRCLE_FETCH_SUCCESS = 'CIRCLE_FETCH_SUCCESS';
|
||||
export const CIRCLE_FETCH_FAIL = 'CIRCLE_FETCH_FAIL';
|
||||
|
||||
export const CIRCLES_FETCH_REQUEST = 'CIRCLES_FETCH_REQUEST';
|
||||
export const CIRCLES_FETCH_SUCCESS = 'CIRCLES_FETCH_SUCCESS';
|
||||
export const CIRCLES_FETCH_FAIL = 'CIRCLES_FETCH_FAIL';
|
||||
|
||||
export const CIRCLE_EDITOR_TITLE_CHANGE = 'CIRCLE_EDITOR_TITLE_CHANGE';
|
||||
export const CIRCLE_EDITOR_RESET = 'CIRCLE_EDITOR_RESET';
|
||||
export const CIRCLE_EDITOR_SETUP = 'CIRCLE_EDITOR_SETUP';
|
||||
|
||||
export const CIRCLE_CREATE_REQUEST = 'CIRCLE_CREATE_REQUEST';
|
||||
export const CIRCLE_CREATE_SUCCESS = 'CIRCLE_CREATE_SUCCESS';
|
||||
export const CIRCLE_CREATE_FAIL = 'CIRCLE_CREATE_FAIL';
|
||||
|
||||
export const CIRCLE_UPDATE_REQUEST = 'CIRCLE_UPDATE_REQUEST';
|
||||
export const CIRCLE_UPDATE_SUCCESS = 'CIRCLE_UPDATE_SUCCESS';
|
||||
export const CIRCLE_UPDATE_FAIL = 'CIRCLE_UPDATE_FAIL';
|
||||
|
||||
export const CIRCLE_DELETE_REQUEST = 'CIRCLE_DELETE_REQUEST';
|
||||
export const CIRCLE_DELETE_SUCCESS = 'CIRCLE_DELETE_SUCCESS';
|
||||
export const CIRCLE_DELETE_FAIL = 'CIRCLE_DELETE_FAIL';
|
||||
|
||||
export const CIRCLE_ACCOUNTS_FETCH_REQUEST = 'CIRCLE_ACCOUNTS_FETCH_REQUEST';
|
||||
export const CIRCLE_ACCOUNTS_FETCH_SUCCESS = 'CIRCLE_ACCOUNTS_FETCH_SUCCESS';
|
||||
export const CIRCLE_ACCOUNTS_FETCH_FAIL = 'CIRCLE_ACCOUNTS_FETCH_FAIL';
|
||||
|
||||
export const CIRCLE_EDITOR_SUGGESTIONS_CHANGE = 'CIRCLE_EDITOR_SUGGESTIONS_CHANGE';
|
||||
export const CIRCLE_EDITOR_SUGGESTIONS_READY = 'CIRCLE_EDITOR_SUGGESTIONS_READY';
|
||||
export const CIRCLE_EDITOR_SUGGESTIONS_CLEAR = 'CIRCLE_EDITOR_SUGGESTIONS_CLEAR';
|
||||
|
||||
export const CIRCLE_EDITOR_ADD_REQUEST = 'CIRCLE_EDITOR_ADD_REQUEST';
|
||||
export const CIRCLE_EDITOR_ADD_SUCCESS = 'CIRCLE_EDITOR_ADD_SUCCESS';
|
||||
export const CIRCLE_EDITOR_ADD_FAIL = 'CIRCLE_EDITOR_ADD_FAIL';
|
||||
|
||||
export const CIRCLE_EDITOR_REMOVE_REQUEST = 'CIRCLE_EDITOR_REMOVE_REQUEST';
|
||||
export const CIRCLE_EDITOR_REMOVE_SUCCESS = 'CIRCLE_EDITOR_REMOVE_SUCCESS';
|
||||
export const CIRCLE_EDITOR_REMOVE_FAIL = 'CIRCLE_EDITOR_REMOVE_FAIL';
|
||||
|
||||
export const CIRCLE_ADDER_RESET = 'CIRCLE_ADDER_RESET';
|
||||
export const CIRCLE_ADDER_SETUP = 'CIRCLE_ADDER_SETUP';
|
||||
|
||||
export const CIRCLE_ADDER_CIRCLES_FETCH_REQUEST = 'CIRCLE_ADDER_CIRCLES_FETCH_REQUEST';
|
||||
export const CIRCLE_ADDER_CIRCLES_FETCH_SUCCESS = 'CIRCLE_ADDER_CIRCLES_FETCH_SUCCESS';
|
||||
export const CIRCLE_ADDER_CIRCLES_FETCH_FAIL = 'CIRCLE_ADDER_CIRCLES_FETCH_FAIL';
|
||||
|
||||
export const fetchCircle = id => (dispatch, getState) => {
|
||||
if (getState().getIn(['circles', id])) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(fetchCircleRequest(id));
|
||||
|
||||
api(getState).get(`/api/v1/circles/${id}`)
|
||||
.then(({ data }) => dispatch(fetchCircleSuccess(data)))
|
||||
.catch(err => dispatch(fetchCircleFail(id, err)));
|
||||
};
|
||||
|
||||
export const fetchCircleRequest = id => ({
|
||||
type: CIRCLE_FETCH_REQUEST,
|
||||
id,
|
||||
});
|
||||
|
||||
export const fetchCircleSuccess = circle => ({
|
||||
type: CIRCLE_FETCH_SUCCESS,
|
||||
circle,
|
||||
});
|
||||
|
||||
export const fetchCircleFail = (id, error) => ({
|
||||
type: CIRCLE_FETCH_FAIL,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
export const fetchCircles = () => (dispatch, getState) => {
|
||||
dispatch(fetchCirclesRequest());
|
||||
|
||||
api(getState).get('/api/v1/circles')
|
||||
.then(({ data }) => dispatch(fetchCirclesSuccess(data)))
|
||||
.catch(err => dispatch(fetchCirclesFail(err)));
|
||||
};
|
||||
|
||||
export const fetchCirclesRequest = () => ({
|
||||
type: CIRCLES_FETCH_REQUEST,
|
||||
});
|
||||
|
||||
export const fetchCirclesSuccess = circles => ({
|
||||
type: CIRCLES_FETCH_SUCCESS,
|
||||
circles,
|
||||
});
|
||||
|
||||
export const fetchCirclesFail = error => ({
|
||||
type: CIRCLES_FETCH_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
export const submitCircleEditor = shouldReset => (dispatch, getState) => {
|
||||
const circleId = getState().getIn(['circleEditor', 'circleId']);
|
||||
const title = getState().getIn(['circleEditor', 'title']);
|
||||
|
||||
if (circleId === null) {
|
||||
dispatch(createCircle(title, shouldReset));
|
||||
} else {
|
||||
dispatch(updateCircle(circleId, title, shouldReset));
|
||||
}
|
||||
};
|
||||
|
||||
export const setupCircleEditor = circleId => (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: CIRCLE_EDITOR_SETUP,
|
||||
circle: getState().getIn(['circles', circleId]),
|
||||
});
|
||||
|
||||
dispatch(fetchCircleAccounts(circleId));
|
||||
};
|
||||
|
||||
export const changeCircleEditorTitle = value => ({
|
||||
type: CIRCLE_EDITOR_TITLE_CHANGE,
|
||||
value,
|
||||
});
|
||||
|
||||
export const createCircle = (title, shouldReset) => (dispatch, getState) => {
|
||||
dispatch(createCircleRequest());
|
||||
|
||||
api(getState).post('/api/v1/circles', { title }).then(({ data }) => {
|
||||
dispatch(createCircleSuccess(data));
|
||||
|
||||
if (shouldReset) {
|
||||
dispatch(resetCircleEditor());
|
||||
}
|
||||
}).catch(err => dispatch(createCircleFail(err)));
|
||||
};
|
||||
|
||||
export const createCircleRequest = () => ({
|
||||
type: CIRCLE_CREATE_REQUEST,
|
||||
});
|
||||
|
||||
export const createCircleSuccess = circle => ({
|
||||
type: CIRCLE_CREATE_SUCCESS,
|
||||
circle,
|
||||
});
|
||||
|
||||
export const createCircleFail = error => ({
|
||||
type: CIRCLE_CREATE_FAIL,
|
||||
error,
|
||||
});
|
||||
|
||||
export const updateCircle = (id, title, shouldReset, isExclusive, replies_policy) => (dispatch, getState) => {
|
||||
dispatch(updateCircleRequest(id));
|
||||
|
||||
api(getState).put(`/api/v1/circles/${id}`, { title, replies_policy, exclusive: typeof isExclusive === 'undefined' ? undefined : !!isExclusive }).then(({ data }) => {
|
||||
dispatch(updateCircleSuccess(data));
|
||||
|
||||
if (shouldReset) {
|
||||
dispatch(resetCircleEditor());
|
||||
}
|
||||
}).catch(err => dispatch(updateCircleFail(id, err)));
|
||||
};
|
||||
|
||||
export const updateCircleRequest = id => ({
|
||||
type: CIRCLE_UPDATE_REQUEST,
|
||||
id,
|
||||
});
|
||||
|
||||
export const updateCircleSuccess = circle => ({
|
||||
type: CIRCLE_UPDATE_SUCCESS,
|
||||
circle,
|
||||
});
|
||||
|
||||
export const updateCircleFail = (id, error) => ({
|
||||
type: CIRCLE_UPDATE_FAIL,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
export const resetCircleEditor = () => ({
|
||||
type: CIRCLE_EDITOR_RESET,
|
||||
});
|
||||
|
||||
export const deleteCircle = id => (dispatch, getState) => {
|
||||
dispatch(deleteCircleRequest(id));
|
||||
|
||||
api(getState).delete(`/api/v1/circles/${id}`)
|
||||
.then(() => dispatch(deleteCircleSuccess(id)))
|
||||
.catch(err => dispatch(deleteCircleFail(id, err)));
|
||||
};
|
||||
|
||||
export const deleteCircleRequest = id => ({
|
||||
type: CIRCLE_DELETE_REQUEST,
|
||||
id,
|
||||
});
|
||||
|
||||
export const deleteCircleSuccess = id => ({
|
||||
type: CIRCLE_DELETE_SUCCESS,
|
||||
id,
|
||||
});
|
||||
|
||||
export const deleteCircleFail = (id, error) => ({
|
||||
type: CIRCLE_DELETE_FAIL,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
export const fetchCircleAccounts = circleId => (dispatch, getState) => {
|
||||
dispatch(fetchCircleAccountsRequest(circleId));
|
||||
|
||||
api(getState).get(`/api/v1/circles/${circleId}/accounts`, { params: { limit: 0 } }).then(({ data }) => {
|
||||
dispatch(importFetchedAccounts(data));
|
||||
dispatch(fetchCircleAccountsSuccess(circleId, data));
|
||||
}).catch(err => dispatch(fetchCircleAccountsFail(circleId, err)));
|
||||
};
|
||||
|
||||
export const fetchCircleAccountsRequest = id => ({
|
||||
type: CIRCLE_ACCOUNTS_FETCH_REQUEST,
|
||||
id,
|
||||
});
|
||||
|
||||
export const fetchCircleAccountsSuccess = (id, accounts, next) => ({
|
||||
type: CIRCLE_ACCOUNTS_FETCH_SUCCESS,
|
||||
id,
|
||||
accounts,
|
||||
next,
|
||||
});
|
||||
|
||||
export const fetchCircleAccountsFail = (id, error) => ({
|
||||
type: CIRCLE_ACCOUNTS_FETCH_FAIL,
|
||||
id,
|
||||
error,
|
||||
});
|
||||
|
||||
export const fetchCircleSuggestions = q => (dispatch, getState) => {
|
||||
const params = {
|
||||
q,
|
||||
resolve: false,
|
||||
follower: true,
|
||||
};
|
||||
|
||||
api(getState).get('/api/v1/accounts/search', { params }).then(({ data }) => {
|
||||
dispatch(importFetchedAccounts(data));
|
||||
dispatch(fetchCircleSuggestionsReady(q, data));
|
||||
}).catch(error => dispatch(showAlertForError(error)));
|
||||
};
|
||||
|
||||
export const fetchCircleSuggestionsReady = (query, accounts) => ({
|
||||
type: CIRCLE_EDITOR_SUGGESTIONS_READY,
|
||||
query,
|
||||
accounts,
|
||||
});
|
||||
|
||||
export const clearCircleSuggestions = () => ({
|
||||
type: CIRCLE_EDITOR_SUGGESTIONS_CLEAR,
|
||||
});
|
||||
|
||||
export const changeCircleSuggestions = value => ({
|
||||
type: CIRCLE_EDITOR_SUGGESTIONS_CHANGE,
|
||||
value,
|
||||
});
|
||||
|
||||
export const addToCircleEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(addToCircle(getState().getIn(['circleEditor', 'circleId']), accountId));
|
||||
};
|
||||
|
||||
export const addToCircle = (circleId, accountId) => (dispatch, getState) => {
|
||||
dispatch(addToCircleRequest(circleId, accountId));
|
||||
|
||||
api(getState).post(`/api/v1/circles/${circleId}/accounts`, { account_ids: [accountId] })
|
||||
.then(() => dispatch(addToCircleSuccess(circleId, accountId)))
|
||||
.catch(err => dispatch(addToCircleFail(circleId, accountId, err)));
|
||||
};
|
||||
|
||||
export const addToCircleRequest = (circleId, accountId) => ({
|
||||
type: CIRCLE_EDITOR_ADD_REQUEST,
|
||||
circleId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const addToCircleSuccess = (circleId, accountId) => ({
|
||||
type: CIRCLE_EDITOR_ADD_SUCCESS,
|
||||
circleId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const addToCircleFail = (circleId, accountId, error) => ({
|
||||
type: CIRCLE_EDITOR_ADD_FAIL,
|
||||
circleId,
|
||||
accountId,
|
||||
error,
|
||||
});
|
||||
|
||||
export const removeFromCircleEditor = accountId => (dispatch, getState) => {
|
||||
dispatch(removeFromCircle(getState().getIn(['circleEditor', 'circleId']), accountId));
|
||||
};
|
||||
|
||||
export const removeFromCircle = (circleId, accountId) => (dispatch, getState) => {
|
||||
dispatch(removeFromCircleRequest(circleId, accountId));
|
||||
|
||||
api(getState).delete(`/api/v1/circles/${circleId}/accounts`, { params: { account_ids: [accountId] } })
|
||||
.then(() => dispatch(removeFromCircleSuccess(circleId, accountId)))
|
||||
.catch(err => dispatch(removeFromCircleFail(circleId, accountId, err)));
|
||||
};
|
||||
|
||||
export const removeFromCircleRequest = (circleId, accountId) => ({
|
||||
type: CIRCLE_EDITOR_REMOVE_REQUEST,
|
||||
circleId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeFromCircleSuccess = (circleId, accountId) => ({
|
||||
type: CIRCLE_EDITOR_REMOVE_SUCCESS,
|
||||
circleId,
|
||||
accountId,
|
||||
});
|
||||
|
||||
export const removeFromCircleFail = (circleId, accountId, error) => ({
|
||||
type: CIRCLE_EDITOR_REMOVE_FAIL,
|
||||
circleId,
|
||||
accountId,
|
||||
error,
|
||||
});
|
||||
|
||||
export const resetCircleAdder = () => ({
|
||||
type: CIRCLE_ADDER_RESET,
|
||||
});
|
||||
|
||||
export const setupCircleAdder = accountId => (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: CIRCLE_ADDER_SETUP,
|
||||
account: getState().getIn(['accounts', accountId]),
|
||||
});
|
||||
dispatch(fetchCircles());
|
||||
dispatch(fetchAccountCircles(accountId));
|
||||
};
|
||||
|
||||
export const fetchAccountCircles = accountId => (dispatch, getState) => {
|
||||
dispatch(fetchAccountCirclesRequest(accountId));
|
||||
|
||||
api(getState).get(`/api/v1/accounts/${accountId}/circles`)
|
||||
.then(({ data }) => dispatch(fetchAccountCirclesSuccess(accountId, data)))
|
||||
.catch(err => dispatch(fetchAccountCirclesFail(accountId, err)));
|
||||
};
|
||||
|
||||
export const fetchAccountCirclesRequest = id => ({
|
||||
type:CIRCLE_ADDER_CIRCLES_FETCH_REQUEST,
|
||||
id,
|
||||
});
|
||||
|
||||
export const fetchAccountCirclesSuccess = (id, circles) => ({
|
||||
type: CIRCLE_ADDER_CIRCLES_FETCH_SUCCESS,
|
||||
id,
|
||||
circles,
|
||||
});
|
||||
|
||||
export const fetchAccountCirclesFail = (id, err) => ({
|
||||
type: CIRCLE_ADDER_CIRCLES_FETCH_FAIL,
|
||||
id,
|
||||
err,
|
||||
});
|
||||
|
||||
export const addToCircleAdder = circleId => (dispatch, getState) => {
|
||||
dispatch(addToCircle(circleId, getState().getIn(['circleAdder', 'accountId'])));
|
||||
};
|
||||
|
||||
export const removeFromCircleAdder = circleId => (dispatch, getState) => {
|
||||
dispatch(removeFromCircle(circleId, getState().getIn(['circleAdder', 'accountId'])));
|
||||
};
|
||||
|
|
@ -75,6 +75,8 @@ export const COMPOSE_POLL_OPTION_CHANGE = 'COMPOSE_POLL_OPTION_CHANGE';
|
|||
export const COMPOSE_POLL_OPTION_REMOVE = 'COMPOSE_POLL_OPTION_REMOVE';
|
||||
export const COMPOSE_POLL_SETTINGS_CHANGE = 'COMPOSE_POLL_SETTINGS_CHANGE';
|
||||
|
||||
export const COMPOSE_CIRCLE_CHANGE = 'COMPOSE_CIRCLE_CHANGE';
|
||||
|
||||
export const INIT_MEDIA_EDIT_MODAL = 'INIT_MEDIA_EDIT_MODAL';
|
||||
|
||||
export const COMPOSE_CHANGE_MEDIA_DESCRIPTION = 'COMPOSE_CHANGE_MEDIA_DESCRIPTION';
|
||||
|
@ -211,6 +213,7 @@ export function submitCompose(routerHistory) {
|
|||
markdown: getState().getIn(['compose', 'markdown']),
|
||||
visibility: getState().getIn(['compose', 'privacy']),
|
||||
searchability: getState().getIn(['compose', 'searchability']),
|
||||
circle_id: getState().getIn(['compose', 'circle_id']),
|
||||
poll: getState().getIn(['compose', 'poll'], null),
|
||||
language: getState().getIn(['compose', 'language']),
|
||||
},
|
||||
|
@ -837,3 +840,10 @@ export function changePollSettings(expiresIn, isMultiple) {
|
|||
isMultiple,
|
||||
};
|
||||
}
|
||||
|
||||
export function changeCircle(circleId) {
|
||||
return {
|
||||
type: COMPOSE_CIRCLE_CHANGE,
|
||||
circleId,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ interface Props {
|
|||
obfuscateCount?: boolean;
|
||||
href?: string;
|
||||
ariaHidden: boolean;
|
||||
data_id?: string;
|
||||
}
|
||||
interface States {
|
||||
activate: boolean;
|
||||
|
@ -108,6 +109,7 @@ export class IconButton extends PureComponent<Props, States> {
|
|||
obfuscateCount,
|
||||
href,
|
||||
ariaHidden,
|
||||
data_id,
|
||||
} = this.props;
|
||||
|
||||
const { activate, deactivate } = this.state;
|
||||
|
@ -160,6 +162,7 @@ export class IconButton extends PureComponent<Props, States> {
|
|||
style={style}
|
||||
tabIndex={tabIndex}
|
||||
disabled={disabled}
|
||||
data-id={data_id}
|
||||
>
|
||||
{contents}
|
||||
</button>
|
||||
|
|
|
@ -72,6 +72,7 @@ const messages = defineMessages({
|
|||
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers only' },
|
||||
limited_short: { id: 'privacy.limited.short', defaultMessage: 'Limited menbers only' },
|
||||
mutual_short: { id: 'privacy.mutual.short', defaultMessage: 'Mutual followers only' },
|
||||
circle_short: { id: 'privacy.circle.short', defaultMessage: 'Circle members only' },
|
||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Mentioned people only' },
|
||||
edited: { id: 'status.edited', defaultMessage: 'Edited {date}' },
|
||||
});
|
||||
|
@ -403,6 +404,7 @@ class Status extends ImmutablePureComponent {
|
|||
'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
|
||||
'limited': { icon: 'get-pocket', text: intl.formatMessage(messages.limited_short) },
|
||||
'mutual': { icon: 'exchange', text: intl.formatMessage(messages.mutual_short) },
|
||||
'circle': { icon: 'user-circle', text: intl.formatMessage(messages.circle_short) },
|
||||
'direct': { icon: 'at', text: intl.formatMessage(messages.direct_short) },
|
||||
};
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import { Provider as ReduxProvider } from 'react-redux';
|
|||
|
||||
import { ScrollContext } from 'react-router-scroll-4';
|
||||
|
||||
import { fetchCircles } from 'mastodon/actions/circles';
|
||||
import { fetchCustomEmojis } from 'mastodon/actions/custom_emojis';
|
||||
import { fetchReactionDeck } from 'mastodon/actions/reaction_deck';
|
||||
import { hydrateStore } from 'mastodon/actions/store';
|
||||
|
@ -27,6 +28,7 @@ store.dispatch(hydrateAction);
|
|||
if (initialState.meta.me) {
|
||||
store.dispatch(fetchCustomEmojis());
|
||||
store.dispatch(fetchReactionDeck());
|
||||
store.dispatch(fetchCircles());
|
||||
}
|
||||
|
||||
const createIdentityContext = state => ({
|
||||
|
|
|
@ -6,7 +6,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { removeFromAntennaEditor, addToAntennaEditor } from '../../../actions/antennas';
|
||||
import { removeFromAntennaEditor, addToAntennaEditor, removeExcludeFromAntennaEditor, addExcludeToAntennaEditor } from '../../../actions/antennas';
|
||||
import { Avatar } from '../../../components/avatar';
|
||||
import { DisplayName } from '../../../components/display_name';
|
||||
import { IconButton } from '../../../components/icon_button';
|
||||
|
@ -20,9 +20,9 @@ const messages = defineMessages({
|
|||
const makeMapStateToProps = () => {
|
||||
const getAccount = makeGetAccount();
|
||||
|
||||
const mapStateToProps = (state, { accountId, added }) => ({
|
||||
const mapStateToProps = (state, { accountId, added, isExclude }) => ({
|
||||
account: getAccount(state, accountId),
|
||||
added: typeof added === 'undefined' ? state.getIn(['antennaEditor', 'accounts', 'items']).includes(accountId) : added,
|
||||
added: typeof added === 'undefined' ? state.getIn(['antennaEditor', isExclude ? 'excludeAccounts' : 'accounts', 'items']).includes(accountId) : added,
|
||||
});
|
||||
|
||||
return mapStateToProps;
|
||||
|
@ -31,15 +31,20 @@ const makeMapStateToProps = () => {
|
|||
const mapDispatchToProps = (dispatch, { accountId }) => ({
|
||||
onRemove: () => dispatch(removeFromAntennaEditor(accountId)),
|
||||
onAdd: () => dispatch(addToAntennaEditor(accountId)),
|
||||
onExcludeRemove: () => dispatch(removeExcludeFromAntennaEditor(accountId)),
|
||||
onExcludeAdd: () => dispatch(addExcludeToAntennaEditor(accountId)),
|
||||
});
|
||||
|
||||
class Account extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
account: ImmutablePropTypes.map.isRequired,
|
||||
isExclude: PropTypes.bool.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onRemove: PropTypes.func.isRequired,
|
||||
onAdd: PropTypes.func.isRequired,
|
||||
onExcludeRemove: PropTypes.func.isRequired,
|
||||
onExcludeAdd: PropTypes.func.isRequired,
|
||||
added: PropTypes.bool,
|
||||
};
|
||||
|
||||
|
@ -48,14 +53,14 @@ class Account extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
render () {
|
||||
const { account, intl, onRemove, onAdd, added } = this.props;
|
||||
const { account, intl, isExclude, onRemove, onAdd, onExcludeRemove, onExcludeAdd, added } = this.props;
|
||||
|
||||
let button;
|
||||
|
||||
if (added) {
|
||||
button = <IconButton icon='times' title={intl.formatMessage(messages.remove)} onClick={onRemove} />;
|
||||
button = <IconButton icon='times' title={intl.formatMessage(messages.remove)} onClick={isExclude ? onExcludeRemove : onRemove} />;
|
||||
} else {
|
||||
button = <IconButton icon='plus' title={intl.formatMessage(messages.add)} onClick={onAdd} />;
|
||||
button = <IconButton icon='plus' title={intl.formatMessage(messages.add)} onClick={isExclude ? onExcludeAdd : onAdd} />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -8,20 +8,20 @@ import { connect } from 'react-redux';
|
|||
|
||||
import spring from 'react-motion/lib/spring';
|
||||
|
||||
import { setupAntennaEditor, clearAntennaSuggestions, resetAntennaEditor } from '../../actions/antennas';
|
||||
import { setupAntennaEditor, setupExcludeAntennaEditor, clearAntennaSuggestions, resetAntennaEditor } from '../../actions/antennas';
|
||||
import Motion from '../ui/util/optional_motion';
|
||||
|
||||
import Account from './components/account';
|
||||
import EditAntennaForm from './components/edit_antenna_form';
|
||||
import Search from './components/search';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
accountIds: state.getIn(['antennaEditor', 'accounts', 'items']),
|
||||
const mapStateToProps = (state, { isExclude }) => ({
|
||||
accountIds: state.getIn(['antennaEditor', isExclude ? 'excludeAccounts' : 'accounts', 'items']),
|
||||
searchAccountIds: state.getIn(['antennaEditor', 'suggestions', 'items']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onInitialize: antennaId => dispatch(setupAntennaEditor(antennaId)),
|
||||
const mapDispatchToProps = (dispatch, { isExclude }) => ({
|
||||
onInitialize: antennaId => dispatch(isExclude ? setupExcludeAntennaEditor(antennaId) : setupAntennaEditor(antennaId)),
|
||||
onClear: () => dispatch(clearAntennaSuggestions()),
|
||||
onReset: () => dispatch(resetAntennaEditor()),
|
||||
});
|
||||
|
@ -30,6 +30,7 @@ class AntennaEditor extends ImmutablePureComponent {
|
|||
|
||||
static propTypes = {
|
||||
antennaId: PropTypes.string.isRequired,
|
||||
isExclude: PropTypes.bool.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onInitialize: PropTypes.func.isRequired,
|
||||
|
@ -50,7 +51,7 @@ class AntennaEditor extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
render () {
|
||||
const { accountIds, searchAccountIds, onClear } = this.props;
|
||||
const { accountIds, searchAccountIds, onClear, isExclude } = this.props;
|
||||
const showSearch = searchAccountIds.size > 0;
|
||||
|
||||
return (
|
||||
|
@ -61,7 +62,7 @@ class AntennaEditor extends ImmutablePureComponent {
|
|||
|
||||
<div className='drawer__pager'>
|
||||
<div className='drawer__inner list-editor__accounts'>
|
||||
{accountIds.map(accountId => <Account key={accountId} accountId={accountId} added />)}
|
||||
{accountIds.map(accountId => <Account key={accountId} accountId={accountId} isExclude={isExclude} added />)}
|
||||
</div>
|
||||
|
||||
{showSearch && <div role='button' tabIndex={-1} className='drawer__backdrop' onClick={onClear} />}
|
||||
|
@ -69,7 +70,7 @@ class AntennaEditor extends ImmutablePureComponent {
|
|||
<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} />)}
|
||||
{searchAccountIds.map(accountId => <Account key={accountId} accountId={accountId} isExclude={isExclude} />)}
|
||||
</div>
|
||||
)}
|
||||
</Motion>
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
class RadioPanel extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
values: ImmutablePropTypes.list.isRequired,
|
||||
value: PropTypes.object.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
handleChange = e => {
|
||||
const value = e.currentTarget.getAttribute('data-value');
|
||||
|
||||
if (value !== this.props.value.get('value')) {
|
||||
this.props.onChange(value);
|
||||
}
|
||||
};
|
||||
|
||||
render () {
|
||||
const { values, value } = this.props;
|
||||
|
||||
return (
|
||||
<div className='setting-radio-panel'>
|
||||
{values.map((val) => (
|
||||
<button className={classNames('setting-radio-panel__item', {'setting-radio-panel__item__active': value.get('value') === val.get('value')})}
|
||||
key={val.get('value')} onClick={this.handleChange} data-value={val.get('value')}>
|
||||
{val.get('label')}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect()(injectIntl(RadioPanel));
|
|
@ -59,6 +59,11 @@ class TextList extends PureComponent {
|
|||
this.props.onAdd();
|
||||
};
|
||||
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
this.handleAdd();
|
||||
};
|
||||
|
||||
render () {
|
||||
const { icon, value, values, disabled, label, title } = this.props;
|
||||
|
||||
|
@ -68,7 +73,7 @@ class TextList extends PureComponent {
|
|||
<TextListItem key={val} value={val} icon={icon} onRemove={this.props.onRemove} />
|
||||
))}
|
||||
|
||||
<form className='add-text-form'>
|
||||
<form className='add-text-form' onSubmit={this.handleSubmit}>
|
||||
<label>
|
||||
<span style={{ display: 'none' }}>{label}</span>
|
||||
|
||||
|
|
|
@ -5,14 +5,28 @@ import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
|
|||
|
||||
import { Helmet } from 'react-helmet';
|
||||
|
||||
import { List as ImmutableList } from 'immutable';
|
||||
import { List as ImmutableList, Map as ImmutableMap } from 'immutable';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import Select, { NonceProvider } from 'react-select';
|
||||
import Toggle from 'react-toggle';
|
||||
|
||||
import { fetchAntenna, deleteAntenna, updateAntenna, addDomainToAntenna, removeDomainFromAntenna, fetchAntennaDomains, fetchAntennaKeywords, removeKeywordFromAntenna, addKeywordToAntenna } from 'mastodon/actions/antennas';
|
||||
import {
|
||||
fetchAntenna,
|
||||
deleteAntenna,
|
||||
updateAntenna,
|
||||
addDomainToAntenna,
|
||||
removeDomainFromAntenna,
|
||||
addExcludeDomainToAntenna,
|
||||
removeExcludeDomainFromAntenna,
|
||||
fetchAntennaDomains,
|
||||
fetchAntennaKeywords,
|
||||
removeKeywordFromAntenna,
|
||||
addKeywordToAntenna,
|
||||
removeExcludeKeywordFromAntenna,
|
||||
addExcludeKeywordToAntenna
|
||||
} from 'mastodon/actions/antennas';
|
||||
import { addColumn, removeColumn, moveColumn } from 'mastodon/actions/columns';
|
||||
import { fetchLists } from 'mastodon/actions/lists';
|
||||
import { openModal } from 'mastodon/actions/modal';
|
||||
|
@ -23,6 +37,7 @@ import { Icon } from 'mastodon/components/icon';
|
|||
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
|
||||
import BundleColumnError from 'mastodon/features/ui/components/bundle_column_error';
|
||||
|
||||
import RadioPanel from './components/radio_panel';
|
||||
import TextList from './components/text_list';
|
||||
|
||||
const messages = defineMessages({
|
||||
|
@ -35,13 +50,18 @@ const messages = defineMessages({
|
|||
addKeywordLabel: { id: 'antennas.add_keyword_placeholder', defaultMessage: 'New keyword' },
|
||||
addDomainTitle: { id: 'antennas.add_domain', defaultMessage: 'Add domain' },
|
||||
addKeywordTitle: { id: 'antennas.add_keyword', defaultMessage: 'Add keyword' },
|
||||
accounts: { id: 'antennas.accounts', defaultMessage: '{count} accounts' },
|
||||
domains: { id: 'antennas.domains', defaultMessage: '{count} domains' },
|
||||
tags: { id: 'antennas.tags', defaultMessage: '{count} tags' },
|
||||
keywords: { id: 'antennas.keywords', defaultMessage: '{count} keywords' },
|
||||
setHome: { id: 'antennas.select.set_home', defaultMessage: 'Set home' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, props) => ({
|
||||
antenna: state.getIn(['antennas', props.params.id]),
|
||||
lists: state.get('lists'),
|
||||
domains: state.getIn(['antennas', props.params.id, 'domains']) || ImmutableList(),
|
||||
keywords: state.getIn(['antennas', props.params.id, 'keywords']) || ImmutableList(),
|
||||
domains: state.getIn(['antennas', props.params.id, 'domains']) || ImmutableMap(),
|
||||
keywords: state.getIn(['antennas', props.params.id, 'keywords']) || ImmutableMap(),
|
||||
});
|
||||
|
||||
class AntennaSetting extends PureComponent {
|
||||
|
@ -56,15 +76,19 @@ class AntennaSetting extends PureComponent {
|
|||
columnId: PropTypes.string,
|
||||
multiColumn: PropTypes.bool,
|
||||
antenna: PropTypes.oneOfType([ImmutablePropTypes.map, PropTypes.bool]),
|
||||
lists: ImmutablePropTypes.list,
|
||||
domains: ImmutablePropTypes.list,
|
||||
keywords: ImmutablePropTypes.list,
|
||||
lists: ImmutablePropTypes.map,
|
||||
domains: ImmutablePropTypes.map,
|
||||
keywords: ImmutablePropTypes.map,
|
||||
intl: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
state = {
|
||||
domainName: '',
|
||||
excludeDomainName: '',
|
||||
keywordName: '',
|
||||
excludeKeywordName: '',
|
||||
rangeRadioValue: null,
|
||||
contentRadioValue: null,
|
||||
};
|
||||
|
||||
handlePin = () => {
|
||||
|
@ -117,7 +141,14 @@ class AntennaSetting extends PureComponent {
|
|||
handleEditClick = () => {
|
||||
this.props.dispatch(openModal({
|
||||
modalType: 'ANTENNA_EDITOR',
|
||||
modalProps: { antennaId: this.props.params.id },
|
||||
modalProps: { antennaId: this.props.params.id, isExclude: false },
|
||||
}));
|
||||
};
|
||||
|
||||
handleExcludeEditClick = () => {
|
||||
this.props.dispatch(openModal({
|
||||
modalType: 'ANTENNA_EDITOR',
|
||||
modalProps: { antennaId: this.props.params.id, isExclude: true },
|
||||
}));
|
||||
};
|
||||
|
||||
|
@ -181,8 +212,14 @@ class AntennaSetting extends PureComponent {
|
|||
dispatch(updateAntenna(id, undefined, false, value.value, undefined, undefined, undefined, undefined));
|
||||
};
|
||||
|
||||
onHomeSelect = () => this.onSelect({ value: '0' });
|
||||
|
||||
noOptionsMessage = () => this.props.intl.formatMessage(messages.noOptions);
|
||||
|
||||
onRangeRadioChanged = (value) => this.setState({ rangeRadioValue: value });
|
||||
|
||||
onContentRadioChanged = (value) => this.setState({ contentRadioValue: value });
|
||||
|
||||
onDomainNameChanged = (value) => this.setState({ domainName: value });
|
||||
|
||||
onDomainAdd = () => {
|
||||
|
@ -201,6 +238,24 @@ class AntennaSetting extends PureComponent {
|
|||
|
||||
onKeywordRemove = (value) => this.props.dispatch(removeKeywordFromAntenna(this.props.params.id, value));
|
||||
|
||||
onExcludeDomainNameChanged = (value) => this.setState({ excludeDomainName: value });
|
||||
|
||||
onExcludeDomainAdd = () => {
|
||||
this.props.dispatch(addExcludeDomainToAntenna(this.props.params.id, this.state.excludeDomainName));
|
||||
this.setState({ excludeDomainName: '' });
|
||||
};
|
||||
|
||||
onExcludeDomainRemove = (value) => this.props.dispatch(removeExcludeDomainFromAntenna(this.props.params.id, value));
|
||||
|
||||
onExcludeKeywordNameChanged = (value) => this.setState({ excludeKeywordName: value });
|
||||
|
||||
onExcludeKeywordAdd = () => {
|
||||
this.props.dispatch(addExcludeKeywordToAntenna(this.props.params.id, this.state.excludeKeywordName));
|
||||
this.setState({ excludeKeywordName: '' });
|
||||
};
|
||||
|
||||
onExcludeKeywordRemove = (value) => this.props.dispatch(removeExcludeKeywordFromAntenna(this.props.params.id, value));
|
||||
|
||||
render () {
|
||||
const { columnId, multiColumn, antenna, lists, domains, keywords, intl } = this.props;
|
||||
const { id } = this.props.params;
|
||||
|
@ -255,7 +310,21 @@ class AntennaSetting extends PureComponent {
|
|||
);
|
||||
}
|
||||
|
||||
const listOptions = lists.toArray().map((list) => {
|
||||
const rangeRadioValues = ImmutableList([
|
||||
ImmutableMap({ value: 'accounts', label: intl.formatMessage(messages.accounts, { count: antenna.get('accounts_count') }) }),
|
||||
ImmutableMap({ value: 'domains', label: intl.formatMessage(messages.domains, { count: antenna.get('domains_count') }) }),
|
||||
]);
|
||||
const rangeRadioValue = ImmutableMap({ value: this.state.rangeRadioValue || (antenna.get('domains_count') > 0 ? 'domains' : 'accounts') });
|
||||
const rangeRadioAlert = antenna.get(rangeRadioValue.get('value') === 'accounts' ? 'domains_count' : 'accounts_count') > 0;
|
||||
|
||||
const contentRadioValues = ImmutableList([
|
||||
ImmutableMap({ value: 'keywords', label: intl.formatMessage(messages.keywords, { count: antenna.get('keywords_count') }) }),
|
||||
ImmutableMap({ value: 'tags', label: intl.formatMessage(messages.tags, { count: antenna.get('tags_count') }) }),
|
||||
]);
|
||||
const contentRadioValue = ImmutableMap({ value: this.state.contentRadioValue || (antenna.get('tags_count') > 0 ? 'tags' : 'keywords') });
|
||||
const contentRadioAlert = antenna.get(contentRadioValue.get('value') === 'tags' ? 'keywords_count' : 'tags_count') > 0;
|
||||
|
||||
const listOptions = lists.toArray().filter((list) => list.length >= 2 && list[1]).map((list) => {
|
||||
return { value: list[1].get('id'), label: list[1].get('title') }
|
||||
});
|
||||
|
||||
|
@ -317,42 +386,78 @@ class AntennaSetting extends PureComponent {
|
|||
options={listOptions}
|
||||
noOptionsMessage={this.noOptionsMessage}
|
||||
onChange={this.onSelect}
|
||||
className='column-select__container'
|
||||
classNamePrefix='column-select'
|
||||
className='column-content-select__container'
|
||||
classNamePrefix='column-content-select'
|
||||
name='lists'
|
||||
placeholder={this.props.intl.formatMessage(messages.placeholder)}
|
||||
defaultOptions
|
||||
/>
|
||||
</NonceProvider>
|
||||
|
||||
<Button secondary text={this.props.intl.formatMessage(messages.setHome)} onClick={this.onHomeSelect} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{!isStl && (
|
||||
<>
|
||||
<h3><FormattedMessage id='antennas.accounts' defaultMessage='{count} accounts' values={{ count: antenna.get('accounts_count') }} /></h3>
|
||||
<Button text={intl.formatMessage(messages.editAccounts)} onClick={this.handleEditClick} />
|
||||
<h2><FormattedMessage id='antennas.filter' defaultMessage='Filter' /></h2>
|
||||
<RadioPanel values={rangeRadioValues} value={rangeRadioValue} onChange={this.onRangeRadioChanged} />
|
||||
|
||||
<h3><FormattedMessage id='antennas.domains' defaultMessage='{count} domains' values={{ count: antenna.get('domains_count') }} /></h3>
|
||||
{rangeRadioValue.get('value') === 'accounts' && <Button text={intl.formatMessage(messages.editAccounts)} onClick={this.handleEditClick} />}
|
||||
|
||||
{rangeRadioValue.get('value') === 'domains' && (
|
||||
<TextList
|
||||
onChange={this.onDomainNameChanged}
|
||||
onAdd={this.onDomainAdd}
|
||||
onRemove={this.onDomainRemove}
|
||||
value={this.state.domainName}
|
||||
values={domains.get('domains') || ImmutableList()}
|
||||
icon='sitemap'
|
||||
label={intl.formatMessage(messages.addDomainLabel)}
|
||||
title={intl.formatMessage(messages.addDomainTitle)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{rangeRadioAlert && <div className='alert'><FormattedMessage id='antennas.warnings.range_radio' defaultMessage='Simultaneous account and domain designation is not recommended.' /></div>}
|
||||
|
||||
<RadioPanel values={contentRadioValues} value={contentRadioValue} onChange={this.onContentRadioChanged} />
|
||||
|
||||
{contentRadioValue.get('value') === 'keywords' && (
|
||||
<TextList
|
||||
onChange={this.onKeywordNameChanged}
|
||||
onAdd={this.onKeywordAdd}
|
||||
onRemove={this.onKeywordRemove}
|
||||
value={this.state.keywordName}
|
||||
values={keywords.get('keywords') || ImmutableList()}
|
||||
icon='paragraph'
|
||||
label={intl.formatMessage(messages.addKeywordLabel)}
|
||||
title={intl.formatMessage(messages.addKeywordTitle)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{contentRadioAlert && <div className='alert'><FormattedMessage id='antennas.warnings.content_radio' defaultMessage='Simultaneous keyword and tag designation is not recommended.' /></div>}
|
||||
|
||||
<h2><FormattedMessage id='antennas.filter_not' defaultMessage='Filter Not' /></h2>
|
||||
<h3><FormattedMessage id='antennas.exclude_accounts' defaultMessage='Exclude accounts' /></h3>
|
||||
<Button text={intl.formatMessage(messages.editAccounts)} onClick={this.handleExcludeEditClick} />
|
||||
<h3><FormattedMessage id='antennas.exclude_domains' defaultMessage='Exclude domains' /></h3>
|
||||
<TextList
|
||||
onChange={this.onDomainNameChanged}
|
||||
onAdd={this.onDomainAdd}
|
||||
onRemove={this.onDomainRemove}
|
||||
value={this.state.domainName}
|
||||
values={domains.get('domains') || ImmutableList()}
|
||||
onChange={this.onExcludeDomainNameChanged}
|
||||
onAdd={this.onExcludeDomainAdd}
|
||||
onRemove={this.onExcludeDomainRemove}
|
||||
value={this.state.excludeDomainName}
|
||||
values={domains.get('exclude_domains') || ImmutableList()}
|
||||
icon='sitemap'
|
||||
label={intl.formatMessage(messages.addDomainLabel)}
|
||||
title={intl.formatMessage(messages.addDomainTitle)}
|
||||
/>
|
||||
|
||||
<h3><FormattedMessage id='antennas.tags' defaultMessage='{count} tags' values={{ count: antenna.get('tags_count') }} /></h3>
|
||||
|
||||
<h3><FormattedMessage id='antennas.keywords' defaultMessage='{count} keywords' values={{ count: antenna.get('keywords_count') }} /></h3>
|
||||
<h3><FormattedMessage id='antennas.exclude_keywords' defaultMessage='Exclude keywords' /></h3>
|
||||
<TextList
|
||||
onChange={this.onKeywordNameChanged}
|
||||
onAdd={this.onKeywordAdd}
|
||||
onRemove={this.onKeywordRemove}
|
||||
value={this.state.keywordName}
|
||||
values={keywords.get('keywords') || ImmutableList()}
|
||||
onChange={this.onExcludeKeywordNameChanged}
|
||||
onAdd={this.onExcludeKeywordAdd}
|
||||
onRemove={this.onExcludeKeywordRemove}
|
||||
value={this.state.excludeKeywordName}
|
||||
values={keywords.get('exclude_keywords') || ImmutableList()}
|
||||
icon='paragraph'
|
||||
label={intl.formatMessage(messages.addKeywordLabel)}
|
||||
title={intl.formatMessage(messages.addKeywordTitle)}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import { injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { Avatar } from '../../../components/avatar';
|
||||
import { DisplayName } from '../../../components/display_name';
|
||||
import { makeGetAccount } from '../../../selectors';
|
||||
|
||||
const makeMapStateToProps = () => {
|
||||
const getAccount = makeGetAccount();
|
||||
|
||||
const mapStateToProps = (state, { accountId }) => ({
|
||||
account: getAccount(state, accountId),
|
||||
});
|
||||
|
||||
return mapStateToProps;
|
||||
};
|
||||
|
||||
class Account extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
account: ImmutablePropTypes.map.isRequired,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { account } = this.props;
|
||||
return (
|
||||
<div className='account'>
|
||||
<div className='account__wrapper'>
|
||||
<div className='account__display-name'>
|
||||
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
|
||||
<DisplayName account={account} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(makeMapStateToProps)(injectIntl(Account));
|
|
@ -0,0 +1,72 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
|
||||
import { removeFromCircleAdder, addToCircleAdder } from '../../../actions/circles';
|
||||
import { IconButton } from '../../../components/icon_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
remove: { id: 'circles.account.remove', defaultMessage: 'Remove from circle' },
|
||||
add: { id: 'circles.account.add', defaultMessage: 'Add to circle' },
|
||||
});
|
||||
|
||||
const MapStateToProps = (state, { circleId, added }) => ({
|
||||
circle: state.get('circles').get(circleId),
|
||||
added: typeof added === 'undefined' ? state.getIn(['circleAdder', 'circles', 'items']).includes(circleId) : added,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch, { circleId }) => ({
|
||||
onRemove: () => dispatch(removeFromCircleAdder(circleId)),
|
||||
onAdd: () => dispatch(addToCircleAdder(circleId)),
|
||||
});
|
||||
|
||||
class Circle extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
circle: ImmutablePropTypes.map.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onRemove: PropTypes.func.isRequired,
|
||||
onAdd: PropTypes.func.isRequired,
|
||||
added: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
added: false,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { circle, intl, onRemove, onAdd, added } = this.props;
|
||||
|
||||
let button;
|
||||
|
||||
if (added) {
|
||||
button = <IconButton icon='times' title={intl.formatMessage(messages.remove)} onClick={onRemove} />;
|
||||
} else {
|
||||
button = <IconButton icon='plus' title={intl.formatMessage(messages.add)} onClick={onAdd} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='list'>
|
||||
<div className='list__wrapper'>
|
||||
<div className='list__display-name'>
|
||||
<Icon id='user-circle' className='column-link__icon' fixedWidth />
|
||||
{circle.get('title')}
|
||||
</div>
|
||||
|
||||
<div className='account__relationship'>
|
||||
{button}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(MapStateToProps, mapDispatchToProps)(injectIntl(Circle));
|
76
app/javascript/mastodon/features/circle_adder/index.jsx
Normal file
76
app/javascript/mastodon/features/circle_adder/index.jsx
Normal file
|
@ -0,0 +1,76 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
import { setupCircleAdder, resetCircleAdder } from '../../actions/circles';
|
||||
import NewCircleForm from '../circles/components/new_circle_form';
|
||||
|
||||
import Account from './components/account';
|
||||
import Circle from './components/circle';
|
||||
// hack
|
||||
|
||||
const getOrderedCircles = createSelector([state => state.get('circles')], circles => {
|
||||
if (!circles) {
|
||||
return circles;
|
||||
}
|
||||
|
||||
return circles.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title')));
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
circleIds: getOrderedCircles(state).map(circle=>circle.get('id')),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onInitialize: accountId => dispatch(setupCircleAdder(accountId)),
|
||||
onReset: () => dispatch(resetCircleAdder()),
|
||||
});
|
||||
|
||||
class CircleAdder extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
accountId: PropTypes.string.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onInitialize: PropTypes.func.isRequired,
|
||||
onReset: PropTypes.func.isRequired,
|
||||
circleIds: ImmutablePropTypes.list.isRequired,
|
||||
};
|
||||
|
||||
componentDidMount () {
|
||||
const { onInitialize, accountId } = this.props;
|
||||
onInitialize(accountId);
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
const { onReset } = this.props;
|
||||
onReset();
|
||||
}
|
||||
|
||||
render () {
|
||||
const { accountId, circleIds } = this.props;
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal list-adder'>
|
||||
<div className='list-adder__account'>
|
||||
<Account accountId={accountId} />
|
||||
</div>
|
||||
|
||||
<NewCircleForm />
|
||||
|
||||
|
||||
<div className='list-adder__lists'>
|
||||
{circleIds.map(CircleId => <Circle key={CircleId} circleId={CircleId} />)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CircleAdder));
|
|
@ -0,0 +1,79 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { removeFromCircleEditor, addToCircleEditor } from '../../../actions/circles';
|
||||
import { Avatar } from '../../../components/avatar';
|
||||
import { DisplayName } from '../../../components/display_name';
|
||||
import { IconButton } from '../../../components/icon_button';
|
||||
import { makeGetAccount } from '../../../selectors';
|
||||
|
||||
const messages = defineMessages({
|
||||
remove: { id: 'circles.account.remove', defaultMessage: 'Remove from circle' },
|
||||
add: { id: 'circles.account.add', defaultMessage: 'Add to circle' },
|
||||
});
|
||||
|
||||
const makeMapStateToProps = () => {
|
||||
const getAccount = makeGetAccount();
|
||||
|
||||
const mapStateToProps = (state, { accountId, added }) => ({
|
||||
account: getAccount(state, accountId),
|
||||
added: typeof added === 'undefined' ? state.getIn(['circleEditor', 'accounts', 'items']).includes(accountId) : added,
|
||||
});
|
||||
|
||||
return mapStateToProps;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch, { accountId }) => ({
|
||||
onRemove: () => dispatch(removeFromCircleEditor(accountId)),
|
||||
onAdd: () => dispatch(addToCircleEditor(accountId)),
|
||||
});
|
||||
|
||||
class Account extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
account: ImmutablePropTypes.map.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onRemove: PropTypes.func.isRequired,
|
||||
onAdd: PropTypes.func.isRequired,
|
||||
added: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
added: false,
|
||||
};
|
||||
|
||||
render () {
|
||||
const { account, intl, onRemove, onAdd, added } = this.props;
|
||||
|
||||
let button;
|
||||
|
||||
if (added) {
|
||||
button = <IconButton icon='times' title={intl.formatMessage(messages.remove)} onClick={onRemove} />;
|
||||
} else {
|
||||
button = <IconButton icon='plus' title={intl.formatMessage(messages.add)} onClick={onAdd} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='account'>
|
||||
<div className='account__wrapper'>
|
||||
<div className='account__display-name'>
|
||||
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
|
||||
<DisplayName account={account} />
|
||||
</div>
|
||||
|
||||
<div className='account__relationship'>
|
||||
{button}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(makeMapStateToProps, mapDispatchToProps)(injectIntl(Account));
|
|
@ -0,0 +1,73 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { changeCircleEditorTitle, submitCircleEditor } from '../../../actions/circles';
|
||||
import { IconButton } from '../../../components/icon_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'circles.edit.submit', defaultMessage: 'Change title' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
value: state.getIn(['circleEditor', 'title']),
|
||||
disabled: !state.getIn(['circleEditor', 'isChanged']) || !state.getIn(['circleEditor', 'title']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onChange: value => dispatch(changeCircleEditorTitle(value)),
|
||||
onSubmit: () => dispatch(submitCircleEditor(false)),
|
||||
});
|
||||
|
||||
class CircleForm extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
value: PropTypes.string.isRequired,
|
||||
disabled: PropTypes.bool,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
handleChange = e => {
|
||||
this.props.onChange(e.target.value);
|
||||
};
|
||||
|
||||
handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
this.props.onSubmit();
|
||||
};
|
||||
|
||||
handleClick = () => {
|
||||
this.props.onSubmit();
|
||||
};
|
||||
|
||||
render () {
|
||||
const { value, disabled, intl } = this.props;
|
||||
|
||||
const title = intl.formatMessage(messages.title);
|
||||
|
||||
return (
|
||||
<form className='column-inline-form' onSubmit={this.handleSubmit}>
|
||||
<input
|
||||
className='setting-text'
|
||||
value={value}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
|
||||
<IconButton
|
||||
disabled={disabled}
|
||||
icon='check'
|
||||
title={title}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CircleForm));
|
|
@ -0,0 +1,81 @@
|
|||
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 { Icon } from 'mastodon/components/icon';
|
||||
|
||||
import { fetchCircleSuggestions, clearCircleSuggestions, changeCircleSuggestions } from '../../../actions/circles';
|
||||
|
||||
const messages = defineMessages({
|
||||
search: { id: 'circles.search', defaultMessage: 'Search among people you follow' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
value: state.getIn(['circleEditor', 'suggestions', 'value']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onSubmit: value => dispatch(fetchCircleSuggestions(value)),
|
||||
onClear: () => dispatch(clearCircleSuggestions()),
|
||||
onChange: value => dispatch(changeCircleSuggestions(value)),
|
||||
});
|
||||
|
||||
class Search extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
value: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
onClear: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
handleChange = e => {
|
||||
this.props.onChange(e.target.value);
|
||||
};
|
||||
|
||||
handleKeyUp = e => {
|
||||
if (e.keyCode === 13) {
|
||||
this.props.onSubmit(this.props.value);
|
||||
}
|
||||
};
|
||||
|
||||
handleClear = () => {
|
||||
this.props.onClear();
|
||||
};
|
||||
|
||||
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.search)}</span>
|
||||
|
||||
<input
|
||||
className='search__input'
|
||||
type='text'
|
||||
value={value}
|
||||
onChange={this.handleChange}
|
||||
onKeyUp={this.handleKeyUp}
|
||||
placeholder={intl.formatMessage(messages.search)}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div role='button' tabIndex={0} className='search__icon' onClick={this.handleClear}>
|
||||
<Icon id='search' className={classNames({ active: !hasValue })} />
|
||||
<Icon id='times-circle' aria-label={intl.formatMessage(messages.search)} className={classNames({ active: hasValue })} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(Search));
|
83
app/javascript/mastodon/features/circle_editor/index.jsx
Normal file
83
app/javascript/mastodon/features/circle_editor/index.jsx
Normal file
|
@ -0,0 +1,83 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import spring from 'react-motion/lib/spring';
|
||||
|
||||
import { setupCircleEditor, clearCircleSuggestions, resetCircleEditor } from '../../actions/circles';
|
||||
import Motion from '../ui/util/optional_motion';
|
||||
|
||||
import Account from './components/account';
|
||||
import EditCircleForm from './components/edit_circle_form';
|
||||
import Search from './components/search';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
accountIds: state.getIn(['circleEditor', 'accounts', 'items']),
|
||||
searchAccountIds: state.getIn(['circleEditor', 'suggestions', 'items']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onInitialize: circleId => dispatch(setupCircleEditor(circleId)),
|
||||
onClear: () => dispatch(clearCircleSuggestions()),
|
||||
onReset: () => dispatch(resetCircleEditor()),
|
||||
});
|
||||
|
||||
class CircleEditor extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
circleId: PropTypes.string.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onInitialize: PropTypes.func.isRequired,
|
||||
onClear: PropTypes.func.isRequired,
|
||||
onReset: PropTypes.func.isRequired,
|
||||
accountIds: ImmutablePropTypes.list.isRequired,
|
||||
searchAccountIds: ImmutablePropTypes.list.isRequired,
|
||||
};
|
||||
|
||||
componentDidMount () {
|
||||
const { onInitialize, circleId } = this.props;
|
||||
onInitialize(circleId);
|
||||
}
|
||||
|
||||
componentWillUnmount () {
|
||||
const { onReset } = this.props;
|
||||
onReset();
|
||||
}
|
||||
|
||||
render () {
|
||||
const { accountIds, searchAccountIds, onClear } = this.props;
|
||||
const showSearch = searchAccountIds.size > 0;
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal list-editor'>
|
||||
<EditCircleForm />
|
||||
|
||||
<Search />
|
||||
|
||||
<div className='drawer__pager'>
|
||||
<div className='drawer__inner list-editor__accounts'>
|
||||
{accountIds.map(accountId => <Account key={accountId} accountId={accountId} added />)}
|
||||
</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>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CircleEditor));
|
|
@ -0,0 +1,80 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { changeCircleEditorTitle, submitCircleEditor } from 'mastodon/actions/circles';
|
||||
import Button from 'mastodon/components/button';
|
||||
|
||||
const messages = defineMessages({
|
||||
label: { id: 'circles.new.title_placeholder', defaultMessage: 'New circle title' },
|
||||
title: { id: 'circles.new.create', defaultMessage: 'Add circle' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
value: state.getIn(['circleEditor', 'title']),
|
||||
disabled: state.getIn(['circleEditor', 'isSubmitting']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onChange: value => dispatch(changeCircleEditorTitle(value)),
|
||||
onSubmit: () => dispatch(submitCircleEditor(true)),
|
||||
});
|
||||
|
||||
class NewCircleForm extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
value: PropTypes.string.isRequired,
|
||||
disabled: PropTypes.bool,
|
||||
intl: PropTypes.object.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
handleChange = e => {
|
||||
this.props.onChange(e.target.value);
|
||||
};
|
||||
|
||||
handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
this.props.onSubmit();
|
||||
};
|
||||
|
||||
handleClick = () => {
|
||||
this.props.onSubmit();
|
||||
};
|
||||
|
||||
render () {
|
||||
const { value, disabled, intl } = this.props;
|
||||
|
||||
const label = intl.formatMessage(messages.label);
|
||||
const title = intl.formatMessage(messages.title);
|
||||
|
||||
return (
|
||||
<form className='column-inline-form' onSubmit={this.handleSubmit}>
|
||||
<label>
|
||||
<span style={{ display: 'none' }}>{label}</span>
|
||||
|
||||
<input
|
||||
className='setting-text'
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onChange={this.handleChange}
|
||||
placeholder={label}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<Button
|
||||
disabled={disabled || !value}
|
||||
text={title}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(NewCircleForm));
|
126
app/javascript/mastodon/features/circles/index.jsx
Normal file
126
app/javascript/mastodon/features/circles/index.jsx
Normal file
|
@ -0,0 +1,126 @@
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||
|
||||
import { Helmet } from 'react-helmet';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
import { fetchCircles, deleteCircle } from 'mastodon/actions/circles';
|
||||
import { openModal } from 'mastodon/actions/modal';
|
||||
import Column from 'mastodon/components/column';
|
||||
import ColumnHeader from 'mastodon/components/column_header';
|
||||
import { IconButton } from 'mastodon/components/icon_button';
|
||||
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
|
||||
import ScrollableList from 'mastodon/components/scrollable_list';
|
||||
import ColumnLink from 'mastodon/features/ui/components/column_link';
|
||||
import ColumnSubheading from 'mastodon/features/ui/components/column_subheading';
|
||||
|
||||
import NewCircleForm from './components/new_circle_form';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.circles', defaultMessage: 'Circles' },
|
||||
subheading: { id: 'circles.subheading', defaultMessage: 'Your circles' },
|
||||
deleteMessage: { id: 'circles.subheading', defaultMessage: 'Your circles' },
|
||||
deleteConfirm: { id: 'circles.subheading', defaultMessage: 'Your circles' },
|
||||
});
|
||||
|
||||
const getOrderedCircles = createSelector([state => state.get('circles')], circles => {
|
||||
if (!circles) {
|
||||
return circles;
|
||||
}
|
||||
|
||||
return circles.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title')));
|
||||
});
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
circles: getOrderedCircles(state),
|
||||
});
|
||||
|
||||
class Circles extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
params: PropTypes.object.isRequired,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
circles: ImmutablePropTypes.list,
|
||||
intl: PropTypes.object.isRequired,
|
||||
multiColumn: PropTypes.bool,
|
||||
};
|
||||
|
||||
UNSAFE_componentWillMount () {
|
||||
this.props.dispatch(fetchCircles());
|
||||
}
|
||||
|
||||
handleEditClick = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.dispatch(openModal({
|
||||
modalType: 'CIRCLE_EDITOR',
|
||||
modalProps: { circleId: e.currentTarget.getAttribute('data-id') },
|
||||
}));
|
||||
};
|
||||
|
||||
handleRemoveClick = (e) => {
|
||||
const { dispatch, intl } = this.props;
|
||||
|
||||
e.preventDefault();
|
||||
const id = e.currentTarget.getAttribute('data-id');
|
||||
|
||||
dispatch(openModal({
|
||||
modalType: 'CONFIRM',
|
||||
modalProps: {
|
||||
message: intl.formatMessage(messages.deleteMessage),
|
||||
confirm: intl.formatMessage(messages.deleteConfirm),
|
||||
onConfirm: () => {
|
||||
dispatch(deleteCircle(id));
|
||||
},
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
render () {
|
||||
const { intl, circles, multiColumn } = this.props;
|
||||
|
||||
if (!circles) {
|
||||
return (
|
||||
<Column>
|
||||
<LoadingIndicator />
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
const emptyMessage = <FormattedMessage id='empty_column.circles' defaultMessage="You don't have any circles yet. When you create one, it will show up here." />;
|
||||
|
||||
return (
|
||||
<Column bindToDocument={!multiColumn} label={intl.formatMessage(messages.heading)}>
|
||||
<ColumnHeader title={intl.formatMessage(messages.heading)} icon='user-circle' multiColumn={multiColumn} />
|
||||
|
||||
<NewCircleForm />
|
||||
|
||||
<ScrollableList
|
||||
scrollKey='circles'
|
||||
emptyMessage={emptyMessage}
|
||||
prepend={<ColumnSubheading text={intl.formatMessage(messages.subheading)} />}
|
||||
bindToDocument={!multiColumn}
|
||||
>
|
||||
{circles.map(circle =>
|
||||
(<div key={circle.get('id')} className='circle-item'>
|
||||
<ColumnLink to={`#`} data-id={circle.get('id')} onClick={this.handleEditClick} icon='user-circle' text={circle.get('title')} />
|
||||
<IconButton icon='trash' data_id={circle.get('id')} onClick={this.handleRemoveClick} />
|
||||
</div>)
|
||||
)}
|
||||
</ScrollableList>
|
||||
|
||||
<Helmet>
|
||||
<title>{intl.formatMessage(messages.heading)}</title>
|
||||
<meta name='robots' content='noindex' />
|
||||
</Helmet>
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(injectIntl(Circles));
|
|
@ -0,0 +1,59 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import { PureComponent } from 'react';
|
||||
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
|
||||
|
||||
import Select, { NonceProvider } from 'react-select';
|
||||
|
||||
class CircleSelect extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
unavailable: PropTypes.bool,
|
||||
intl: PropTypes.object.isRequired,
|
||||
circles: ImmutablePropTypes.list,
|
||||
circleId: PropTypes.string,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
handleClick = value => {
|
||||
this.props.onChange(value.value);
|
||||
};
|
||||
|
||||
noOptionsMessage = () => '';
|
||||
|
||||
render () {
|
||||
const { unavailable, circles, circleId } = this.props;
|
||||
|
||||
if (unavailable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const listOptions = circles.toArray().filter((circle) => circle[1]).map((circle) => {
|
||||
return { value: circle[1].get('id'), label: circle[1].get('title') };
|
||||
});
|
||||
const listValue = listOptions.find((opt) => opt.value === circleId);
|
||||
|
||||
return (
|
||||
<div className='compose-form__circle-select'>
|
||||
<NonceProvider nonce={document.querySelector('meta[name=style-nonce]').content} cacheKey='circles'>
|
||||
<Select
|
||||
value={listValue}
|
||||
options={listOptions}
|
||||
noOptionsMessage={this.noOptionsMessage}
|
||||
onChange={this.handleClick}
|
||||
className='column-content-select__container'
|
||||
classNamePrefix='column-content-select'
|
||||
name='circles'
|
||||
defaultOptions
|
||||
/>
|
||||
</NonceProvider>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default injectIntl(CircleSelect);
|
|
@ -14,6 +14,7 @@ import { Icon } from 'mastodon/components/icon';
|
|||
import AutosuggestInput from '../../../components/autosuggest_input';
|
||||
import AutosuggestTextarea from '../../../components/autosuggest_textarea';
|
||||
import Button from '../../../components/button';
|
||||
import CircleSelectContainer from '../containers/circle_select_container';
|
||||
import EmojiPickerDropdown from '../containers/emoji_picker_dropdown_container';
|
||||
import ExpirationDropdownContainer from '../containers/expiration_dropdown_container';
|
||||
import LanguageDropdown from '../containers/language_dropdown_container';
|
||||
|
@ -76,6 +77,7 @@ class ComposeForm extends ImmutablePureComponent {
|
|||
isInReply: PropTypes.bool,
|
||||
singleColumn: PropTypes.bool,
|
||||
lang: PropTypes.string,
|
||||
circleId: PropTypes.string,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
@ -101,11 +103,11 @@ class ComposeForm extends ImmutablePureComponent {
|
|||
};
|
||||
|
||||
canSubmit = () => {
|
||||
const { isSubmitting, isChangingUpload, isUploading, anyMedia } = this.props;
|
||||
const { isSubmitting, isChangingUpload, isUploading, anyMedia, privacy, circleId } = this.props;
|
||||
const fulltext = this.getFulltextForCharacterCounting();
|
||||
const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;
|
||||
|
||||
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia));
|
||||
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia) || (privacy === 'circle' && !circleId));
|
||||
};
|
||||
|
||||
handleSubmit = (e) => {
|
||||
|
@ -317,6 +319,8 @@ class ComposeForm extends ImmutablePureComponent {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<CircleSelectContainer />
|
||||
|
||||
<div className='compose-form__publish'>
|
||||
<div className='compose-form__publish-button-wrapper'>
|
||||
<Button
|
||||
|
|
|
@ -26,6 +26,8 @@ const messages = defineMessages({
|
|||
private_long: { id: 'privacy.private.long', defaultMessage: 'Visible for followers only' },
|
||||
mutual_short: { id: 'privacy.mutual.short', defaultMessage: 'Mutual' },
|
||||
mutual_long: { id: 'privacy.mutual.long', defaultMessage: 'Mutual follows only' },
|
||||
circle_short: { id: 'privacy.circle.short', defaultMessage: 'Circle' },
|
||||
circle_long: { id: 'privacy.circle.long', defaultMessage: 'Circle members only' },
|
||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Mentioned people only' },
|
||||
direct_long: { id: 'privacy.direct.long', defaultMessage: 'Visible for mentioned users only' },
|
||||
change_privacy: { id: 'privacy.change', defaultMessage: 'Adjust status privacy' },
|
||||
|
@ -235,6 +237,7 @@ class PrivacyDropdown extends PureComponent {
|
|||
{ icon: 'unlock', value: 'unlisted', text: formatMessage(messages.unlisted_short), meta: formatMessage(messages.unlisted_long) },
|
||||
{ icon: 'lock', value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) },
|
||||
{ icon: 'exchange', value: 'mutual', text: formatMessage(messages.mutual_short), meta: formatMessage(messages.mutual_long) },
|
||||
{ icon: 'user-circle', value: 'circle', text: formatMessage(messages.circle_short), meta: formatMessage(messages.circle_long) },
|
||||
{ icon: 'at', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
||||
];
|
||||
this.selectableOptions = [...this.options];
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { changeCircle } from '../../../actions/compose';
|
||||
import CircleSelect from '../components/circle_select';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
unavailable: state.getIn(['compose', 'privacy']) !== 'circle',
|
||||
circles: state.get('circles'),
|
||||
circleId: state.getIn(['compose', 'circle_id']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
||||
onChange (circleId) {
|
||||
dispatch(changeCircle(circleId));
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(CircleSelect);
|
|
@ -30,6 +30,7 @@ const mapStateToProps = state => ({
|
|||
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
|
||||
isInReply: state.getIn(['compose', 'in_reply_to']) !== null,
|
||||
lang: state.getIn(['compose', 'language']),
|
||||
circleId: state.getIn(['compose', 'circle_id']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
|
|
|
@ -11,10 +11,10 @@ import Warning from '../components/warning';
|
|||
|
||||
const mapStateToProps = state => ({
|
||||
needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']),
|
||||
hashtagWarning: ['public', 'public_unlisted', 'login'].indexOf(state.getIn(['compose', 'privacy'])) < 0 && state.getIn(['compose', 'searchability']) !== 'public' && HASHTAG_PATTERN_REGEX.test(state.getIn(['compose', 'text'])),
|
||||
hashtagWarning: !['public', 'public_unlisted', 'login'].includes(state.getIn(['compose', 'privacy'])) && state.getIn(['compose', 'searchability']) !== 'public' && HASHTAG_PATTERN_REGEX.test(state.getIn(['compose', 'text'])),
|
||||
directMessageWarning: state.getIn(['compose', 'privacy']) === 'direct',
|
||||
searchabilityWarning: state.getIn(['compose', 'searchability']) === 'limited',
|
||||
limitedPostWarning: state.getIn(['compose', 'privacy']) === 'mutual',
|
||||
limitedPostWarning: ['mutual', 'circle'].includes(state.getIn(['compose', 'privacy'])),
|
||||
});
|
||||
|
||||
const WarningWrapper = ({ needsLockWarning, hashtagWarning, directMessageWarning, searchabilityWarning, limitedPostWarning }) => {
|
||||
|
|
|
@ -22,6 +22,7 @@ const messages = defineMessages({
|
|||
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers only' },
|
||||
limited_short: { id: 'privacy.limited.short', defaultMessage: 'Limited menbers only' },
|
||||
mutual_short: { id: 'privacy.mutual.short', defaultMessage: 'Mutual followers only' },
|
||||
circle_short: { id: 'privacy.circle.short', defaultMessage: 'Circle members only' },
|
||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Mentioned people only' },
|
||||
});
|
||||
|
||||
|
@ -55,6 +56,7 @@ class StatusCheckBox extends PureComponent {
|
|||
'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
|
||||
'limited': { icon: 'get-pocket', text: intl.formatMessage(messages.limited_short) },
|
||||
'mutual': { icon: 'exchange', text: intl.formatMessage(messages.mutual_short) },
|
||||
'circle': { icon: 'user-circle', text: intl.formatMessage(messages.circle_short) },
|
||||
'direct': { icon: 'at', text: intl.formatMessage(messages.direct_short) },
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ const messages = defineMessages({
|
|||
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers only' },
|
||||
limited_short: { id: 'privacy.limited.short', defaultMessage: 'Limited menbers only' },
|
||||
mutual_short: { id: 'privacy.mutual.short', defaultMessage: 'Mutual followers only' },
|
||||
circle_short: { id: 'privacy.circle.short', defaultMessage: 'Circle members only' },
|
||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Mentioned people only' },
|
||||
searchability_public_short: { id: 'searchability.public.short', defaultMessage: 'Public' },
|
||||
searchability_private_short: { id: 'searchability.unlisted.short', defaultMessage: 'Followers' },
|
||||
|
@ -256,6 +257,7 @@ class DetailedStatus extends ImmutablePureComponent {
|
|||
'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
|
||||
'limited': { icon: 'get-pocket', text: intl.formatMessage(messages.limited_short) },
|
||||
'mutual': { icon: 'exchange', text: intl.formatMessage(messages.mutual_short) },
|
||||
'circle': { icon: 'user-circle', text: intl.formatMessage(messages.circle_short) },
|
||||
'direct': { icon: 'at', text: intl.formatMessage(messages.direct_short) },
|
||||
};
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ const messages = defineMessages({
|
|||
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers only' },
|
||||
limited_short: { id: 'privacy.limited.short', defaultMessage: 'Limited menbers only' },
|
||||
mutual_short: { id: 'privacy.mutual.short', defaultMessage: 'Mutual followers only' },
|
||||
circle_short: { id: 'privacy.circle.short', defaultMessage: 'Circle members only' },
|
||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Mentioned people only' },
|
||||
});
|
||||
|
||||
|
@ -98,6 +99,7 @@ class BoostModal extends ImmutablePureComponent {
|
|||
'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
|
||||
'limited': { icon: 'get-pocket', text: intl.formatMessage(messages.limited_short) },
|
||||
'mutual': { icon: 'exchange', text: intl.formatMessage(messages.mutual_short) },
|
||||
'circle': { icon: 'user-circle', text: intl.formatMessage(messages.circle_short) },
|
||||
'direct': { icon: 'at', text: intl.formatMessage(messages.direct_short) },
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ import {
|
|||
ListAdder,
|
||||
AntennaEditor,
|
||||
AntennaAdder,
|
||||
CircleEditor,
|
||||
CircleAdder,
|
||||
CompareHistoryModal,
|
||||
FilterModal,
|
||||
InteractionModal,
|
||||
|
@ -48,9 +50,11 @@ export const MODAL_COMPONENTS = {
|
|||
'EMBED': EmbedModal,
|
||||
'LIST_EDITOR': ListEditor,
|
||||
'ANTENNA_EDITOR': AntennaEditor,
|
||||
'CIRCLE_EDITOR': CircleEditor,
|
||||
'FOCAL_POINT': () => Promise.resolve({ default: FocalPointModal }),
|
||||
'LIST_ADDER': ListAdder,
|
||||
'ANTENNA_ADDER': AntennaAdder,
|
||||
'CIRCLE_ADDER': CircleAdder,
|
||||
'COMPARE_HISTORY': CompareHistoryModal,
|
||||
'FILTER': FilterModal,
|
||||
'SUBSCRIBED_LANGUAGES': SubscribedLanguagesModal,
|
||||
|
|
|
@ -28,6 +28,7 @@ const messages = defineMessages({
|
|||
bookmarks: { id: 'navigation_bar.bookmarks', defaultMessage: 'Bookmarks' },
|
||||
lists: { id: 'navigation_bar.lists', defaultMessage: 'Lists' },
|
||||
antennas: { id: 'navigation_bar.antennas', defaultMessage: 'Antennas' },
|
||||
circles: { id: 'navigation_bar.circles', defaultMessage: 'Circles' },
|
||||
preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
|
||||
followsAndFollowers: { id: 'navigation_bar.follows_and_followers', defaultMessage: 'Follows and followers' },
|
||||
about: { id: 'navigation_bar.about', defaultMessage: 'About' },
|
||||
|
@ -106,6 +107,7 @@ class NavigationPanel extends Component {
|
|||
<>
|
||||
<ColumnLink transparent to='/lists' icon='list-ul' text={intl.formatMessage(messages.lists)} />
|
||||
<ColumnLink transparent to='/antennasw' icon='wifi' text={intl.formatMessage(messages.antennas)} isActive={this.isAntennasActive} />
|
||||
<ColumnLink transparent to='/circles' icon='user-circle' text={intl.formatMessage(messages.circles)} />
|
||||
<FollowRequestsColumnLink />
|
||||
<ColumnLink transparent to='/conversations' icon='at' text={intl.formatMessage(messages.direct)} />
|
||||
</>
|
||||
|
|
|
@ -62,6 +62,7 @@ import {
|
|||
PinnedStatuses,
|
||||
Lists,
|
||||
Antennas,
|
||||
Circles,
|
||||
AntennaSetting,
|
||||
Directory,
|
||||
Explore,
|
||||
|
@ -254,6 +255,7 @@ class SwitchingColumnsArea extends PureComponent {
|
|||
<WrappedRoute path='/mutes' component={Mutes} content={children} />
|
||||
<WrappedRoute path='/lists' component={Lists} content={children} />
|
||||
<WrappedRoute path='/antennasw' component={Antennas} content={children} />
|
||||
<WrappedRoute path='/circles' component={Circles} content={children} />
|
||||
|
||||
<Route component={BundleColumnError} />
|
||||
</WrappedSwitch>
|
||||
|
|
|
@ -50,6 +50,10 @@ export function Antennas () {
|
|||
return import(/* webpackChunkName: "features/antennas" */'../../antennas');
|
||||
}
|
||||
|
||||
export function Circles () {
|
||||
return import(/* webpackChunkName: "features/circles" */'../../circles');
|
||||
}
|
||||
|
||||
export function Status () {
|
||||
return import(/* webpackChunkName: "features/status" */'../../status');
|
||||
}
|
||||
|
@ -170,6 +174,14 @@ export function AntennaEditor () {
|
|||
return import(/*webpackChunkName: "features/antenna_editor" */'../../antenna_editor');
|
||||
}
|
||||
|
||||
export function CircleAdder () {
|
||||
return import(/*webpackChunkName: "features/circle_adder" */'../../circle_adder');
|
||||
}
|
||||
|
||||
export function CircleEditor () {
|
||||
return import(/*webpackChunkName: "features/circle_editor" */'../../circle_editor');
|
||||
}
|
||||
|
||||
export function AntennaSetting () {
|
||||
return import(/*webpackChunkName: "features/antenna_setting" */'../../antenna_setting');
|
||||
}
|
||||
|
|
|
@ -88,12 +88,24 @@
|
|||
"alert.unexpected.message": "不明なエラーが発生しました。",
|
||||
"alert.unexpected.title": "エラー!",
|
||||
"announcement.announcement": "お知らせ",
|
||||
"antennas.account.add": "アンテナに追加",
|
||||
"antennas.account.remove": "アンテナから外す",
|
||||
"antennas.accounts": "{count} のアカウント",
|
||||
"antennas.add_domain": "新規ドメイン",
|
||||
"antennas.add_domain_placeholder": "新しいドメイン名",
|
||||
"antennas.add_keyword": "新規キーワード",
|
||||
"antennas.add_keyword_placeholder": "新しいキーワード",
|
||||
"antennas.delete": "アンテナを削除",
|
||||
"antennas.domains": "{count} のドメイン",
|
||||
"antennas.edit": "アンテナを編集",
|
||||
"antennas.edit.submit": "タイトルを変更",
|
||||
"antennas.edit_static": "旧編集画面に移動",
|
||||
"antennas.edit_accounts": "アカウントを編集",
|
||||
"antennas.exclude_accounts": "除外するアカウント",
|
||||
"antennas.exclude_domains": "除外するドメイン",
|
||||
"antennas.exclude_keywords": "除外するキーワード",
|
||||
"antennas.filter": "絞り込み条件",
|
||||
"antennas.filter_not": "絞り込み条件の例外",
|
||||
"antennas.go_timeline": "タイムラインを見る",
|
||||
"antennas.ignore_reblog": "ブーストを除外",
|
||||
"antennas.in_stl_mode": "STLモードが有効になっています",
|
||||
|
@ -107,9 +119,12 @@
|
|||
"antennas.search": "すべてのユーザーから検索",
|
||||
"antennas.select.no_options_message": "リストがありません",
|
||||
"antennas.select.placeholder": "リストを選択",
|
||||
"antennas.select.set_home": "リセット (ホームに関連付ける)",
|
||||
"antennas.subheading": "あなたのアンテナ",
|
||||
"antennas.stl": "STLモード",
|
||||
"antennas.tags": "{count} のタグ",
|
||||
"antennas.warnings.content_radio": "キーワードとタグの同時指定は推奨されません。",
|
||||
"antennas.warnings.range_radio": "アカウントとドメインの同時指定は推奨されません。",
|
||||
"attachments_list.unprocessed": "(未処理)",
|
||||
"audio.hide": "音声を閉じる",
|
||||
"autosuggest_hashtag.per_week": "{count} 回 / 週",
|
||||
|
|
|
@ -13,11 +13,16 @@ import {
|
|||
ANTENNA_ACCOUNTS_FETCH_REQUEST,
|
||||
ANTENNA_ACCOUNTS_FETCH_SUCCESS,
|
||||
ANTENNA_ACCOUNTS_FETCH_FAIL,
|
||||
ANTENNA_EXCLUDE_ACCOUNTS_FETCH_REQUEST,
|
||||
ANTENNA_EXCLUDE_ACCOUNTS_FETCH_SUCCESS,
|
||||
ANTENNA_EXCLUDE_ACCOUNTS_FETCH_FAIL,
|
||||
ANTENNA_EDITOR_SUGGESTIONS_READY,
|
||||
ANTENNA_EDITOR_SUGGESTIONS_CLEAR,
|
||||
ANTENNA_EDITOR_SUGGESTIONS_CHANGE,
|
||||
ANTENNA_EDITOR_ADD_SUCCESS,
|
||||
ANTENNA_EDITOR_REMOVE_SUCCESS,
|
||||
ANTENNA_EDITOR_ADD_EXCLUDE_SUCCESS,
|
||||
ANTENNA_EDITOR_REMOVE_EXCLUDE_SUCCESS,
|
||||
} from '../actions/antennas';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
|
@ -33,6 +38,12 @@ const initialState = ImmutableMap({
|
|||
isLoading: false,
|
||||
}),
|
||||
|
||||
excludeAccounts: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
suggestions: ImmutableMap({
|
||||
value: '',
|
||||
items: ImmutableList(),
|
||||
|
@ -80,6 +91,16 @@ export default function antennaEditorReducer(state = initialState, action) {
|
|||
map.set('loaded', true);
|
||||
map.set('items', ImmutableList(action.accounts.map(item => item.id)));
|
||||
}));
|
||||
case ANTENNA_EXCLUDE_ACCOUNTS_FETCH_REQUEST:
|
||||
return state.setIn(['excludeAccounts', 'isLoading'], true);
|
||||
case ANTENNA_EXCLUDE_ACCOUNTS_FETCH_FAIL:
|
||||
return state.setIn(['excludeAccounts', 'isLoading'], false);
|
||||
case ANTENNA_EXCLUDE_ACCOUNTS_FETCH_SUCCESS:
|
||||
return state.update('excludeAccounts', accounts => accounts.withMutations(map => {
|
||||
map.set('isLoading', false);
|
||||
map.set('loaded', true);
|
||||
map.set('items', ImmutableList(action.accounts.map(item => item.id)));
|
||||
}));
|
||||
case ANTENNA_EDITOR_SUGGESTIONS_CHANGE:
|
||||
return state.setIn(['suggestions', 'value'], action.value);
|
||||
case ANTENNA_EDITOR_SUGGESTIONS_READY:
|
||||
|
@ -93,6 +114,10 @@ export default function antennaEditorReducer(state = initialState, action) {
|
|||
return state.updateIn(['accounts', 'items'], antenna => antenna.unshift(action.accountId));
|
||||
case ANTENNA_EDITOR_REMOVE_SUCCESS:
|
||||
return state.updateIn(['accounts', 'items'], antenna => antenna.filterNot(item => item === action.accountId));
|
||||
case ANTENNA_EDITOR_ADD_EXCLUDE_SUCCESS:
|
||||
return state.updateIn(['excludeAccounts', 'items'], antenna => antenna.unshift(action.accountId));
|
||||
case ANTENNA_EDITOR_REMOVE_EXCLUDE_SUCCESS:
|
||||
return state.updateIn(['excludeAccounts', 'items'], antenna => antenna.filterNot(item => item === action.accountId));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -11,9 +11,13 @@ import {
|
|||
ANTENNA_EDITOR_REMOVE_SUCCESS,
|
||||
ANTENNA_EDITOR_ADD_DOMAIN_SUCCESS,
|
||||
ANTENNA_EDITOR_REMOVE_DOMAIN_SUCCESS,
|
||||
ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_SUCCESS,
|
||||
ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_SUCCESS,
|
||||
ANTENNA_EDITOR_FETCH_DOMAINS_SUCCESS,
|
||||
ANTENNA_EDITOR_ADD_KEYWORD_SUCCESS,
|
||||
ANTENNA_EDITOR_REMOVE_KEYWORD_SUCCESS,
|
||||
ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_SUCCESS,
|
||||
ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_SUCCESS,
|
||||
ANTENNA_EDITOR_FETCH_KEYWORDS_SUCCESS,
|
||||
} from '../actions/antennas';
|
||||
|
||||
|
@ -21,10 +25,16 @@ const initialState = ImmutableMap();
|
|||
|
||||
const normalizeAntenna = (state, antenna) => {
|
||||
const old = state.get(antenna.id);
|
||||
if (old === false) {
|
||||
return state;
|
||||
}
|
||||
|
||||
let s = state.set(antenna.id, fromJS(antenna));
|
||||
if (old) {
|
||||
s = s.setIn([antenna.id, 'domains'], old.get('domains'));
|
||||
s = s.setIn([antenna.id, 'exclude_domains'], old.get('exclude_domains'));
|
||||
s = s.setIn([antenna.id, 'keywords'], old.get('keywords'));
|
||||
s = s.setIn([antenna.id, 'exclude_keywords'], old.get('exclude_keywords'));
|
||||
s = s.setIn([antenna.id, 'accounts_count'], old.get('accounts_count'));
|
||||
s = s.setIn([antenna.id, 'domains_count'], old.get('domains_count'));
|
||||
s = s.setIn([antenna.id, 'keywords_count'], old.get('keywords_count'));
|
||||
|
@ -59,14 +69,22 @@ export default function antennas(state = initialState, action) {
|
|||
return state.setIn([action.antennaId, 'domains_count'], state.getIn([action.antennaId, 'domains_count']) + 1).updateIn([action.antennaId, 'domains', 'domains'], domains => (ImmutableList(domains || [])).push(action.domain));
|
||||
case ANTENNA_EDITOR_REMOVE_DOMAIN_SUCCESS:
|
||||
return state.setIn([action.antennaId, 'domains_count'], state.getIn([action.antennaId, 'domains_count']) - 1).updateIn([action.antennaId, 'domains', 'domains'], domains => (ImmutableList(domains || [])).filterNot(domain => domain === action.domain));
|
||||
case ANTENNA_EDITOR_ADD_EXCLUDE_DOMAIN_SUCCESS:
|
||||
return state.updateIn([action.antennaId, 'domains', 'exclude_domains'], domains => (ImmutableList(domains || [])).push(action.domain));
|
||||
case ANTENNA_EDITOR_REMOVE_EXCLUDE_DOMAIN_SUCCESS:
|
||||
return state.updateIn([action.antennaId, 'domains', 'exclude_domains'], domains => (ImmutableList(domains || [])).filterNot(domain => domain === action.domain));
|
||||
case ANTENNA_EDITOR_FETCH_DOMAINS_SUCCESS:
|
||||
return state.setIn([action.id, 'domains'], ImmutableMap(action.domains));
|
||||
return state.setIn([action.id, 'domains'], ImmutableMap({ domains: ImmutableList(action.domains.domains), exclude_domains: ImmutableList(action.domains.exclude_domains) }));
|
||||
case ANTENNA_EDITOR_ADD_KEYWORD_SUCCESS:
|
||||
return state.setIn([action.antennaId, 'keywords_count'], state.getIn([action.antennaId, 'keywords_count']) + 1).updateIn([action.antennaId, 'keywords', 'keywords'], keywords => (ImmutableList(keywords || [])).push(action.keyword));
|
||||
case ANTENNA_EDITOR_REMOVE_KEYWORD_SUCCESS:
|
||||
return state.setIn([action.antennaId, 'keywords_count'], state.getIn([action.antennaId, 'keywords_count']) - 1).updateIn([action.antennaId, 'keywords', 'keywords'], keywords => (ImmutableList(keywords || [])).filterNot(keyword => keyword === action.keyword));
|
||||
case ANTENNA_EDITOR_ADD_EXCLUDE_KEYWORD_SUCCESS:
|
||||
return state.updateIn([action.antennaId, 'keywords', 'exclude_keywords'], keywords => (ImmutableList(keywords || [])).push(action.keyword));
|
||||
case ANTENNA_EDITOR_REMOVE_EXCLUDE_KEYWORD_SUCCESS:
|
||||
return state.updateIn([action.antennaId, 'keywords', 'exclude_keywords'], keywords => (ImmutableList(keywords || [])).filterNot(keyword => keyword === action.keyword));
|
||||
case ANTENNA_EDITOR_FETCH_KEYWORDS_SUCCESS:
|
||||
return state.setIn([action.id, 'keywords'], ImmutableMap(action.keywords));
|
||||
return state.setIn([action.id, 'keywords'], ImmutableMap({ keywords: ImmutableList(action.keywords.keywords), exclude_keywords: ImmutableList(action.keywords.exclude_keywords) }));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
48
app/javascript/mastodon/reducers/circle_adder.js
Normal file
48
app/javascript/mastodon/reducers/circle_adder.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
|
||||
import {
|
||||
LIST_ADDER_RESET,
|
||||
LIST_ADDER_SETUP,
|
||||
LIST_ADDER_LISTS_FETCH_REQUEST,
|
||||
LIST_ADDER_LISTS_FETCH_SUCCESS,
|
||||
LIST_ADDER_LISTS_FETCH_FAIL,
|
||||
LIST_EDITOR_ADD_SUCCESS,
|
||||
LIST_EDITOR_REMOVE_SUCCESS,
|
||||
} from '../actions/lists';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
accountId: null,
|
||||
|
||||
lists: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
});
|
||||
|
||||
export default function listAdderReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case LIST_ADDER_RESET:
|
||||
return initialState;
|
||||
case LIST_ADDER_SETUP:
|
||||
return state.withMutations(map => {
|
||||
map.set('accountId', action.account.get('id'));
|
||||
});
|
||||
case LIST_ADDER_LISTS_FETCH_REQUEST:
|
||||
return state.setIn(['lists', 'isLoading'], true);
|
||||
case LIST_ADDER_LISTS_FETCH_FAIL:
|
||||
return state.setIn(['lists', 'isLoading'], false);
|
||||
case LIST_ADDER_LISTS_FETCH_SUCCESS:
|
||||
return state.update('lists', lists => lists.withMutations(map => {
|
||||
map.set('isLoading', false);
|
||||
map.set('loaded', true);
|
||||
map.set('items', ImmutableList(action.lists.map(item => item.id)));
|
||||
}));
|
||||
case LIST_EDITOR_ADD_SUCCESS:
|
||||
return state.updateIn(['lists', 'items'], list => list.unshift(action.listId));
|
||||
case LIST_EDITOR_REMOVE_SUCCESS:
|
||||
return state.updateIn(['lists', 'items'], list => list.filterNot(item => item === action.listId));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
99
app/javascript/mastodon/reducers/circle_editor.js
Normal file
99
app/javascript/mastodon/reducers/circle_editor.js
Normal file
|
@ -0,0 +1,99 @@
|
|||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
|
||||
import {
|
||||
CIRCLE_CREATE_REQUEST,
|
||||
CIRCLE_CREATE_FAIL,
|
||||
CIRCLE_CREATE_SUCCESS,
|
||||
CIRCLE_UPDATE_REQUEST,
|
||||
CIRCLE_UPDATE_FAIL,
|
||||
CIRCLE_UPDATE_SUCCESS,
|
||||
CIRCLE_EDITOR_RESET,
|
||||
CIRCLE_EDITOR_SETUP,
|
||||
CIRCLE_EDITOR_TITLE_CHANGE,
|
||||
CIRCLE_ACCOUNTS_FETCH_REQUEST,
|
||||
CIRCLE_ACCOUNTS_FETCH_SUCCESS,
|
||||
CIRCLE_ACCOUNTS_FETCH_FAIL,
|
||||
CIRCLE_EDITOR_SUGGESTIONS_READY,
|
||||
CIRCLE_EDITOR_SUGGESTIONS_CLEAR,
|
||||
CIRCLE_EDITOR_SUGGESTIONS_CHANGE,
|
||||
CIRCLE_EDITOR_ADD_SUCCESS,
|
||||
CIRCLE_EDITOR_REMOVE_SUCCESS,
|
||||
} from '../actions/circles';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
circleId: null,
|
||||
isSubmitting: false,
|
||||
isChanged: false,
|
||||
title: '',
|
||||
isExclusive: false,
|
||||
|
||||
accounts: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
suggestions: ImmutableMap({
|
||||
value: '',
|
||||
items: ImmutableList(),
|
||||
}),
|
||||
});
|
||||
|
||||
export default function circleEditorReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case CIRCLE_EDITOR_RESET:
|
||||
return initialState;
|
||||
case CIRCLE_EDITOR_SETUP:
|
||||
return state.withMutations(map => {
|
||||
map.set('circleId', action.circle.get('id'));
|
||||
map.set('title', action.circle.get('title'));
|
||||
map.set('isExclusive', action.circle.get('is_exclusive'));
|
||||
map.set('isSubmitting', false);
|
||||
});
|
||||
case CIRCLE_EDITOR_TITLE_CHANGE:
|
||||
return state.withMutations(map => {
|
||||
map.set('title', action.value);
|
||||
map.set('isChanged', true);
|
||||
});
|
||||
case CIRCLE_CREATE_REQUEST:
|
||||
case CIRCLE_UPDATE_REQUEST:
|
||||
return state.withMutations(map => {
|
||||
map.set('isSubmitting', true);
|
||||
map.set('isChanged', false);
|
||||
});
|
||||
case CIRCLE_CREATE_FAIL:
|
||||
case CIRCLE_UPDATE_FAIL:
|
||||
return state.set('isSubmitting', false);
|
||||
case CIRCLE_CREATE_SUCCESS:
|
||||
case CIRCLE_UPDATE_SUCCESS:
|
||||
return state.withMutations(map => {
|
||||
map.set('isSubmitting', false);
|
||||
map.set('circleId', action.circle.id);
|
||||
});
|
||||
case CIRCLE_ACCOUNTS_FETCH_REQUEST:
|
||||
return state.setIn(['accounts', 'isLoading'], true);
|
||||
case CIRCLE_ACCOUNTS_FETCH_FAIL:
|
||||
return state.setIn(['accounts', 'isLoading'], false);
|
||||
case CIRCLE_ACCOUNTS_FETCH_SUCCESS:
|
||||
return state.update('accounts', accounts => accounts.withMutations(map => {
|
||||
map.set('isLoading', false);
|
||||
map.set('loaded', true);
|
||||
map.set('items', ImmutableList(action.accounts.map(item => item.id)));
|
||||
}));
|
||||
case CIRCLE_EDITOR_SUGGESTIONS_CHANGE:
|
||||
return state.setIn(['suggestions', 'value'], action.value);
|
||||
case CIRCLE_EDITOR_SUGGESTIONS_READY:
|
||||
return state.setIn(['suggestions', 'items'], ImmutableList(action.accounts.map(item => item.id)));
|
||||
case CIRCLE_EDITOR_SUGGESTIONS_CLEAR:
|
||||
return state.update('suggestions', suggestions => suggestions.withMutations(map => {
|
||||
map.set('items', ImmutableList());
|
||||
map.set('value', '');
|
||||
}));
|
||||
case CIRCLE_EDITOR_ADD_SUCCESS:
|
||||
return state.updateIn(['accounts', 'items'], circle => circle.unshift(action.accountId));
|
||||
case CIRCLE_EDITOR_REMOVE_SUCCESS:
|
||||
return state.updateIn(['accounts', 'items'], circle => circle.filterNot(item => item === action.accountId));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
38
app/javascript/mastodon/reducers/circles.js
Normal file
38
app/javascript/mastodon/reducers/circles.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
import {
|
||||
CIRCLE_FETCH_SUCCESS,
|
||||
CIRCLE_FETCH_FAIL,
|
||||
CIRCLES_FETCH_SUCCESS,
|
||||
CIRCLE_CREATE_SUCCESS,
|
||||
CIRCLE_UPDATE_SUCCESS,
|
||||
CIRCLE_DELETE_SUCCESS,
|
||||
} from '../actions/circles';
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
const normalizeList = (state, circle) => state.set(circle.id, fromJS(circle));
|
||||
|
||||
const normalizeLists = (state, circles) => {
|
||||
circles.forEach(circle => {
|
||||
state = normalizeList(state, circle);
|
||||
});
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
export default function circles(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case CIRCLE_FETCH_SUCCESS:
|
||||
case CIRCLE_CREATE_SUCCESS:
|
||||
case CIRCLE_UPDATE_SUCCESS:
|
||||
return normalizeList(state, action.circle);
|
||||
case CIRCLES_FETCH_SUCCESS:
|
||||
return normalizeLists(state, action.circles);
|
||||
case CIRCLE_DELETE_SUCCESS:
|
||||
case CIRCLE_FETCH_FAIL:
|
||||
return state.set(action.id, false);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ import {
|
|||
COMPOSE_POLL_OPTION_CHANGE,
|
||||
COMPOSE_POLL_OPTION_REMOVE,
|
||||
COMPOSE_POLL_SETTINGS_CHANGE,
|
||||
COMPOSE_CIRCLE_CHANGE,
|
||||
INIT_MEDIA_EDIT_MODAL,
|
||||
COMPOSE_CHANGE_MEDIA_DESCRIPTION,
|
||||
COMPOSE_CHANGE_MEDIA_FOCUS,
|
||||
|
@ -68,6 +69,7 @@ const initialState = ImmutableMap({
|
|||
spoiler_text: '',
|
||||
markdown: false,
|
||||
privacy: null,
|
||||
circle_id: null,
|
||||
searchability: null,
|
||||
id: null,
|
||||
text: '',
|
||||
|
@ -136,6 +138,7 @@ function clearAll(state) {
|
|||
map.update('media_attachments', list => list.clear());
|
||||
map.set('poll', null);
|
||||
map.set('idempotencyKey', uuid());
|
||||
map.set('circle_id', null);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -597,6 +600,8 @@ export default function compose(state = initialState, action) {
|
|||
return state.updateIn(['poll', 'options'], options => options.delete(action.index));
|
||||
case COMPOSE_POLL_SETTINGS_CHANGE:
|
||||
return state.update('poll', poll => poll.set('expires_in', action.expiresIn).set('multiple', action.isMultiple));
|
||||
case COMPOSE_CIRCLE_CHANGE:
|
||||
return state.set('circle_id', action.circleId);
|
||||
case COMPOSE_LANGUAGE_CHANGE:
|
||||
return state.set('language', action.language);
|
||||
case COMPOSE_FOCUS:
|
||||
|
|
|
@ -13,6 +13,9 @@ import antennaEditor from './antenna_editor';
|
|||
import antennas from './antennas';
|
||||
import blocks from './blocks';
|
||||
import boosts from './boosts';
|
||||
import circleAdder from './circle_adder';
|
||||
import circleEditor from './circle_editor';
|
||||
import circles from './circles';
|
||||
import compose from './compose';
|
||||
import contexts from './contexts';
|
||||
import conversations from './conversations';
|
||||
|
@ -83,6 +86,9 @@ const reducers = {
|
|||
antennas,
|
||||
antennaEditor,
|
||||
antennaAdder,
|
||||
circles,
|
||||
circleEditor,
|
||||
circleAdder,
|
||||
filters,
|
||||
conversations,
|
||||
suggestions,
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
|
||||
import {
|
||||
LIST_ADDER_RESET,
|
||||
LIST_ADDER_SETUP,
|
||||
LIST_ADDER_LISTS_FETCH_REQUEST,
|
||||
LIST_ADDER_LISTS_FETCH_SUCCESS,
|
||||
LIST_ADDER_LISTS_FETCH_FAIL,
|
||||
LIST_EDITOR_ADD_SUCCESS,
|
||||
LIST_EDITOR_REMOVE_SUCCESS,
|
||||
} from '../actions/lists';
|
||||
CIRCLE_ADDER_RESET,
|
||||
CIRCLE_ADDER_SETUP,
|
||||
CIRCLE_ADDER_CIRCLES_FETCH_REQUEST,
|
||||
CIRCLE_ADDER_CIRCLES_FETCH_SUCCESS,
|
||||
CIRCLE_ADDER_CIRCLES_FETCH_FAIL,
|
||||
CIRCLE_EDITOR_ADD_SUCCESS,
|
||||
CIRCLE_EDITOR_REMOVE_SUCCESS,
|
||||
} from '../actions/circles';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
accountId: null,
|
||||
|
||||
lists: ImmutableMap({
|
||||
circles: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
});
|
||||
|
||||
export default function listAdderReducer(state = initialState, action) {
|
||||
export default function circleAdderReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case LIST_ADDER_RESET:
|
||||
case CIRCLE_ADDER_RESET:
|
||||
return initialState;
|
||||
case LIST_ADDER_SETUP:
|
||||
case CIRCLE_ADDER_SETUP:
|
||||
return state.withMutations(map => {
|
||||
map.set('accountId', action.account.get('id'));
|
||||
});
|
||||
case LIST_ADDER_LISTS_FETCH_REQUEST:
|
||||
return state.setIn(['lists', 'isLoading'], true);
|
||||
case LIST_ADDER_LISTS_FETCH_FAIL:
|
||||
return state.setIn(['lists', 'isLoading'], false);
|
||||
case LIST_ADDER_LISTS_FETCH_SUCCESS:
|
||||
return state.update('lists', lists => lists.withMutations(map => {
|
||||
case CIRCLE_ADDER_CIRCLES_FETCH_REQUEST:
|
||||
return state.setIn(['circles', 'isLoading'], true);
|
||||
case CIRCLE_ADDER_CIRCLES_FETCH_FAIL:
|
||||
return state.setIn(['circles', 'isLoading'], false);
|
||||
case CIRCLE_ADDER_CIRCLES_FETCH_SUCCESS:
|
||||
return state.update('circles', circles => circles.withMutations(map => {
|
||||
map.set('isLoading', false);
|
||||
map.set('loaded', true);
|
||||
map.set('items', ImmutableList(action.lists.map(item => item.id)));
|
||||
map.set('items', ImmutableList(action.circles.map(item => item.id)));
|
||||
}));
|
||||
case LIST_EDITOR_ADD_SUCCESS:
|
||||
return state.updateIn(['lists', 'items'], list => list.unshift(action.listId));
|
||||
case LIST_EDITOR_REMOVE_SUCCESS:
|
||||
return state.updateIn(['lists', 'items'], list => list.filterNot(item => item === action.listId));
|
||||
case CIRCLE_EDITOR_ADD_SUCCESS:
|
||||
return state.updateIn(['circles', 'items'], circle => circle.unshift(action.circleId));
|
||||
case CIRCLE_EDITOR_REMOVE_SUCCESS:
|
||||
return state.updateIn(['circles', 'items'], circle => circle.filterNot(item => item === action.circleId));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
3
app/javascript/styles/full-dark.scss
Normal file
3
app/javascript/styles/full-dark.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@import 'full-dark/variables';
|
||||
@import 'application';
|
||||
@import 'full-dark/diff';
|
41
app/javascript/styles/full-dark/diff.scss
Normal file
41
app/javascript/styles/full-dark/diff.scss
Normal file
|
@ -0,0 +1,41 @@
|
|||
input,
|
||||
textarea {
|
||||
background: $ui-base-color !important;
|
||||
color: $primary-text-color !important;
|
||||
|
||||
&::placeholder {
|
||||
color: lighten($dark-text-color, 36%) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.emoji-mart-category-label {
|
||||
color: $lighter-text-color !important;
|
||||
}
|
||||
|
||||
.compose-form .compose-form__warning {
|
||||
color: $ui-base-color;
|
||||
}
|
||||
|
||||
.column-content-select__control,
|
||||
.column-content-select__menu {
|
||||
background: $ui-base-color !important;
|
||||
}
|
||||
|
||||
.column-content-select__single-value {
|
||||
color: $classic-secondary-color !important;
|
||||
}
|
||||
|
||||
.modal-root__modal {
|
||||
background: lighten($classic-base-color, 12%);
|
||||
}
|
||||
|
||||
.boost-modal__action-bar,
|
||||
.confirmation-modal__action-bar,
|
||||
.mute-modal__action-bar,
|
||||
.block-modal__action-bar {
|
||||
background: lighten($classic-base-color, 2%);
|
||||
}
|
||||
|
||||
.searchability-dropdown__value-overlay {
|
||||
color: #ff9bf8 !important;
|
||||
}
|
105
app/javascript/styles/full-dark/variables.scss
Normal file
105
app/javascript/styles/full-dark/variables.scss
Normal file
|
@ -0,0 +1,105 @@
|
|||
// Commonly used web colors
|
||||
$black: #000000; // Black
|
||||
$white: #ffffff; // White
|
||||
$red-600: #b7253d !default; // Deep Carmine
|
||||
$red-500: #df405a !default; // Cerise
|
||||
$blurple-600: #563acc; // Iris
|
||||
$blurple-500: #6364ff; // Brand purple
|
||||
$blurple-400: #7477fd; // Medium slate blue
|
||||
$blurple-300: #858afa; // Faded Blue
|
||||
$grey-600: #4e4c5a; // Trout
|
||||
$grey-100: #dadaf3; // Topaz
|
||||
|
||||
$success-green: #79bd9a !default; // Padua
|
||||
$error-red: $red-500 !default; // Cerise
|
||||
$warning-red: #ff5050 !default; // Sunset Orange
|
||||
$gold-star: #ca8f04 !default; // Dark Goldenrod
|
||||
$kmyblue: #29a5f7 !default;
|
||||
|
||||
$red-bookmark: $warning-red;
|
||||
|
||||
// Values from the classic Mastodon UI
|
||||
$classic-base-color: #282c37; // Midnight Express
|
||||
$classic-primary-color: #9baec8; // Echo Blue
|
||||
$classic-secondary-color: #d9e1e8; // Pattens Blue
|
||||
$classic-highlight-color: #6364ff; // Brand purple
|
||||
|
||||
// Values for kmyblue original functions
|
||||
$emoji-reaction-color: #42485a !default;
|
||||
$emoji-reaction-selected-color: #617ed5 !default;
|
||||
|
||||
// Variables for defaults in UI
|
||||
$base-shadow-color: $black !default;
|
||||
$base-overlay-background: $black !default;
|
||||
$base-border-color: $white !default;
|
||||
$simple-background-color: $classic-base-color !default;
|
||||
$valid-value-color: $success-green !default;
|
||||
$error-value-color: $error-red !default;
|
||||
|
||||
// Tell UI to use selected colors
|
||||
$ui-base-color: $classic-base-color !default; // Darkest
|
||||
$ui-base-lighter-color: #969fbc !default; // Lighter darkest
|
||||
$ui-primary-color: $classic-primary-color !default; // Lighter
|
||||
$ui-secondary-color: $classic-secondary-color !default; // Lightest
|
||||
$ui-highlight-color: $classic-highlight-color !default;
|
||||
$ui-button-color: $white !default;
|
||||
$ui-button-background-color: $blurple-500 !default;
|
||||
$ui-button-focus-background-color: $blurple-600 !default;
|
||||
$ui-button-focus-outline-color: $blurple-400 !default;
|
||||
$ui-button-focus-outline: solid 2px $ui-button-focus-outline-color !default;
|
||||
|
||||
$ui-button-secondary-color: $grey-100 !default;
|
||||
$ui-button-secondary-border-color: $grey-100 !default;
|
||||
$ui-button-secondary-focus-background-color: $grey-600 !default;
|
||||
$ui-button-secondary-focus-color: $white !default;
|
||||
|
||||
$ui-button-tertiary-color: $blurple-300 !default;
|
||||
$ui-button-tertiary-border-color: $blurple-300 !default;
|
||||
$ui-button-tertiary-focus-background-color: $blurple-600 !default;
|
||||
$ui-button-tertiary-focus-color: $white !default;
|
||||
|
||||
$ui-button-destructive-background-color: $red-500 !default;
|
||||
$ui-button-destructive-focus-background-color: $red-600 !default;
|
||||
|
||||
$ui-button-icon-focus-outline: $ui-button-focus-outline !default;
|
||||
$ui-button-icon-hover-background-color: rgba(140, 141, 255, 40%) !default;
|
||||
|
||||
// Variables for texts
|
||||
$primary-text-color: $white !default;
|
||||
$darker-text-color: $ui-primary-color !default;
|
||||
$dark-text-color: $ui-base-lighter-color !default;
|
||||
$secondary-text-color: $ui-secondary-color !default;
|
||||
$highlight-text-color: lighten($ui-highlight-color, 8%) !default;
|
||||
$action-button-color: $ui-base-lighter-color !default;
|
||||
$action-button-focus-color: lighten($ui-base-lighter-color, 4%) !default;
|
||||
$passive-text-color: $gold-star !default;
|
||||
$active-passive-text-color: $success-green !default;
|
||||
|
||||
// For texts on inverted backgrounds
|
||||
$inverted-text-color: $classic-secondary-color !default;
|
||||
$lighter-text-color: $ui-base-lighter-color !default;
|
||||
$light-text-color: $ui-primary-color !default;
|
||||
|
||||
// Language codes that uses CJK fonts
|
||||
$cjk-langs: ja, ko, zh-CN, zh-HK, zh-TW;
|
||||
|
||||
// Variables for components
|
||||
$media-modal-media-max-width: 100%;
|
||||
|
||||
// put margins on top and bottom of image to avoid the screen covered by image.
|
||||
$media-modal-media-max-height: 80%;
|
||||
|
||||
$no-gap-breakpoint: 1175px;
|
||||
|
||||
$font-sans-serif: 'mastodon-font-sans-serif' !default;
|
||||
$font-display: 'mastodon-font-display' !default;
|
||||
$font-monospace: 'mastodon-font-monospace' !default;
|
||||
|
||||
:root {
|
||||
--dropdown-border-color: #{lighten($ui-base-color, 12%)};
|
||||
--dropdown-background-color: #{lighten($ui-base-color, 4%)};
|
||||
--dropdown-shadow: 0 20px 25px -5px #{rgba($base-shadow-color, 0.25)},
|
||||
0 8px 10px -6px #{rgba($base-shadow-color, 0.25)};
|
||||
--modal-background-color: #{darken($ui-base-color, 4%)};
|
||||
--modal-border-color: #{lighten($ui-base-color, 4%)};
|
||||
}
|
|
@ -3341,6 +3341,8 @@ $ui-header-height: 55px;
|
|||
white-space: nowrap;
|
||||
border: 0;
|
||||
border-left: 4px solid transparent;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
|
@ -3390,7 +3392,8 @@ $ui-header-height: 55px;
|
|||
margin-inline-end: 5px;
|
||||
}
|
||||
|
||||
.column-link__badge {
|
||||
.column-link__badge,
|
||||
.column-link__command {
|
||||
display: inline-block;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
|
@ -3401,6 +3404,12 @@ $ui-header-height: 55px;
|
|||
margin: -6px 10px;
|
||||
}
|
||||
|
||||
.column-link__command {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.column-subheading {
|
||||
background: $ui-base-color;
|
||||
color: $dark-text-color;
|
||||
|
@ -3549,6 +3558,19 @@ $ui-header-height: 55px;
|
|||
}
|
||||
}
|
||||
|
||||
.circle-item {
|
||||
display: flex;
|
||||
|
||||
.column-link {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.icon-button {
|
||||
align-self: center;
|
||||
margin: 0 8px;
|
||||
}
|
||||
}
|
||||
|
||||
button.icon-button i.fa-retweet {
|
||||
background-position: 0 0;
|
||||
height: 19px;
|
||||
|
@ -4500,6 +4522,104 @@ a.status-card {
|
|||
}
|
||||
}
|
||||
|
||||
.column-content-select {
|
||||
&__control {
|
||||
@include search-input;
|
||||
|
||||
&::placeholder {
|
||||
color: lighten($darker-text-color, 4%);
|
||||
}
|
||||
|
||||
&::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
&::-moz-focus-inner,
|
||||
&:focus,
|
||||
&:active {
|
||||
outline: 0 !important;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
background: lighten($ui-base-color, 4%);
|
||||
}
|
||||
|
||||
@media screen and (width <= 600px) {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
&__placeholder {
|
||||
color: $dark-text-color;
|
||||
padding-inline-start: 2px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&__value-container {
|
||||
padding-inline-start: 6px;
|
||||
}
|
||||
|
||||
&__multi-value {
|
||||
background: lighten($ui-base-color, 8%);
|
||||
|
||||
&__remove {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover,
|
||||
&:active,
|
||||
&:focus {
|
||||
background: lighten($ui-base-color, 12%);
|
||||
color: lighten($darker-text-color, 4%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__multi-value__label,
|
||||
&__input,
|
||||
&__input-container {
|
||||
color: $darker-text-color;
|
||||
}
|
||||
|
||||
&__clear-indicator,
|
||||
&__dropdown-indicator {
|
||||
cursor: pointer;
|
||||
transition: none;
|
||||
color: $dark-text-color;
|
||||
|
||||
&:hover,
|
||||
&:active,
|
||||
&:focus {
|
||||
color: lighten($dark-text-color, 4%);
|
||||
}
|
||||
}
|
||||
|
||||
&__indicator-separator {
|
||||
background-color: lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
&__menu {
|
||||
@include search-popout;
|
||||
|
||||
padding: 0;
|
||||
background: $ui-secondary-color;
|
||||
}
|
||||
|
||||
&__menu-list {
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
&__option {
|
||||
color: $inverted-text-color;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
|
||||
&--is-focused,
|
||||
&--is-selected {
|
||||
background: darken($ui-secondary-color, 10%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.relationship-tag {
|
||||
color: $white;
|
||||
margin-bottom: 4px;
|
||||
|
@ -7382,11 +7502,45 @@ noscript {
|
|||
.antenna-setting {
|
||||
margin: 8px 16px 32px;
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
margin: 40px 0 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
margin: 40px 0 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.alert {
|
||||
color: $warning-red;
|
||||
margin: 16px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-radio-panel {
|
||||
display: flex;
|
||||
margin-top: 24px;
|
||||
|
||||
.setting-radio-panel__item {
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
flex: 1;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
margin: 16px 0;
|
||||
background: lighten($ui-base-color, 4%);
|
||||
color: $darker-text-color;
|
||||
border: 0;
|
||||
|
||||
&__active {
|
||||
color: $primary-text-color;
|
||||
background: $ui-primary-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.setting-text-list {
|
||||
|
|
|
@ -118,7 +118,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
|
||||
def process_status_params
|
||||
@status_parser = ActivityPub::Parser::StatusParser.new(@json['signature'].present? ? @object : @json, followers_collection: @account.followers_url)
|
||||
@status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url, object: @object)
|
||||
|
||||
@params = {
|
||||
uri: @status_parser.uri,
|
||||
|
|
|
@ -8,7 +8,7 @@ class ActivityPub::Parser::StatusParser
|
|||
# @option magic_values [String] :followers_collection
|
||||
def initialize(json, magic_values = {})
|
||||
@json = json
|
||||
@object = json['object'] || json
|
||||
@object = magic_values[:object] || json['object'] || json
|
||||
@magic_values = magic_values
|
||||
end
|
||||
|
||||
|
@ -87,8 +87,11 @@ class ActivityPub::Parser::StatusParser
|
|||
end
|
||||
|
||||
def limited_scope
|
||||
if @object['limitedScope'] == 'Mutual'
|
||||
case @object['limitedScope']
|
||||
when 'Mutual'
|
||||
:mutual
|
||||
when 'Circle'
|
||||
:circle
|
||||
else
|
||||
:none
|
||||
end
|
||||
|
|
|
@ -222,7 +222,11 @@ class ActivityPub::TagManager
|
|||
end
|
||||
|
||||
def limited_scope(status)
|
||||
status.mutual_limited? ? 'Mutual' : ''
|
||||
if status.mutual_limited?
|
||||
'Mutual'
|
||||
else
|
||||
status.circle_limited? ? 'Circle' : ''
|
||||
end
|
||||
end
|
||||
|
||||
def subscribable_by(account)
|
||||
|
|
|
@ -265,6 +265,28 @@ class FeedManager
|
|||
end
|
||||
end
|
||||
|
||||
def clear_from_antenna(antenna, target_account)
|
||||
timeline_key = key(:antenna, antenna.id)
|
||||
timeline_status_ids = redis.zrange(timeline_key, 0, -1)
|
||||
statuses = Status.where(id: timeline_status_ids).select(:id, :reblog_of_id, :account_id).to_a
|
||||
reblogged_ids = Status.where(id: statuses.filter_map(&:reblog_of_id), account: target_account).pluck(:id)
|
||||
with_mentions_ids = Mention.active.where(status_id: statuses.flat_map { |s| [s.id, s.reblog_of_id] }.compact, account: target_account).pluck(:status_id)
|
||||
|
||||
target_statuses = statuses.select do |status|
|
||||
status.account_id == target_account.id || reblogged_ids.include?(status.reblog_of_id) || with_mentions_ids.include?(status.id) || with_mentions_ids.include?(status.reblog_of_id)
|
||||
end
|
||||
|
||||
target_statuses.each do |status|
|
||||
unpush_from_antenna(antenna, status)
|
||||
end
|
||||
end
|
||||
|
||||
def clear_from_antennas(account, target_account)
|
||||
Antenna.where(account: account).each do |antenna|
|
||||
clear_from_antenna(antenna, target_account)
|
||||
end
|
||||
end
|
||||
|
||||
# Populate home feed of account from scratch
|
||||
# @param [Account] account
|
||||
# @return [void]
|
||||
|
|
|
@ -30,6 +30,10 @@ class Antenna < ApplicationRecord
|
|||
include Expireable
|
||||
|
||||
LIMIT = 30
|
||||
DOMAINS_PER_ANTENNA_LIMIT = 20
|
||||
ACCOUNTS_PER_ANTENNA_LIMIT = 100
|
||||
TAGS_PER_ANTENNA_LIMIT = 50
|
||||
KEYWORDS_PER_ANTENNA_LIMIT = 100
|
||||
|
||||
has_many :antenna_domains, inverse_of: :antenna, dependent: :destroy
|
||||
has_many :antenna_tags, inverse_of: :antenna, dependent: :destroy
|
||||
|
|
|
@ -14,4 +14,17 @@
|
|||
class AntennaAccount < ApplicationRecord
|
||||
belongs_to :antenna
|
||||
belongs_to :account
|
||||
|
||||
validate :duplicate_account
|
||||
validate :limit_per_antenna
|
||||
|
||||
private
|
||||
|
||||
def duplicate_account
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.duplicate_account') if AntennaAccount.exists?(antenna_id: antenna_id, account_id: account_id, exclude: exclude)
|
||||
end
|
||||
|
||||
def limit_per_antenna
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.limit.accounts') if AntennaAccount.where(antenna_id: antenna_id).count >= Antenna::ACCOUNTS_PER_ANTENNA_LIMIT
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,8 +15,15 @@ class AntennaDomain < ApplicationRecord
|
|||
belongs_to :antenna
|
||||
|
||||
validate :duplicate_domain
|
||||
validate :limit_per_antenna
|
||||
|
||||
private
|
||||
|
||||
def duplicate_domain
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.duplicate_domain') if AntennaDomain.exists?(antenna_id: antenna_id, name: name, exclude: exclude)
|
||||
end
|
||||
|
||||
def limit_per_antenna
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.limit.domains') if AntennaDomain.where(antenna_id: antenna_id).count >= Antenna::DOMAINS_PER_ANTENNA_LIMIT
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,4 +14,17 @@
|
|||
class AntennaTag < ApplicationRecord
|
||||
belongs_to :antenna
|
||||
belongs_to :tag
|
||||
|
||||
validate :duplicate_tag
|
||||
validate :limit_per_antenna
|
||||
|
||||
private
|
||||
|
||||
def duplicate_tag
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.duplicate_tag') if AntennaTag.exists?(antenna_id: antenna_id, tag_id: tag_id, exclude: exclude)
|
||||
end
|
||||
|
||||
def limit_per_antenna
|
||||
raise Mastodon::ValidationError, I18n.t('antennas.errors.limit.tags') if AntennaTag.where(antenna_id: antenna_id).count >= Antenna::TAGS_PER_ANTENNA_LIMIT
|
||||
end
|
||||
end
|
||||
|
|
29
app/models/circle.rb
Normal file
29
app/models/circle.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: circles
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8) not null
|
||||
# title :string default(""), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class Circle < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
PER_ACCOUNT_LIMIT = 100
|
||||
|
||||
belongs_to :account
|
||||
|
||||
has_many :circle_accounts, inverse_of: :circle, dependent: :destroy
|
||||
has_many :accounts, through: :circle_accounts
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
validates_each :account_id, on: :create do |record, _attr, value|
|
||||
record.errors.add(:base, I18n.t('lists.errors.limit')) if List.where(account_id: value).count >= PER_ACCOUNT_LIMIT
|
||||
end
|
||||
end
|
39
app/models/circle_account.rb
Normal file
39
app/models/circle_account.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: circle_accounts
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# circle_id :bigint(8)
|
||||
# account_id :bigint(8) not null
|
||||
# follow_id :bigint(8) not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class CircleAccount < ApplicationRecord
|
||||
belongs_to :circle
|
||||
belongs_to :account
|
||||
belongs_to :follow
|
||||
|
||||
validates :account_id, uniqueness: { scope: :circle_id }
|
||||
validate :validate_relationship
|
||||
|
||||
before_validation :set_follow
|
||||
|
||||
private
|
||||
|
||||
def set_follow
|
||||
return if circle.account_id == account.id
|
||||
|
||||
self.follow = Follow.find_by!(account_id: account.id, target_account_id: circle.account_id)
|
||||
end
|
||||
|
||||
def validate_relationship
|
||||
return if circle.account_id == account_id
|
||||
|
||||
errors.add(:account_id, 'follow relationship missing') if follow_id.nil?
|
||||
errors.add(:follow, 'mismatched accounts') if follow_id.present? && follow.account_id != account_id
|
||||
end
|
||||
end
|
|
@ -87,6 +87,29 @@ module AccountSearch
|
|||
LIMIT :limit OFFSET :offset
|
||||
SQL
|
||||
|
||||
ADVANCED_SEARCH_WITH_FOLLOWED = <<~SQL.squish
|
||||
WITH first_degree AS (
|
||||
SELECT account_id
|
||||
FROM follows
|
||||
WHERE target_account_id = :id
|
||||
UNION ALL
|
||||
SELECT :id
|
||||
)
|
||||
SELECT
|
||||
accounts.*,
|
||||
(count(f.id) + 1) * #{BOOST} * ts_rank_cd(#{TEXT_SEARCH_RANKS}, to_tsquery('simple', :tsquery), 32) AS rank
|
||||
FROM accounts
|
||||
LEFT OUTER JOIN follows AS f ON (accounts.id = f.target_account_id AND f.account_id = :id)
|
||||
LEFT JOIN account_stats AS s ON accounts.id = s.account_id
|
||||
WHERE accounts.id IN (SELECT * FROM first_degree)
|
||||
AND to_tsquery('simple', :tsquery) @@ #{TEXT_SEARCH_RANKS}
|
||||
AND accounts.suspended_at IS NULL
|
||||
AND accounts.moved_to_account_id IS NULL
|
||||
GROUP BY accounts.id, s.id
|
||||
ORDER BY rank DESC
|
||||
LIMIT :limit OFFSET :offset
|
||||
SQL
|
||||
|
||||
ADVANCED_SEARCH_WITHOUT_FOLLOWING = <<~SQL.squish
|
||||
SELECT
|
||||
accounts.*,
|
||||
|
@ -126,9 +149,13 @@ module AccountSearch
|
|||
end
|
||||
end
|
||||
|
||||
def advanced_search_for(terms, account, limit: 10, following: false, offset: 0)
|
||||
def advanced_search_for(terms, account, limit: 10, following: false, follower: false, offset: 0)
|
||||
tsquery = generate_query_for_search(terms)
|
||||
sql_template = following ? ADVANCED_SEARCH_WITH_FOLLOWING : ADVANCED_SEARCH_WITHOUT_FOLLOWING
|
||||
sql_template = if following
|
||||
ADVANCED_SEARCH_WITH_FOLLOWING
|
||||
else
|
||||
follower ? ADVANCED_SEARCH_WITH_FOLLOWED : ADVANCED_SEARCH_WITHOUT_FOLLOWING
|
||||
end
|
||||
|
||||
find_by_sql([sql_template, { id: account.id, limit: limit, offset: offset, tsquery: tsquery }]).tap do |records|
|
||||
ActiveRecord::Associations::Preloader.new(records: records, associations: :account_stat)
|
||||
|
|
|
@ -55,7 +55,7 @@ class Status < ApplicationRecord
|
|||
|
||||
enum visibility: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10, login: 11 }, _suffix: :visibility
|
||||
enum searchability: { public: 0, private: 1, direct: 2, limited: 3, unsupported: 4, public_unlisted: 10 }, _suffix: :searchability
|
||||
enum limited_scope: { none: 0, mutual: 1 }, _suffix: :limited
|
||||
enum limited_scope: { none: 0, mutual: 1, circle: 2 }, _suffix: :limited
|
||||
|
||||
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
|
||||
|
||||
|
|
9
app/serializers/rest/circle_serializer.rb
Normal file
9
app/serializers/rest/circle_serializer.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::CircleSerializer < ActiveModel::Serializer
|
||||
attributes :id, :title
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
|
@ -119,6 +119,9 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
:kmyblue_visibility_login,
|
||||
:status_reference,
|
||||
:visibility_mutual,
|
||||
:visibility_limited,
|
||||
:kmyblue_limited_scope,
|
||||
:kmyblue_antenna,
|
||||
]
|
||||
|
||||
capabilities << :profile_search unless Chewy.enabled?
|
||||
|
|
|
@ -128,7 +128,9 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
|||
:kmyblue_visibility_login,
|
||||
:status_reference,
|
||||
:visibility_mutual,
|
||||
:visibility_limited,
|
||||
:kmyblue_limited_scope,
|
||||
:kmyblue_antenna,
|
||||
]
|
||||
|
||||
capabilities << :profile_search unless Chewy.enabled?
|
||||
|
|
|
@ -44,13 +44,15 @@ class AccountSearchService < BaseService
|
|||
def must_clauses
|
||||
if @account && @options[:following]
|
||||
[core_query, only_following_query]
|
||||
elsif @account && @options[:follower]
|
||||
[core_query, only_follower_query]
|
||||
else
|
||||
[core_query]
|
||||
end
|
||||
end
|
||||
|
||||
def should_clauses
|
||||
if @account && !@options[:following]
|
||||
if @account && !@options[:following] && !@options[:follower]
|
||||
[boost_following_query]
|
||||
else
|
||||
[]
|
||||
|
@ -76,6 +78,23 @@ class AccountSearchService < BaseService
|
|||
}
|
||||
end
|
||||
|
||||
def only_follower_query
|
||||
{
|
||||
terms: {
|
||||
id: follower_ids,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
def boost_follower_query
|
||||
{
|
||||
terms: {
|
||||
id: follower_ids,
|
||||
boost: 100,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
# This function deranks accounts that follow more people than follow them
|
||||
def reputation_score_function
|
||||
{
|
||||
|
@ -114,6 +133,10 @@ class AccountSearchService < BaseService
|
|||
def following_ids
|
||||
@following_ids ||= @account.active_relationships.pluck(:target_account_id) + [@account.id]
|
||||
end
|
||||
|
||||
def follower_ids
|
||||
@follower_ids ||= @account.passive_relationships.pluck(:account_id)
|
||||
end
|
||||
end
|
||||
|
||||
class AutocompleteQueryBuilder < QueryBuilder
|
||||
|
@ -177,6 +200,7 @@ class AccountSearchService < BaseService
|
|||
end
|
||||
|
||||
match = nil if !match.nil? && !account.nil? && options[:following] && !account.following?(match)
|
||||
match = nil if !match.nil? && !account.nil? && options[:follower] && !match.following?(account)
|
||||
|
||||
@exact_match = match
|
||||
end
|
||||
|
@ -200,7 +224,7 @@ class AccountSearchService < BaseService
|
|||
end
|
||||
|
||||
def advanced_search_results
|
||||
Account.advanced_search_for(terms_for_query, account, limit: limit_for_non_exact_results, following: options[:following], offset: offset)
|
||||
Account.advanced_search_for(terms_for_query, account, limit: limit_for_non_exact_results, following: options[:following], follower: options[:follower], offset: offset)
|
||||
end
|
||||
|
||||
def simple_search_results
|
||||
|
@ -210,9 +234,9 @@ class AccountSearchService < BaseService
|
|||
def from_elasticsearch
|
||||
query_builder = begin
|
||||
if options[:use_searchable_text]
|
||||
FullQueryBuilder.new(terms_for_query, account, options.slice(:following))
|
||||
FullQueryBuilder.new(terms_for_query, account, options.slice(:following, :follower))
|
||||
else
|
||||
AutocompleteQueryBuilder.new(terms_for_query, account, options.slice(:following))
|
||||
AutocompleteQueryBuilder.new(terms_for_query, account, options.slice(:following, :follower))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ class AfterBlockService < BaseService
|
|||
|
||||
clear_home_feed!
|
||||
clear_list_feeds!
|
||||
clear_antenna_feeds!
|
||||
clear_notifications!
|
||||
clear_conversations!
|
||||
end
|
||||
|
@ -21,6 +22,10 @@ class AfterBlockService < BaseService
|
|||
FeedManager.instance.clear_from_lists(@account, @target_account)
|
||||
end
|
||||
|
||||
def clear_antenna_feeds!
|
||||
FeedManager.instance.clear_from_antennas(@account, @target_account)
|
||||
end
|
||||
|
||||
def clear_conversations!
|
||||
AccountConversation.where(account: @account).where('? = ANY(participant_account_ids)', @target_account.id).in_batches.destroy_all
|
||||
end
|
||||
|
|
|
@ -172,7 +172,7 @@ class FanOutOnWriteService < BaseService
|
|||
antennas = antennas.where(account: @status.account.followers) if [:public, :public_unlisted, :login, :limited].exclude?(@status.visibility.to_sym)
|
||||
antennas = antennas.where(account: @status.mentioned_accounts) if @status.visibility.to_sym == :limited
|
||||
antennas = antennas.where(with_media_only: false) unless @status.with_media?
|
||||
antennas = antennas.where(ignore_reblog: false) unless @status.reblog?
|
||||
antennas = antennas.where(ignore_reblog: false) if @status.reblog?
|
||||
antennas = antennas.where(stl: false)
|
||||
|
||||
collection = AntennaCollection.new(@status, @options[:update], false)
|
||||
|
@ -276,8 +276,8 @@ class FanOutOnWriteService < BaseService
|
|||
|
||||
def push(antenna)
|
||||
if antenna.list_id.zero?
|
||||
@home_account_ids << { id: antenna.account_id, antenna_id: antenna.id } if @home_account_ids.none? { |id| id.id == antenna.account_id }
|
||||
elsif @list_ids.none? { |id| id.id == antenna.list_id }
|
||||
@home_account_ids << { id: antenna.account_id, antenna_id: antenna.id } if @home_account_ids.none? { |id| id[:id] == antenna.account_id }
|
||||
elsif @list_ids.none? { |id| id[:id] == antenna.list_id }
|
||||
@list_ids << { id: antenna.list_id, antenna_id: antenna.id }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,20 +75,29 @@ class PostStatusService < BaseService
|
|||
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
|
||||
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
|
||||
@visibility = :direct if @in_reply_to&.limited_visibility?
|
||||
@visibility = :limited if @options[:visibility] == 'mutual'
|
||||
@visibility = :limited if %w(mutual circle).include?(@options[:visibility])
|
||||
@visibility = :unlisted if (@visibility&.to_sym == :public || @visibility&.to_sym == :public_unlisted || @visibility&.to_sym == :login) && @account.silenced?
|
||||
@visibility = :public_unlisted if @visibility&.to_sym == :public && !@options[:force_visibility] && !@options[:application]&.superapp && @account.user&.setting_public_post_to_unlisted
|
||||
@limited_scope = @options[:visibility]&.to_sym if @visibility == :limited
|
||||
@searchability = searchability
|
||||
@searchability = :private if @account.silenced? && @searchability&.to_sym == :public
|
||||
@markdown = @options[:markdown] || false
|
||||
@scheduled_at = @options[:scheduled_at]&.to_datetime
|
||||
@scheduled_at = nil if scheduled_in_the_past?
|
||||
@reference_ids = (@options[:status_reference_ids] || []).map(&:to_i).filter(&:positive?)
|
||||
load_circle
|
||||
process_sensitive_words
|
||||
rescue ArgumentError
|
||||
raise ActiveRecord::RecordInvalid
|
||||
end
|
||||
|
||||
def load_circle
|
||||
return unless @options[:visibility] == 'circle'
|
||||
|
||||
@circle = @options[:circle_id].present? && Circle.find(@options[:circle_id])
|
||||
raise ArgumentError if @circle.nil?
|
||||
end
|
||||
|
||||
def process_sensitive_words
|
||||
if [:public, :public_unlisted, :login].include?(@visibility&.to_sym) && Admin::SensitiveWord.sensitive?(@text, @options[:spoiler_text] || '')
|
||||
@text = Admin::SensitiveWord.modified_text(@text, @options[:spoiler_text])
|
||||
|
@ -115,7 +124,7 @@ class PostStatusService < BaseService
|
|||
|
||||
def process_status!
|
||||
@status = @account.statuses.new(status_attributes)
|
||||
process_mentions_service.call(@status, limited_type: @status.limited_visibility? ? 'mutual' : '', save_records: false)
|
||||
process_mentions_service.call(@status, limited_type: @status.limited_visibility? ? @limited_scope : '', circle: @circle, save_records: false)
|
||||
safeguard_mentions!(@status)
|
||||
|
||||
UpdateStatusExpirationService.new.call(@status)
|
||||
|
@ -248,7 +257,7 @@ class PostStatusService < BaseService
|
|||
spoiler_text: @options[:spoiler_text] || '',
|
||||
markdown: @markdown,
|
||||
visibility: @visibility,
|
||||
limited_scope: @visibility == :limited ? :mutual : :none,
|
||||
limited_scope: @limited_scope || :none,
|
||||
searchability: @searchability,
|
||||
language: valid_locale_cascade(@options[:language], @account.user&.preferred_posting_language, I18n.default_locale),
|
||||
application: @options[:application],
|
||||
|
|
|
@ -7,9 +7,10 @@ class ProcessMentionsService < BaseService
|
|||
# and create local mention pointers
|
||||
# @param [Status] status
|
||||
# @param [Boolean] save_records Whether to save records in database
|
||||
def call(status, limited_type: '', save_records: true)
|
||||
def call(status, limited_type: '', circle: nil, save_records: true)
|
||||
@status = status
|
||||
@limited_type = limited_type
|
||||
@circle = circle
|
||||
@save_records = save_records
|
||||
|
||||
return unless @status.local?
|
||||
|
@ -63,7 +64,8 @@ class ProcessMentionsService < BaseService
|
|||
"@#{mentioned_account.acct}"
|
||||
end
|
||||
|
||||
process_mutual! if @limited_type == 'mutual'
|
||||
process_mutual! if @limited_type == :mutual
|
||||
process_circle! if @limited_type == :circle
|
||||
|
||||
@status.save! if @save_records
|
||||
end
|
||||
|
@ -103,4 +105,12 @@ class ProcessMentionsService < BaseService
|
|||
@current_mentions << @status.mentions.new(silent: true, account: target_account) unless mentioned_account_ids.include?(target_account.id)
|
||||
end
|
||||
end
|
||||
|
||||
def process_circle!
|
||||
mentioned_account_ids = @current_mentions.map(&:account_id)
|
||||
|
||||
@circle.accounts.find_each do |target_account|
|
||||
@current_mentions << @status.mentions.new(silent: true, account: target_account) unless mentioned_account_ids.include?(target_account.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1028,6 +1028,12 @@ en:
|
|||
domain: Domains
|
||||
keyword: Keywords
|
||||
tag: Tags
|
||||
errors:
|
||||
limit:
|
||||
accounts: 登録できるアカウント数の上限に達しています
|
||||
domains: 登録できるドメイン数の上限に達しています
|
||||
keywords: 登録できるキーワード数の上限に達しています
|
||||
tags: 登録できるタグ数の上限に達しています
|
||||
edit:
|
||||
accounts_hint: \@askyq or @askyq@example.com
|
||||
accounts_raw: Account list
|
||||
|
@ -1057,7 +1063,6 @@ en:
|
|||
invalid_list_owner: This list is not yours
|
||||
over_limit: You have exceeded the limit of %{limit} antennas
|
||||
over_stl_limit: You have exceeded the limit of %{limit} stl antennas
|
||||
remove_list_with_antenna: Cannot remove list because this list is related to antenna.
|
||||
index:
|
||||
contexts: Antennas in %{contexts}
|
||||
delete: Delete
|
||||
|
|
|
@ -1027,9 +1027,13 @@ ja:
|
|||
duplicate_keyword: すでに同じキーワードが登録されています
|
||||
empty_contexts: 絞り込み条件が1つも指定されていないため無効です(除外条件はカウントされません)
|
||||
invalid_list_owner: これはあなたのリストではありません
|
||||
limit:
|
||||
accounts: 登録できるアカウント数の上限に達しています
|
||||
domains: 登録できるドメイン数の上限に達しています
|
||||
keywords: 登録できるキーワード数の上限に達しています
|
||||
tags: 登録できるタグ数の上限に達しています
|
||||
over_limit: 所持できるアンテナ数 %{limit}を超えています
|
||||
over_stl_limit: 所持できるSTLモード付きアンテナ数 (ホーム/リストそれぞれにつき%{limit}) を超えています
|
||||
remove_list_with_antenna: アンテナが関連付けられているリストは削除できません
|
||||
edit:
|
||||
accounts_hint: ローカルアカウントの場合は「@info」、リモートアカウントの場合は「@info@example.com」の形式で指定します。サーバーが認識していないアカウントは保存時に自動的に削除されます。
|
||||
accounts_raw: 絞り込むアカウント
|
||||
|
@ -1812,6 +1816,7 @@ ja:
|
|||
themes:
|
||||
contrast: Mastodon (ハイコントラスト)
|
||||
default: Mastodon (ダーク)
|
||||
full-dark: フルダーク
|
||||
mastodon-light: Mastodon (ライト)
|
||||
time:
|
||||
formats:
|
||||
|
|
|
@ -159,8 +159,8 @@ ja:
|
|||
fields:
|
||||
name: ラベル
|
||||
value: 内容
|
||||
hide_collections: (仮訳)フォロー・フォロワー一覧を隠す
|
||||
locked: (仮訳)新規フォローを承認制にする
|
||||
show_collections: (仮訳)フォロー・フォロワー一覧を公開する
|
||||
unlocked: (仮訳)新規フォローを自動で承認する
|
||||
account_alias:
|
||||
acct: 引っ越し元のユーザー ID
|
||||
account_migration:
|
||||
|
|
|
@ -18,6 +18,7 @@ Rails.application.routes.draw do
|
|||
/lists/(*any)
|
||||
/antennasw/(*any)
|
||||
/antennast/(*any)
|
||||
/circles
|
||||
/notifications
|
||||
/favourites
|
||||
/emoji_reactions
|
||||
|
|
|
@ -210,6 +210,13 @@ namespace :api, format: false do
|
|||
resource :accounts, only: [:show, :create, :destroy], controller: 'antennas/accounts'
|
||||
resource :domains, only: [:show, :create, :destroy], controller: 'antennas/domains'
|
||||
resource :keywords, only: [:show, :create, :destroy], controller: 'antennas/keywords'
|
||||
resource :exclude_accounts, only: [:show, :create, :destroy], controller: 'antennas/exclude_accounts'
|
||||
resource :exclude_domains, only: [:create, :destroy], controller: 'antennas/exclude_domains'
|
||||
resource :exclude_keywords, only: [:create, :destroy], controller: 'antennas/exclude_keywords'
|
||||
end
|
||||
|
||||
resources :circles, only: [:index, :create, :show, :update, :destroy] do
|
||||
resource :accounts, only: [:show, :create, :destroy], controller: 'circles/accounts'
|
||||
end
|
||||
|
||||
namespace :featured_tags do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
default: styles/application.scss
|
||||
contrast: styles/contrast.scss
|
||||
mastodon-light: styles/mastodon-light.scss
|
||||
full-dark: styles/full-dark.scss
|
||||
|
|
21
db/migrate/20230821061713_create_circles.rb
Normal file
21
db/migrate/20230821061713_create_circles.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateCircles < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :circles do |t|
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :title, null: false, default: ''
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
create_table :circle_accounts do |t|
|
||||
t.belongs_to :circle, null: true, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :follow, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
|
||||
add_index :circle_accounts, [:circle_id, :account_id], unique: true
|
||||
end
|
||||
end
|
26
db/schema.rb
26
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_08_19_084858) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_08_21_061713) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -401,6 +401,26 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_19_084858) do
|
|||
t.index ["reference_account_id"], name: "index_canonical_email_blocks_on_reference_account_id"
|
||||
end
|
||||
|
||||
create_table "circle_accounts", force: :cascade do |t|
|
||||
t.bigint "circle_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "follow_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id"], name: "index_circle_accounts_on_account_id"
|
||||
t.index ["circle_id", "account_id"], name: "index_circle_accounts_on_circle_id_and_account_id", unique: true
|
||||
t.index ["circle_id"], name: "index_circle_accounts_on_circle_id"
|
||||
t.index ["follow_id"], name: "index_circle_accounts_on_follow_id"
|
||||
end
|
||||
|
||||
create_table "circles", force: :cascade do |t|
|
||||
t.bigint "account_id", null: false
|
||||
t.string "title", default: "", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id"], name: "index_circles_on_account_id"
|
||||
end
|
||||
|
||||
create_table "conversation_mutes", force: :cascade do |t|
|
||||
t.bigint "conversation_id", null: false
|
||||
t.bigint "account_id", null: false
|
||||
|
@ -1341,6 +1361,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_19_084858) do
|
|||
add_foreign_key "bulk_import_rows", "bulk_imports", on_delete: :cascade
|
||||
add_foreign_key "bulk_imports", "accounts", on_delete: :cascade
|
||||
add_foreign_key "canonical_email_blocks", "accounts", column: "reference_account_id", on_delete: :cascade
|
||||
add_foreign_key "circle_accounts", "accounts", on_delete: :cascade
|
||||
add_foreign_key "circle_accounts", "circles", on_delete: :cascade
|
||||
add_foreign_key "circle_accounts", "follows", on_delete: :cascade
|
||||
add_foreign_key "circles", "accounts", on_delete: :cascade
|
||||
add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
|
||||
add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
|
||||
add_foreign_key "custom_filter_keywords", "custom_filters", on_delete: :cascade
|
||||
|
|
56
spec/controllers/api/v1/timelines/antenna_controller_spec.rb
Normal file
56
spec/controllers/api/v1/timelines/antenna_controller_spec.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::V1::Timelines::AntennaController do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:antenna) { Fabricate(:antenna, account: user.account) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:doorkeeper_token) { token }
|
||||
end
|
||||
|
||||
context 'with a user context' do
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:lists') }
|
||||
|
||||
describe 'GET #show' do
|
||||
before do
|
||||
account = Fabricate(:account)
|
||||
antenna.antenna_accounts.create!(account: account)
|
||||
PostStatusService.new.call(account, text: 'New status for user home timeline.')
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
get :show, params: { id: antenna.id }
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with the wrong user context' do
|
||||
let(:other_user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: other_user.id, scopes: 'read') }
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http not found' do
|
||||
get :show, params: { id: antenna.id }
|
||||
expect(response).to have_http_status(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'without a user context' do
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil, scopes: 'read') }
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http unprocessable entity' do
|
||||
get :show, params: { id: antenna.id }
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.headers['Link']).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
7
spec/fabricators/antenna_fabricator.rb
Normal file
7
spec/fabricators/antenna_fabricator.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:antenna) do
|
||||
account { Fabricate.build(:account) }
|
||||
title 'MyString'
|
||||
list_id 0
|
||||
end
|
|
@ -48,4 +48,23 @@ RSpec.describe AfterBlockService, type: :service do
|
|||
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'antennas' do
|
||||
let(:antenna) { Fabricate(:antenna, account: account, list_id: 0) }
|
||||
let(:antenna_timeline_key) { FeedManager.instance.key(:antenna, antenna.id) }
|
||||
|
||||
before do
|
||||
redis.del(antenna_timeline_key)
|
||||
end
|
||||
|
||||
it "clears account's statuses" do
|
||||
FeedManager.instance.push_to_antenna(antenna, status)
|
||||
FeedManager.instance.push_to_antenna(antenna, other_account_status)
|
||||
FeedManager.instance.push_to_antenna(antenna, other_account_reblog)
|
||||
|
||||
expect { subject }.to change {
|
||||
redis.zrange(antenna_timeline_key, 0, -1)
|
||||
}.from([status.id.to_s, other_account_status.id.to_s, other_account_reblog.id.to_s]).to([other_account_status.id.to_s])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue