Merge branch 'glitch' into thread-icon
commit
c86cd2041d
|
@ -11,6 +11,8 @@ aliases:
|
||||||
RAILS_ENV: test
|
RAILS_ENV: test
|
||||||
PARALLEL_TEST_PROCESSORS: 4
|
PARALLEL_TEST_PROCESSORS: 4
|
||||||
ALLOW_NOPAM: true
|
ALLOW_NOPAM: true
|
||||||
|
CONTINUOUS_INTEGRATION: true
|
||||||
|
DISABLE_SIMPLECOV: true
|
||||||
working_directory: ~/projects/mastodon/
|
working_directory: ~/projects/mastodon/
|
||||||
|
|
||||||
- &attach_workspace
|
- &attach_workspace
|
||||||
|
@ -90,7 +92,7 @@ aliases:
|
||||||
command: ./bin/rails parallel:create parallel:load_schema parallel:prepare
|
command: ./bin/rails parallel:create parallel:load_schema parallel:prepare
|
||||||
- run:
|
- run:
|
||||||
name: Run Tests
|
name: Run Tests
|
||||||
command: bundle exec parallel_test ./spec/ --group-by filesize --type rspec
|
command: ./bin/retry bundle exec parallel_test ./spec/ --group-by filesize --type rspec
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
install:
|
install:
|
||||||
|
@ -150,7 +152,7 @@ jobs:
|
||||||
- image: circleci/node:8.11.1-stretch
|
- image: circleci/node:8.11.1-stretch
|
||||||
steps:
|
steps:
|
||||||
- *attach_workspace
|
- *attach_workspace
|
||||||
- run: yarn test:jest
|
- run: ./bin/retry yarn test:jest
|
||||||
|
|
||||||
check-i18n:
|
check-i18n:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
|
|
|
@ -88,6 +88,10 @@ SMTP_FROM_ADDRESS=notifications@example.com
|
||||||
# CDN_HOST=https://assets.example.com
|
# CDN_HOST=https://assets.example.com
|
||||||
|
|
||||||
# S3 (optional)
|
# S3 (optional)
|
||||||
|
# The attachment host must allow cross origin request from WEB_DOMAIN or
|
||||||
|
# LOCAL_DOMAIN if WEB_DOMAIN is not set. For example, the server may have the
|
||||||
|
# following header field:
|
||||||
|
# Access-Control-Allow-Origin: https://192.168.1.123:9000/
|
||||||
# S3_ENABLED=true
|
# S3_ENABLED=true
|
||||||
# S3_BUCKET=
|
# S3_BUCKET=
|
||||||
# AWS_ACCESS_KEY_ID=
|
# AWS_ACCESS_KEY_ID=
|
||||||
|
@ -97,6 +101,8 @@ SMTP_FROM_ADDRESS=notifications@example.com
|
||||||
# S3_HOSTNAME=192.168.1.123:9000
|
# S3_HOSTNAME=192.168.1.123:9000
|
||||||
|
|
||||||
# S3 (Minio Config (optional) Please check Minio instance for details)
|
# S3 (Minio Config (optional) Please check Minio instance for details)
|
||||||
|
# The attachment host must allow cross origin request - see the description
|
||||||
|
# above.
|
||||||
# S3_ENABLED=true
|
# S3_ENABLED=true
|
||||||
# S3_BUCKET=
|
# S3_BUCKET=
|
||||||
# AWS_ACCESS_KEY_ID=
|
# AWS_ACCESS_KEY_ID=
|
||||||
|
@ -108,11 +114,15 @@ SMTP_FROM_ADDRESS=notifications@example.com
|
||||||
# S3_SIGNATURE_VERSION=
|
# S3_SIGNATURE_VERSION=
|
||||||
|
|
||||||
# Swift (optional)
|
# Swift (optional)
|
||||||
|
# The attachment host must allow cross origin request - see the description
|
||||||
|
# above.
|
||||||
# SWIFT_ENABLED=true
|
# SWIFT_ENABLED=true
|
||||||
# SWIFT_USERNAME=
|
# SWIFT_USERNAME=
|
||||||
# For Keystone V3, the value for SWIFT_TENANT should be the project name
|
# For Keystone V3, the value for SWIFT_TENANT should be the project name
|
||||||
# SWIFT_TENANT=
|
# SWIFT_TENANT=
|
||||||
# SWIFT_PASSWORD=
|
# SWIFT_PASSWORD=
|
||||||
|
# Some OpenStack V3 providers require PROJECT_ID (optional)
|
||||||
|
# SWIFT_PROJECT_ID=
|
||||||
# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
|
# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid
|
||||||
# issues with token rate-limiting during high load.
|
# issues with token rate-limiting during high load.
|
||||||
# SWIFT_AUTH_URL=
|
# SWIFT_AUTH_URL=
|
||||||
|
|
|
@ -7,6 +7,9 @@ env:
|
||||||
es6: true
|
es6: true
|
||||||
jest: true
|
jest: true
|
||||||
|
|
||||||
|
globals:
|
||||||
|
ATTACHMENT_HOST: false
|
||||||
|
|
||||||
parser: babel-eslint
|
parser: babel-eslint
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
---
|
||||||
|
name: Bug Report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
[Issue text goes here].
|
[Issue text goes here].
|
||||||
|
|
||||||
* * * *
|
* * * *
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
name: Feature Request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
[Issue text goes here].
|
||||||
|
|
||||||
|
* * * *
|
||||||
|
|
||||||
|
- [ ] I searched or browsed the repo’s other issues to ensure this is not a duplicate.
|
|
@ -37,7 +37,7 @@ addons:
|
||||||
|
|
||||||
rvm:
|
rvm:
|
||||||
- 2.4.3
|
- 2.4.3
|
||||||
- 2.5.0
|
- 2.5.1
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- redis-server
|
- redis-server
|
||||||
|
@ -47,6 +47,10 @@ install:
|
||||||
- bundle install --path=vendor/bundle --with pam_authentication --without development production --retry=3 --jobs=16
|
- bundle install --path=vendor/bundle --with pam_authentication --without development production --retry=3 --jobs=16
|
||||||
- yarn install
|
- yarn install
|
||||||
|
|
||||||
|
# https://github.com/travis-ci/travis-ci/issues/9333
|
||||||
|
before_install:
|
||||||
|
- gem install bundler
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- travis_wait ./bin/rails parallel:create parallel:load_schema parallel:prepare assets:precompile
|
- travis_wait ./bin/rails parallel:create parallel:load_schema parallel:prepare assets:precompile
|
||||||
|
|
||||||
|
|
6
Gemfile
6
Gemfile
|
@ -19,7 +19,6 @@ gem 'fog-local', '~> 0.5', require: false
|
||||||
gem 'fog-openstack', '~> 0.1', require: false
|
gem 'fog-openstack', '~> 0.1', require: false
|
||||||
gem 'paperclip', '~> 6.0'
|
gem 'paperclip', '~> 6.0'
|
||||||
gem 'paperclip-av-transcoder', '~> 0.6'
|
gem 'paperclip-av-transcoder', '~> 0.6'
|
||||||
gem 'posix-spawn', '~> 0.3'
|
|
||||||
gem 'streamio-ffmpeg', '~> 3.0'
|
gem 'streamio-ffmpeg', '~> 3.0'
|
||||||
|
|
||||||
gem 'active_model_serializers', '~> 0.10'
|
gem 'active_model_serializers', '~> 0.10'
|
||||||
|
@ -42,7 +41,7 @@ gem 'omniauth-cas', '~> 1.1'
|
||||||
gem 'omniauth-saml', '~> 1.10'
|
gem 'omniauth-saml', '~> 1.10'
|
||||||
gem 'omniauth', '~> 1.2'
|
gem 'omniauth', '~> 1.2'
|
||||||
|
|
||||||
gem 'doorkeeper', '~> 4.3'
|
gem 'doorkeeper', '~> 4.2', '< 4.3'
|
||||||
gem 'fast_blank', '~> 1.0'
|
gem 'fast_blank', '~> 1.0'
|
||||||
gem 'fastimage'
|
gem 'fastimage'
|
||||||
gem 'goldfinger', '~> 2.1'
|
gem 'goldfinger', '~> 2.1'
|
||||||
|
@ -52,6 +51,7 @@ gem 'html2text'
|
||||||
gem 'htmlentities', '~> 4.3'
|
gem 'htmlentities', '~> 4.3'
|
||||||
gem 'http', '~> 3.2'
|
gem 'http', '~> 3.2'
|
||||||
gem 'http_accept_language', '~> 2.1'
|
gem 'http_accept_language', '~> 2.1'
|
||||||
|
gem 'http_parser.rb', '~> 0.6', git: 'https://github.com/tmm1/http_parser.rb', ref: '54b17ba8c7d8d20a16dfc65d1775241833219cf2'
|
||||||
gem 'httplog', '~> 1.0'
|
gem 'httplog', '~> 1.0'
|
||||||
gem 'idn-ruby', require: 'idn'
|
gem 'idn-ruby', require: 'idn'
|
||||||
gem 'kaminari', '~> 1.1'
|
gem 'kaminari', '~> 1.1'
|
||||||
|
@ -62,6 +62,7 @@ gem 'nsa', '~> 0.2'
|
||||||
gem 'oj', '~> 3.5'
|
gem 'oj', '~> 3.5'
|
||||||
gem 'ostatus2', '~> 2.0'
|
gem 'ostatus2', '~> 2.0'
|
||||||
gem 'ox', '~> 2.9'
|
gem 'ox', '~> 2.9'
|
||||||
|
gem 'posix-spawn', git: 'https://github.com/rtomayko/posix-spawn', ref: '58465d2e213991f8afb13b984854a49fcdcc980c'
|
||||||
gem 'pundit', '~> 1.1'
|
gem 'pundit', '~> 1.1'
|
||||||
gem 'premailer-rails'
|
gem 'premailer-rails'
|
||||||
gem 'rack-attack', '~> 5.2'
|
gem 'rack-attack', '~> 5.2'
|
||||||
|
@ -113,7 +114,6 @@ group :test do
|
||||||
gem 'microformats', '~> 4.0'
|
gem 'microformats', '~> 4.0'
|
||||||
gem 'rails-controller-testing', '~> 1.0'
|
gem 'rails-controller-testing', '~> 1.0'
|
||||||
gem 'rspec-sidekiq', '~> 3.0'
|
gem 'rspec-sidekiq', '~> 3.0'
|
||||||
gem 'rspec-retry', '~> 0.5', require: false
|
|
||||||
gem 'simplecov', '~> 0.16', require: false
|
gem 'simplecov', '~> 0.16', require: false
|
||||||
gem 'webmock', '~> 3.3'
|
gem 'webmock', '~> 3.3'
|
||||||
gem 'parallel_tests', '~> 2.21'
|
gem 'parallel_tests', '~> 2.21'
|
||||||
|
|
26
Gemfile.lock
26
Gemfile.lock
|
@ -1,3 +1,17 @@
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/rtomayko/posix-spawn
|
||||||
|
revision: 58465d2e213991f8afb13b984854a49fcdcc980c
|
||||||
|
ref: 58465d2e213991f8afb13b984854a49fcdcc980c
|
||||||
|
specs:
|
||||||
|
posix-spawn (0.3.13)
|
||||||
|
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/tmm1/http_parser.rb
|
||||||
|
revision: 54b17ba8c7d8d20a16dfc65d1775241833219cf2
|
||||||
|
ref: 54b17ba8c7d8d20a16dfc65d1775241833219cf2
|
||||||
|
specs:
|
||||||
|
http_parser.rb (0.6.1)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -167,7 +181,7 @@ GEM
|
||||||
docile (1.3.0)
|
docile (1.3.0)
|
||||||
domain_name (0.5.20180417)
|
domain_name (0.5.20180417)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
doorkeeper (4.3.2)
|
doorkeeper (4.2.6)
|
||||||
railties (>= 4.2)
|
railties (>= 4.2)
|
||||||
dotenv (2.2.2)
|
dotenv (2.2.2)
|
||||||
dotenv-rails (2.2.2)
|
dotenv-rails (2.2.2)
|
||||||
|
@ -254,7 +268,6 @@ GEM
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http-form_data (2.1.0)
|
http-form_data (2.1.0)
|
||||||
http_accept_language (2.1.1)
|
http_accept_language (2.1.1)
|
||||||
http_parser.rb (0.6.0)
|
|
||||||
httplog (1.0.2)
|
httplog (1.0.2)
|
||||||
colorize (~> 0.8)
|
colorize (~> 0.8)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
|
@ -383,7 +396,6 @@ GEM
|
||||||
pghero (2.1.0)
|
pghero (2.1.0)
|
||||||
activerecord
|
activerecord
|
||||||
pkg-config (1.3.0)
|
pkg-config (1.3.0)
|
||||||
posix-spawn (0.3.13)
|
|
||||||
powerpack (0.1.1)
|
powerpack (0.1.1)
|
||||||
premailer (1.11.1)
|
premailer (1.11.1)
|
||||||
addressable
|
addressable
|
||||||
|
@ -503,8 +515,6 @@ GEM
|
||||||
rspec-expectations (~> 3.7.0)
|
rspec-expectations (~> 3.7.0)
|
||||||
rspec-mocks (~> 3.7.0)
|
rspec-mocks (~> 3.7.0)
|
||||||
rspec-support (~> 3.7.0)
|
rspec-support (~> 3.7.0)
|
||||||
rspec-retry (0.5.7)
|
|
||||||
rspec-core (> 3.3)
|
|
||||||
rspec-sidekiq (3.0.3)
|
rspec-sidekiq (3.0.3)
|
||||||
rspec-core (~> 3.0, >= 3.0.0)
|
rspec-core (~> 3.0, >= 3.0.0)
|
||||||
sidekiq (>= 2.4.0)
|
sidekiq (>= 2.4.0)
|
||||||
|
@ -663,7 +673,7 @@ DEPENDENCIES
|
||||||
devise (~> 4.4)
|
devise (~> 4.4)
|
||||||
devise-two-factor (~> 3.0)
|
devise-two-factor (~> 3.0)
|
||||||
devise_pam_authenticatable2 (~> 9.1)
|
devise_pam_authenticatable2 (~> 9.1)
|
||||||
doorkeeper (~> 4.3)
|
doorkeeper (~> 4.2, < 4.3)
|
||||||
dotenv-rails (~> 2.2, < 2.3)
|
dotenv-rails (~> 2.2, < 2.3)
|
||||||
fabrication (~> 2.20)
|
fabrication (~> 2.20)
|
||||||
faker (~> 1.8)
|
faker (~> 1.8)
|
||||||
|
@ -680,6 +690,7 @@ DEPENDENCIES
|
||||||
htmlentities (~> 4.3)
|
htmlentities (~> 4.3)
|
||||||
http (~> 3.2)
|
http (~> 3.2)
|
||||||
http_accept_language (~> 2.1)
|
http_accept_language (~> 2.1)
|
||||||
|
http_parser.rb (~> 0.6)!
|
||||||
httplog (~> 1.0)
|
httplog (~> 1.0)
|
||||||
i18n-tasks (~> 0.9)
|
i18n-tasks (~> 0.9)
|
||||||
idn-ruby
|
idn-ruby
|
||||||
|
@ -709,7 +720,7 @@ DEPENDENCIES
|
||||||
pg (~> 1.0)
|
pg (~> 1.0)
|
||||||
pghero (~> 2.1)
|
pghero (~> 2.1)
|
||||||
pkg-config (~> 1.3)
|
pkg-config (~> 1.3)
|
||||||
posix-spawn (~> 0.3)
|
posix-spawn!
|
||||||
premailer-rails
|
premailer-rails
|
||||||
private_address_check (~> 0.4.1)
|
private_address_check (~> 0.4.1)
|
||||||
pry-byebug (~> 3.6)
|
pry-byebug (~> 3.6)
|
||||||
|
@ -729,7 +740,6 @@ DEPENDENCIES
|
||||||
redis-rails (~> 5.0)
|
redis-rails (~> 5.0)
|
||||||
rqrcode (~> 0.10)
|
rqrcode (~> 0.10)
|
||||||
rspec-rails (~> 3.7)
|
rspec-rails (~> 3.7)
|
||||||
rspec-retry (~> 0.5)
|
|
||||||
rspec-sidekiq (~> 3.0)
|
rspec-sidekiq (~> 3.0)
|
||||||
rubocop (~> 0.55)
|
rubocop (~> 0.55)
|
||||||
ruby-progressbar (~> 1.4)
|
ruby-progressbar (~> 1.4)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class ConfirmationsController < BaseController
|
class ConfirmationsController < BaseController
|
||||||
before_action :set_user
|
before_action :set_user
|
||||||
|
before_action :check_confirmation, only: [:resend]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize @user, :confirm?
|
authorize @user, :confirm?
|
||||||
|
@ -11,10 +12,28 @@ module Admin
|
||||||
redirect_to admin_accounts_path
|
redirect_to admin_accounts_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def resend
|
||||||
|
authorize @user, :confirm?
|
||||||
|
|
||||||
|
@user.resend_confirmation_instructions
|
||||||
|
|
||||||
|
log_action :confirm, @user
|
||||||
|
|
||||||
|
flash[:notice] = I18n.t('admin.accounts.resend_confirmation.success')
|
||||||
|
redirect_to admin_accounts_path
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_user
|
def set_user
|
||||||
@user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
|
@user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_confirmation
|
||||||
|
if @user.confirmed?
|
||||||
|
flash[:error] = I18n.t('admin.accounts.resend_confirmation.already_confirmed')
|
||||||
|
redirect_to admin_accounts_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
module Admin
|
module Admin
|
||||||
class ReportedStatusesController < BaseController
|
class ReportedStatusesController < BaseController
|
||||||
before_action :set_report
|
before_action :set_report
|
||||||
before_action :set_status, only: [:update, :destroy]
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize :status, :update?
|
authorize :status, :update?
|
||||||
|
@ -14,20 +13,6 @@ module Admin
|
||||||
redirect_to admin_report_path(@report)
|
redirect_to admin_report_path(@report)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
|
||||||
authorize @status, :update?
|
|
||||||
@status.update!(status_params)
|
|
||||||
log_action :update, @status
|
|
||||||
redirect_to admin_report_path(@report)
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
authorize @status, :destroy?
|
|
||||||
RemovalWorker.perform_async(@status.id)
|
|
||||||
log_action :destroy, @status
|
|
||||||
render json: @status
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def status_params
|
def status_params
|
||||||
|
@ -51,9 +36,5 @@ module Admin
|
||||||
def set_report
|
def set_report
|
||||||
@report = Report.find(params[:report_id])
|
@report = Report.find(params[:report_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_status
|
|
||||||
@status = @report.statuses.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,6 @@ module Admin
|
||||||
helper_method :current_params
|
helper_method :current_params
|
||||||
|
|
||||||
before_action :set_account
|
before_action :set_account
|
||||||
before_action :set_status, only: [:update, :destroy]
|
|
||||||
|
|
||||||
PER_PAGE = 20
|
PER_PAGE = 20
|
||||||
|
|
||||||
|
@ -26,40 +25,18 @@ module Admin
|
||||||
def create
|
def create
|
||||||
authorize :status, :update?
|
authorize :status, :update?
|
||||||
|
|
||||||
@form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account))
|
@form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account, action: action_from_button))
|
||||||
flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save
|
flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save
|
||||||
|
|
||||||
redirect_to admin_account_statuses_path(@account.id, current_params)
|
redirect_to admin_account_statuses_path(@account.id, current_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
|
||||||
authorize @status, :update?
|
|
||||||
@status.update!(status_params)
|
|
||||||
log_action :update, @status
|
|
||||||
redirect_to admin_account_statuses_path(@account.id, current_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
authorize @status, :destroy?
|
|
||||||
RemovalWorker.perform_async(@status.id)
|
|
||||||
log_action :destroy, @status
|
|
||||||
render json: @status
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def status_params
|
|
||||||
params.require(:status).permit(:sensitive)
|
|
||||||
end
|
|
||||||
|
|
||||||
def form_status_batch_params
|
def form_status_batch_params
|
||||||
params.require(:form_status_batch).permit(:action, status_ids: [])
|
params.require(:form_status_batch).permit(:action, status_ids: [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_status
|
|
||||||
@status = @account.statuses.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
@account = Account.find(params[:account_id])
|
@account = Account.find(params[:account_id])
|
||||||
end
|
end
|
||||||
|
@ -72,5 +49,15 @@ module Admin
|
||||||
page: page > 1 && page,
|
page: page > 1 && page,
|
||||||
}.select { |_, value| value.present? }
|
}.select { |_, value| value.present? }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def action_from_button
|
||||||
|
if params[:nsfw_on]
|
||||||
|
'nsfw_on'
|
||||||
|
elsif params[:nsfw_off]
|
||||||
|
'nsfw_off'
|
||||||
|
elsif params[:delete]
|
||||||
|
'delete'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def account_params
|
def account_params
|
||||||
params.permit(:display_name, :note, :avatar, :header, :locked, fields_attributes: [:name, :value])
|
params.permit(:display_name, :note, :avatar, :header, :locked, :bot, fields_attributes: [:name, :value])
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_settings_params
|
def user_settings_params
|
||||||
|
|
|
@ -19,6 +19,8 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
|
return [] if @account.user_hides_network? && current_account.id != @account.id
|
||||||
|
|
||||||
default_accounts.merge(paginated_follows).to_a
|
default_accounts.merge(paginated_follows).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
|
return [] if @account.user_hides_network? && current_account.id != @account.id
|
||||||
|
|
||||||
default_accounts.merge(paginated_follows).to_a
|
default_accounts.merge(paginated_follows).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,19 +27,17 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_statuses
|
def account_statuses
|
||||||
default_statuses.tap do |statuses|
|
statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses
|
||||||
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
|
statuses = statuses.paginate_by_max_id(
|
||||||
statuses.merge!(pinned_scope) if truthy_param?(:pinned)
|
|
||||||
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def default_statuses
|
|
||||||
permitted_account_statuses.paginate_by_max_id(
|
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||||
params[:max_id],
|
params[:max_id],
|
||||||
params[:since_id]
|
params[:since_id]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
|
||||||
|
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
|
||||||
|
|
||||||
|
statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
def permitted_account_statuses
|
def permitted_account_statuses
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Push::SubscriptionsController < Api::BaseController
|
||||||
|
before_action -> { doorkeeper_authorize! :push }
|
||||||
|
before_action :require_user!
|
||||||
|
before_action :set_web_push_subscription
|
||||||
|
|
||||||
|
def create
|
||||||
|
@web_subscription&.destroy!
|
||||||
|
|
||||||
|
@web_subscription = ::Web::PushSubscription.create!(
|
||||||
|
endpoint: subscription_params[:endpoint],
|
||||||
|
key_p256dh: subscription_params[:keys][:p256dh],
|
||||||
|
key_auth: subscription_params[:keys][:auth],
|
||||||
|
data: data_params,
|
||||||
|
user_id: current_user.id,
|
||||||
|
access_token_id: doorkeeper_token.id
|
||||||
|
)
|
||||||
|
|
||||||
|
render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
raise ActiveRecord::RecordNotFound if @web_subscription.nil?
|
||||||
|
|
||||||
|
render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
raise ActiveRecord::RecordNotFound if @web_subscription.nil?
|
||||||
|
|
||||||
|
@web_subscription.update!(data: data_params)
|
||||||
|
|
||||||
|
render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@web_subscription&.destroy!
|
||||||
|
render_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_web_push_subscription
|
||||||
|
@web_subscription = ::Web::PushSubscription.find_by(access_token_id: doorkeeper_token.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def subscription_params
|
||||||
|
params.require(:subscription).permit(:endpoint, keys: [:auth, :p256dh])
|
||||||
|
end
|
||||||
|
|
||||||
|
def data_params
|
||||||
|
return {} if params[:data].blank?
|
||||||
|
params.require(:data).permit(alerts: [:follow, :favourite, :reblog, :mention])
|
||||||
|
end
|
||||||
|
end
|
|
@ -39,7 +39,7 @@ class Api::V1::Statuses::PinsController < Api::BaseController
|
||||||
adapter: ActivityPub::Adapter
|
adapter: ActivityPub::Adapter
|
||||||
).as_json
|
).as_json
|
||||||
|
|
||||||
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account)
|
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def distribute_remove_activity!
|
def distribute_remove_activity!
|
||||||
|
@ -49,6 +49,6 @@ class Api::V1::Statuses::PinsController < Api::BaseController
|
||||||
adapter: ActivityPub::Adapter
|
adapter: ActivityPub::Adapter
|
||||||
).as_json
|
).as_json
|
||||||
|
|
||||||
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account)
|
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(json), current_account.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,12 @@ class Api::V1::StatusesController < Api::BaseController
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
|
# This API was originally unlimited, pagination cannot be introduced without
|
||||||
|
# breaking backwards-compatibility. Arbitrarily high number to cover most
|
||||||
|
# conversations as quasi-unlimited, it would be too much work to render more
|
||||||
|
# than this anyway
|
||||||
|
CONTEXT_LIMIT = 4_096
|
||||||
|
|
||||||
def show
|
def show
|
||||||
cached = Rails.cache.read(@status.cache_key)
|
cached = Rails.cache.read(@status.cache_key)
|
||||||
@status = cached unless cached.nil?
|
@status = cached unless cached.nil?
|
||||||
|
@ -17,8 +23,8 @@ class Api::V1::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def context
|
def context
|
||||||
ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(DEFAULT_STATUSES_LIMIT, current_account)
|
ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(CONTEXT_LIMIT, current_account)
|
||||||
descendants_results = @status.descendants(DEFAULT_STATUSES_LIMIT, current_account)
|
descendants_results = @status.descendants(CONTEXT_LIMIT, current_account)
|
||||||
loaded_ancestors = cache_collection(ancestors_results, Status)
|
loaded_ancestors = cache_collection(ancestors_results, Status)
|
||||||
loaded_descendants = cache_collection(descendants_results, Status)
|
loaded_descendants = cache_collection(descendants_results, Status)
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,18 @@ class Api::V1::Timelines::DirectController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def direct_statuses
|
def direct_statuses
|
||||||
direct_timeline_statuses.paginate_by_max_id(
|
direct_timeline_statuses
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
|
||||||
params[:max_id],
|
|
||||||
params[:since_id]
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def direct_timeline_statuses
|
def direct_timeline_statuses
|
||||||
Status.as_direct_timeline(current_account)
|
# this query requires built in pagination.
|
||||||
|
Status.as_direct_timeline(
|
||||||
|
current_account,
|
||||||
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||||
|
params[:max_id],
|
||||||
|
params[:since_id],
|
||||||
|
true # returns array of cache_ids object
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
def insert_pagination_headers
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::TrendsController < Api::BaseController
|
||||||
|
before_action :set_tags
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def index
|
||||||
|
render json: @tags, each_serializer: REST::TagSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_tags
|
||||||
|
@tags = TrendingTags.get(limit_param(10))
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V2::SearchController < Api::V1::SearchController
|
||||||
|
def index
|
||||||
|
@search = Search.new(search)
|
||||||
|
render json: @search, serializer: REST::V2::SearchSerializer
|
||||||
|
end
|
||||||
|
end
|
|
@ -31,22 +31,23 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController
|
||||||
endpoint: subscription_params[:endpoint],
|
endpoint: subscription_params[:endpoint],
|
||||||
key_p256dh: subscription_params[:keys][:p256dh],
|
key_p256dh: subscription_params[:keys][:p256dh],
|
||||||
key_auth: subscription_params[:keys][:auth],
|
key_auth: subscription_params[:keys][:auth],
|
||||||
data: data
|
data: data,
|
||||||
|
user_id: active_session.user_id,
|
||||||
|
access_token_id: active_session.access_token_id
|
||||||
)
|
)
|
||||||
|
|
||||||
active_session.update!(web_push_subscription: web_subscription)
|
active_session.update!(web_push_subscription: web_subscription)
|
||||||
|
|
||||||
render json: web_subscription.as_payload
|
render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
params.require([:id])
|
params.require([:id])
|
||||||
|
|
||||||
web_subscription = ::Web::PushSubscription.find(params[:id])
|
web_subscription = ::Web::PushSubscription.find(params[:id])
|
||||||
|
|
||||||
web_subscription.update!(data: data_params)
|
web_subscription.update!(data: data_params)
|
||||||
|
|
||||||
render json: web_subscription.as_payload
|
render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -56,6 +57,6 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def data_params
|
def data_params
|
||||||
@data_params ||= params.require(:data).permit(:alerts)
|
@data_params ||= params.require(:data).permit(alerts: [:follow, :favourite, :reblog, :mention])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
include Localized
|
include Localized
|
||||||
include UserTrackingConcern
|
include UserTrackingConcern
|
||||||
|
include SessionTrackingConcern
|
||||||
|
|
||||||
helper_method :current_account
|
helper_method :current_account
|
||||||
helper_method :current_session
|
helper_method :current_session
|
||||||
|
@ -20,6 +21,7 @@ class ApplicationController < ActionController::Base
|
||||||
rescue_from ActionController::RoutingError, with: :not_found
|
rescue_from ActionController::RoutingError, with: :not_found
|
||||||
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
||||||
rescue_from ActionController::InvalidAuthenticityToken, with: :unprocessable_entity
|
rescue_from ActionController::InvalidAuthenticityToken, with: :unprocessable_entity
|
||||||
|
rescue_from ActionController::UnknownFormat, with: :not_acceptable
|
||||||
rescue_from Mastodon::NotPermittedError, with: :forbidden
|
rescue_from Mastodon::NotPermittedError, with: :forbidden
|
||||||
|
|
||||||
before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
|
before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
|
||||||
|
@ -142,6 +144,10 @@ class ApplicationController < ActionController::Base
|
||||||
respond_with_error(422)
|
respond_with_error(422)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def not_acceptable
|
||||||
|
respond_with_error(406)
|
||||||
|
end
|
||||||
|
|
||||||
def single_user_mode?
|
def single_user_mode?
|
||||||
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.exists?
|
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.exists?
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module SessionTrackingConcern
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
UPDATE_SIGN_IN_HOURS = 24
|
||||||
|
|
||||||
|
included do
|
||||||
|
before_action :set_session_activity
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_session_activity
|
||||||
|
return unless session_needs_update?
|
||||||
|
current_session.touch
|
||||||
|
end
|
||||||
|
|
||||||
|
def session_needs_update?
|
||||||
|
!current_session.nil? && current_session.updated_at < UPDATE_SIGN_IN_HOURS.hours.ago
|
||||||
|
end
|
||||||
|
end
|
|
@ -107,9 +107,7 @@ module SignatureVerification
|
||||||
|
|
||||||
def incompatible_signature?(signature_params)
|
def incompatible_signature?(signature_params)
|
||||||
signature_params['keyId'].blank? ||
|
signature_params['keyId'].blank? ||
|
||||||
signature_params['signature'].blank? ||
|
signature_params['signature'].blank?
|
||||||
signature_params['algorithm'].blank? ||
|
|
||||||
signature_params['algorithm'] != 'rsa-sha256'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_from_key_id(key_id)
|
def account_from_key_id(key_id)
|
||||||
|
|
|
@ -4,16 +4,19 @@ class FollowerAccountsController < ApplicationController
|
||||||
include AccountControllerConcern
|
include AccountControllerConcern
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@follows = Follow.where(target_account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
use_pack 'public'
|
use_pack 'public'
|
||||||
|
|
||||||
@relationships = AccountRelationshipsPresenter.new(@follows.map(&:account_id), current_user.account_id) if user_signed_in?
|
next if @account.user_hides_network?
|
||||||
|
|
||||||
|
follows
|
||||||
|
@relationships = AccountRelationshipsPresenter.new(follows.map(&:account_id), current_user.account_id) if user_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
|
raise Mastodon::NotPermittedError if params[:page].present? && @account.user_hides_network?
|
||||||
|
|
||||||
render json: collection_presenter,
|
render json: collection_presenter,
|
||||||
serializer: ActivityPub::CollectionSerializer,
|
serializer: ActivityPub::CollectionSerializer,
|
||||||
adapter: ActivityPub::Adapter,
|
adapter: ActivityPub::Adapter,
|
||||||
|
@ -24,28 +27,31 @@ class FollowerAccountsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def follows
|
||||||
|
@follows ||= Follow.where(target_account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
|
||||||
|
end
|
||||||
|
|
||||||
def page_url(page)
|
def page_url(page)
|
||||||
account_followers_url(@account, page: page) unless page.nil?
|
account_followers_url(@account, page: page) unless page.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
page = ActivityPub::CollectionPresenter.new(
|
if params[:page].present?
|
||||||
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_followers_url(@account, page: params.fetch(:page, 1)),
|
id: account_followers_url(@account, page: params.fetch(:page, 1)),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.followers_count,
|
size: @account.followers_count,
|
||||||
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) },
|
items: follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.account) },
|
||||||
part_of: account_followers_url(@account),
|
part_of: account_followers_url(@account),
|
||||||
next: page_url(@follows.next_page),
|
next: page_url(follows.next_page),
|
||||||
prev: page_url(@follows.prev_page)
|
prev: page_url(follows.prev_page)
|
||||||
)
|
)
|
||||||
if params[:page].present?
|
|
||||||
page
|
|
||||||
else
|
else
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_followers_url(@account),
|
id: account_followers_url(@account),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.followers_count,
|
size: @account.followers_count,
|
||||||
first: page
|
first: page_url(1)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,16 +4,19 @@ class FollowingAccountsController < ApplicationController
|
||||||
include AccountControllerConcern
|
include AccountControllerConcern
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@follows = Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
use_pack 'public'
|
use_pack 'public'
|
||||||
|
|
||||||
@relationships = AccountRelationshipsPresenter.new(@follows.map(&:target_account_id), current_user.account_id) if user_signed_in?
|
next if @account.user_hides_network?
|
||||||
|
|
||||||
|
follows
|
||||||
|
@relationships = AccountRelationshipsPresenter.new(follows.map(&:target_account_id), current_user.account_id) if user_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
|
raise Mastodon::NotPermittedError if params[:page].present? && @account.user_hides_network?
|
||||||
|
|
||||||
render json: collection_presenter,
|
render json: collection_presenter,
|
||||||
serializer: ActivityPub::CollectionSerializer,
|
serializer: ActivityPub::CollectionSerializer,
|
||||||
adapter: ActivityPub::Adapter,
|
adapter: ActivityPub::Adapter,
|
||||||
|
@ -24,28 +27,31 @@ class FollowingAccountsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def follows
|
||||||
|
@follows ||= Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
|
||||||
|
end
|
||||||
|
|
||||||
def page_url(page)
|
def page_url(page)
|
||||||
account_following_index_url(@account, page: page) unless page.nil?
|
account_following_index_url(@account, page: page) unless page.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
page = ActivityPub::CollectionPresenter.new(
|
if params[:page].present?
|
||||||
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_following_index_url(@account, page: params.fetch(:page, 1)),
|
id: account_following_index_url(@account, page: params.fetch(:page, 1)),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.following_count,
|
size: @account.following_count,
|
||||||
items: @follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) },
|
items: follows.map { |f| ActivityPub::TagManager.instance.uri_for(f.target_account) },
|
||||||
part_of: account_following_index_url(@account),
|
part_of: account_following_index_url(@account),
|
||||||
next: page_url(@follows.next_page),
|
next: page_url(follows.next_page),
|
||||||
prev: page_url(@follows.prev_page)
|
prev: page_url(follows.prev_page)
|
||||||
)
|
)
|
||||||
if params[:page].present?
|
|
||||||
page
|
|
||||||
else
|
else
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_following_index_url(@account),
|
id: account_following_index_url(@account),
|
||||||
type: :ordered,
|
type: :ordered,
|
||||||
size: @account.following_count,
|
size: @account.following_count,
|
||||||
first: page
|
first: page_url(1)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ class InvitesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
authorize :invite, :create?
|
authorize :invite, :create?
|
||||||
|
|
||||||
@invites = Invite.where(user: current_user)
|
@invites = invites
|
||||||
@invite = Invite.new(expires_in: 1.day.to_i)
|
@invite = Invite.new(expires_in: 1.day.to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,13 +24,13 @@ class InvitesController < ApplicationController
|
||||||
if @invite.save
|
if @invite.save
|
||||||
redirect_to invites_path
|
redirect_to invites_path
|
||||||
else
|
else
|
||||||
@invites = Invite.where(user: current_user)
|
@invites = invites
|
||||||
render :index
|
render :index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@invite = Invite.where(user: current_user).find(params[:id])
|
@invite = invites.find(params[:id])
|
||||||
authorize @invite, :destroy?
|
authorize @invite, :destroy?
|
||||||
@invite.expire!
|
@invite.expire!
|
||||||
redirect_to invites_path
|
redirect_to invites_path
|
||||||
|
@ -42,6 +42,10 @@ class InvitesController < ApplicationController
|
||||||
use_pack 'settings'
|
use_pack 'settings'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def invites
|
||||||
|
Invite.where(user: current_user)
|
||||||
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:invite).permit(:max_uses, :expires_in)
|
params.require(:invite).permit(:max_uses, :expires_in)
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,8 @@ class MediaProxyController < ApplicationController
|
||||||
if lock.acquired?
|
if lock.acquired?
|
||||||
@media_attachment = MediaAttachment.remote.find(params[:id])
|
@media_attachment = MediaAttachment.remote.find(params[:id])
|
||||||
redownload! if @media_attachment.needs_redownload? && !reject_media?
|
redownload! if @media_attachment.needs_redownload? && !reject_media?
|
||||||
|
else
|
||||||
|
raise Mastodon::RaceConditionError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,11 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
|
||||||
|
|
||||||
include Localized
|
include Localized
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
Web::PushSubscription.unsubscribe_for(params[:id], current_resource_owner)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def store_current_location
|
def store_current_location
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Oauth::TokensController < Doorkeeper::TokensController
|
||||||
|
def revoke
|
||||||
|
unsubscribe_for_token if authorized? && token.accessible?
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def unsubscribe_for_token
|
||||||
|
Web::PushSubscription.where(access_token_id: token.id).delete_all
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,7 +6,7 @@ class Settings::ApplicationsController < Settings::BaseController
|
||||||
before_action :prepare_scopes, only: [:create, :update]
|
before_action :prepare_scopes, only: [:create, :update]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@applications = current_user.applications.page(params[:page])
|
@applications = current_user.applications.order(id: :desc).page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -40,6 +40,7 @@ class Settings::PreferencesController < Settings::BaseController
|
||||||
:setting_reduce_motion,
|
:setting_reduce_motion,
|
||||||
:setting_system_font_ui,
|
:setting_system_font_ui,
|
||||||
:setting_noindex,
|
:setting_noindex,
|
||||||
|
:setting_hide_network,
|
||||||
notification_emails: %i(follow follow_request reblog favourite mention digest),
|
notification_emails: %i(follow follow_request reblog favourite mention digest),
|
||||||
interactions: %i(must_be_follower must_be_following)
|
interactions: %i(must_be_follower must_be_following)
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Settings::ProfilesController < Settings::BaseController
|
||||||
ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
|
ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
|
||||||
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
|
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
|
||||||
else
|
else
|
||||||
|
@account.build_fields
|
||||||
render :show
|
render :show
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,7 +25,7 @@ class Settings::ProfilesController < Settings::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def account_params
|
def account_params
|
||||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, fields_attributes: [:name, :value])
|
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :bot, fields_attributes: [:name, :value])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
|
|
|
@ -16,6 +16,7 @@ class SharesController < ApplicationController
|
||||||
|
|
||||||
def initial_state_params
|
def initial_state_params
|
||||||
text = [params[:title], params[:text], params[:url]].compact.join(' ')
|
text = [params[:title], params[:text], params[:url]].compact.join(' ')
|
||||||
|
|
||||||
{
|
{
|
||||||
settings: Web::Setting.find_by(user: current_user)&.data || {},
|
settings: Web::Setting.find_by(user: current_user)&.data || {},
|
||||||
push_subscription: current_account.user.web_push_subscription(current_session),
|
push_subscription: current_account.user.web_push_subscription(current_session),
|
||||||
|
|
|
@ -10,10 +10,16 @@ module Admin::AccountModerationNotesHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def admin_account_inline_link_to(account)
|
||||||
|
link_to admin_account_path(account.id), class: name_tag_classes(account, true) do
|
||||||
|
content_tag(:span, account.acct, class: 'username')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def name_tag_classes(account)
|
def name_tag_classes(account, inline = false)
|
||||||
classes = ['name-tag']
|
classes = [inline ? 'inline-name-tag' : 'name-tag']
|
||||||
classes << 'suspended' if account.suspended?
|
classes << 'suspended' if account.suspended?
|
||||||
classes.join(' ')
|
classes.join(' ')
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,18 +52,22 @@ module JsonLdHelper
|
||||||
graph.dump(:normalize)
|
graph.dump(:normalize)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_resource(uri, id)
|
def fetch_resource(uri, id, on_behalf_of = nil)
|
||||||
unless id
|
unless id
|
||||||
json = fetch_resource_without_id_validation(uri)
|
json = fetch_resource_without_id_validation(uri, on_behalf_of)
|
||||||
return unless json
|
return unless json
|
||||||
uri = json['id']
|
uri = json['id']
|
||||||
end
|
end
|
||||||
|
|
||||||
json = fetch_resource_without_id_validation(uri)
|
json = fetch_resource_without_id_validation(uri, on_behalf_of)
|
||||||
json.present? && json['id'] == uri ? json : nil
|
json.present? && json['id'] == uri ? json : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_resource_without_id_validation(uri)
|
def fetch_resource_without_id_validation(uri, on_behalf_of = nil)
|
||||||
|
build_request(uri, on_behalf_of).perform do |response|
|
||||||
|
return body_to_json(response.body_with_limit) if response.code == 200
|
||||||
|
end
|
||||||
|
# If request failed, retry without doing it on behalf of a user
|
||||||
build_request(uri).perform do |response|
|
build_request(uri).perform do |response|
|
||||||
response.code == 200 ? body_to_json(response.body_with_limit) : nil
|
response.code == 200 ? body_to_json(response.body_with_limit) : nil
|
||||||
end
|
end
|
||||||
|
@ -85,8 +89,9 @@ module JsonLdHelper
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def build_request(uri)
|
def build_request(uri, on_behalf_of = nil)
|
||||||
request = Request.new(:get, uri)
|
request = Request.new(:get, uri)
|
||||||
|
request.on_behalf_of(on_behalf_of) if on_behalf_of
|
||||||
request.add_headers('Accept' => 'application/activity+json, application/ld+json')
|
request.add_headers('Accept' => 'application/activity+json, application/ld+json')
|
||||||
request
|
request
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ module SettingsHelper
|
||||||
ar: 'العربية',
|
ar: 'العربية',
|
||||||
bg: 'Български',
|
bg: 'Български',
|
||||||
ca: 'Català',
|
ca: 'Català',
|
||||||
|
co: 'Corsu',
|
||||||
de: 'Deutsch',
|
de: 'Deutsch',
|
||||||
el: 'Ελληνικά',
|
el: 'Ελληνικά',
|
||||||
eo: 'Esperanto',
|
eo: 'Esperanto',
|
||||||
|
@ -32,6 +33,7 @@ module SettingsHelper
|
||||||
'pt-BR': 'Português do Brasil',
|
'pt-BR': 'Português do Brasil',
|
||||||
ru: 'Русский',
|
ru: 'Русский',
|
||||||
sk: 'Slovensky',
|
sk: 'Slovensky',
|
||||||
|
sl: 'Slovenščina',
|
||||||
sr: 'Српски',
|
sr: 'Српски',
|
||||||
'sr-Latn': 'Srpski (latinica)',
|
'sr-Latn': 'Srpski (latinica)',
|
||||||
sv: 'Svenska',
|
sv: 'Svenska',
|
||||||
|
|
|
@ -4,9 +4,13 @@ module StreamEntriesHelper
|
||||||
EMBEDDED_CONTROLLER = 'statuses'
|
EMBEDDED_CONTROLLER = 'statuses'
|
||||||
EMBEDDED_ACTION = 'embed'
|
EMBEDDED_ACTION = 'embed'
|
||||||
|
|
||||||
def display_name(account)
|
def display_name(account, **options)
|
||||||
|
if options[:custom_emojify]
|
||||||
|
Formatter.instance.format_display_name(account, options)
|
||||||
|
else
|
||||||
account.display_name.presence || account.username
|
account.display_name.presence || account.username
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def account_description(account)
|
def account_description(account)
|
||||||
prepend_str = [
|
prepend_str = [
|
||||||
|
|
|
@ -3,14 +3,9 @@ import { CancelToken } from 'axios';
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
import { search as emojiSearch } from 'flavours/glitch/util/emoji/emoji_mart_search_light';
|
import { search as emojiSearch } from 'flavours/glitch/util/emoji/emoji_mart_search_light';
|
||||||
import { useEmoji } from './emojis';
|
import { useEmoji } from './emojis';
|
||||||
|
import resizeImage from 'flavours/glitch/util/resize_image';
|
||||||
|
|
||||||
import {
|
import { updateTimeline } from './timelines';
|
||||||
updateTimeline,
|
|
||||||
refreshHomeTimeline,
|
|
||||||
refreshCommunityTimeline,
|
|
||||||
refreshPublicTimeline,
|
|
||||||
refreshDirectTimeline,
|
|
||||||
} from './timelines';
|
|
||||||
|
|
||||||
let cancelFetchComposeSuggestionsAccounts;
|
let cancelFetchComposeSuggestionsAccounts;
|
||||||
|
|
||||||
|
@ -21,6 +16,7 @@ export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS';
|
||||||
export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL';
|
export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL';
|
||||||
export const COMPOSE_REPLY = 'COMPOSE_REPLY';
|
export const COMPOSE_REPLY = 'COMPOSE_REPLY';
|
||||||
export const COMPOSE_REPLY_CANCEL = 'COMPOSE_REPLY_CANCEL';
|
export const COMPOSE_REPLY_CANCEL = 'COMPOSE_REPLY_CANCEL';
|
||||||
|
export const COMPOSE_DIRECT = 'COMPOSE_DIRECT';
|
||||||
export const COMPOSE_MENTION = 'COMPOSE_MENTION';
|
export const COMPOSE_MENTION = 'COMPOSE_MENTION';
|
||||||
export const COMPOSE_RESET = 'COMPOSE_RESET';
|
export const COMPOSE_RESET = 'COMPOSE_RESET';
|
||||||
export const COMPOSE_UPLOAD_REQUEST = 'COMPOSE_UPLOAD_REQUEST';
|
export const COMPOSE_UPLOAD_REQUEST = 'COMPOSE_UPLOAD_REQUEST';
|
||||||
|
@ -102,6 +98,19 @@ export function mentionCompose(account, router) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function directCompose(account, router) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch({
|
||||||
|
type: COMPOSE_DIRECT,
|
||||||
|
account: account,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!getState().getIn(['compose', 'mounted'])) {
|
||||||
|
router.push('/statuses/new');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export function submitCompose() {
|
export function submitCompose() {
|
||||||
return function (dispatch, getState) {
|
return function (dispatch, getState) {
|
||||||
let status = getState().getIn(['compose', 'text'], '');
|
let status = getState().getIn(['compose', 'text'], '');
|
||||||
|
@ -136,21 +145,19 @@ export function submitCompose() {
|
||||||
|
|
||||||
// To make the app more responsive, immediately get the status into the columns
|
// To make the app more responsive, immediately get the status into the columns
|
||||||
|
|
||||||
const insertOrRefresh = (timelineId, refreshAction) => {
|
const insertIfOnline = (timelineId) => {
|
||||||
if (getState().getIn(['timelines', timelineId, 'online'])) {
|
if (getState().getIn(['timelines', timelineId, 'items', 0]) !== null) {
|
||||||
dispatch(updateTimeline(timelineId, { ...response.data }));
|
dispatch(updateTimeline(timelineId, { ...response.data }));
|
||||||
} else if (getState().getIn(['timelines', timelineId, 'loaded'])) {
|
|
||||||
dispatch(refreshAction());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
insertOrRefresh('home', refreshHomeTimeline);
|
insertIfOnline('home');
|
||||||
|
|
||||||
if (response.data.in_reply_to_id === null && response.data.visibility === 'public') {
|
if (response.data.in_reply_to_id === null && response.data.visibility === 'public') {
|
||||||
insertOrRefresh('community', refreshCommunityTimeline);
|
insertIfOnline('community');
|
||||||
insertOrRefresh('public', refreshPublicTimeline);
|
insertIfOnline('public');
|
||||||
} else if (response.data.visibility === 'direct') {
|
} else if (response.data.visibility === 'direct') {
|
||||||
insertOrRefresh('direct', refreshDirectTimeline);
|
insertIfOnline('direct');
|
||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
dispatch(submitComposeFail(error));
|
dispatch(submitComposeFail(error));
|
||||||
|
@ -193,18 +200,14 @@ export function uploadCompose(files) {
|
||||||
|
|
||||||
dispatch(uploadComposeRequest());
|
dispatch(uploadComposeRequest());
|
||||||
|
|
||||||
let data = new FormData();
|
resizeImage(files[0]).then(file => {
|
||||||
data.append('file', files[0]);
|
const data = new FormData();
|
||||||
|
data.append('file', file);
|
||||||
|
|
||||||
api(getState).post('/api/v1/media', data, {
|
return api(getState).post('/api/v1/media', data, {
|
||||||
onUploadProgress: function (e) {
|
onUploadProgress: ({ loaded, total }) => dispatch(uploadComposeProgress(loaded, total)),
|
||||||
dispatch(uploadComposeProgress(e.loaded, e.total));
|
}).then(({ data }) => dispatch(uploadComposeSuccess(data)));
|
||||||
},
|
}).catch(error => dispatch(uploadComposeFail(error)));
|
||||||
}).then(function (response) {
|
|
||||||
dispatch(uploadComposeSuccess(response.data));
|
|
||||||
}).catch(function (error) {
|
|
||||||
dispatch(uploadComposeFail(error));
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import api, { getLinks } from 'flavours/glitch/util/api';
|
import api, { getLinks } from 'flavours/glitch/util/api';
|
||||||
import { List as ImmutableList } from 'immutable';
|
|
||||||
import IntlMessageFormat from 'intl-messageformat';
|
import IntlMessageFormat from 'intl-messageformat';
|
||||||
import { fetchRelationships } from './accounts';
|
import { fetchRelationships } from './accounts';
|
||||||
import { defineMessages } from 'react-intl';
|
import { defineMessages } from 'react-intl';
|
||||||
|
import { unescapeHTML } from 'flavours/glitch/util/html';
|
||||||
|
|
||||||
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
||||||
|
|
||||||
|
@ -17,10 +17,6 @@ export const NOTIFICATIONS_UNMARK_ALL_FOR_DELETE = 'NOTIFICATIONS_UNMARK_ALL_FOR
|
||||||
// Mark one for delete
|
// Mark one for delete
|
||||||
export const NOTIFICATION_MARK_FOR_DELETE = 'NOTIFICATION_MARK_FOR_DELETE';
|
export const NOTIFICATION_MARK_FOR_DELETE = 'NOTIFICATION_MARK_FOR_DELETE';
|
||||||
|
|
||||||
export const NOTIFICATIONS_REFRESH_REQUEST = 'NOTIFICATIONS_REFRESH_REQUEST';
|
|
||||||
export const NOTIFICATIONS_REFRESH_SUCCESS = 'NOTIFICATIONS_REFRESH_SUCCESS';
|
|
||||||
export const NOTIFICATIONS_REFRESH_FAIL = 'NOTIFICATIONS_REFRESH_FAIL';
|
|
||||||
|
|
||||||
export const NOTIFICATIONS_EXPAND_REQUEST = 'NOTIFICATIONS_EXPAND_REQUEST';
|
export const NOTIFICATIONS_EXPAND_REQUEST = 'NOTIFICATIONS_EXPAND_REQUEST';
|
||||||
export const NOTIFICATIONS_EXPAND_SUCCESS = 'NOTIFICATIONS_EXPAND_SUCCESS';
|
export const NOTIFICATIONS_EXPAND_SUCCESS = 'NOTIFICATIONS_EXPAND_SUCCESS';
|
||||||
export const NOTIFICATIONS_EXPAND_FAIL = 'NOTIFICATIONS_EXPAND_FAIL';
|
export const NOTIFICATIONS_EXPAND_FAIL = 'NOTIFICATIONS_EXPAND_FAIL';
|
||||||
|
@ -40,13 +36,6 @@ const fetchRelatedRelationships = (dispatch, notifications) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const unescapeHTML = (html) => {
|
|
||||||
const wrapper = document.createElement('div');
|
|
||||||
html = html.replace(/<br \/>|<br>|\n/g, ' ');
|
|
||||||
wrapper.innerHTML = html;
|
|
||||||
return wrapper.textContent;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function updateNotifications(notification, intlMessages, intlLocale) {
|
export function updateNotifications(notification, intlMessages, intlLocale) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const showAlert = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true);
|
const showAlert = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true);
|
||||||
|
@ -78,84 +67,37 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
|
||||||
|
|
||||||
const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS();
|
const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS();
|
||||||
|
|
||||||
export function refreshNotifications() {
|
|
||||||
|
const noOp = () => {};
|
||||||
|
|
||||||
|
export function expandNotifications({ maxId } = {}, done = noOp) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const params = {};
|
const notifications = getState().get('notifications');
|
||||||
const ids = getState().getIn(['notifications', 'items']);
|
|
||||||
|
|
||||||
let skipLoading = false;
|
if (notifications.get('isLoading')) {
|
||||||
|
done();
|
||||||
if (ids.size > 0) {
|
|
||||||
params.since_id = ids.first().get('id');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getState().getIn(['notifications', 'loaded'])) {
|
|
||||||
skipLoading = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
params.exclude_types = excludeTypesFromSettings(getState());
|
|
||||||
|
|
||||||
dispatch(refreshNotificationsRequest(skipLoading));
|
|
||||||
|
|
||||||
api(getState).get('/api/v1/notifications', { params }).then(response => {
|
|
||||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
|
||||||
|
|
||||||
dispatch(refreshNotificationsSuccess(response.data, skipLoading, next ? next.uri : null));
|
|
||||||
fetchRelatedRelationships(dispatch, response.data);
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(refreshNotificationsFail(error, skipLoading));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function refreshNotificationsRequest(skipLoading) {
|
|
||||||
return {
|
|
||||||
type: NOTIFICATIONS_REFRESH_REQUEST,
|
|
||||||
skipLoading,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function refreshNotificationsSuccess(notifications, skipLoading, next) {
|
|
||||||
return {
|
|
||||||
type: NOTIFICATIONS_REFRESH_SUCCESS,
|
|
||||||
notifications,
|
|
||||||
accounts: notifications.map(item => item.account),
|
|
||||||
statuses: notifications.map(item => item.status).filter(status => !!status),
|
|
||||||
skipLoading,
|
|
||||||
next,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function refreshNotificationsFail(error, skipLoading) {
|
|
||||||
return {
|
|
||||||
type: NOTIFICATIONS_REFRESH_FAIL,
|
|
||||||
error,
|
|
||||||
skipLoading,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function expandNotifications() {
|
|
||||||
return (dispatch, getState) => {
|
|
||||||
const items = getState().getIn(['notifications', 'items'], ImmutableList());
|
|
||||||
|
|
||||||
if (getState().getIn(['notifications', 'isLoading']) || items.size === 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
max_id: items.last().get('id'),
|
max_id: maxId,
|
||||||
limit: 20,
|
|
||||||
exclude_types: excludeTypesFromSettings(getState()),
|
exclude_types: excludeTypesFromSettings(getState()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!maxId && notifications.get('items').size > 0) {
|
||||||
|
params.since_id = notifications.getIn(['items', 0]);
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(expandNotificationsRequest());
|
dispatch(expandNotificationsRequest());
|
||||||
|
|
||||||
api(getState).get('/api/v1/notifications', { params }).then(response => {
|
api(getState).get('/api/v1/notifications', { params }).then(response => {
|
||||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||||
dispatch(expandNotificationsSuccess(response.data, next ? next.uri : null));
|
dispatch(expandNotificationsSuccess(response.data, next ? next.uri : null));
|
||||||
fetchRelatedRelationships(dispatch, response.data);
|
fetchRelatedRelationships(dispatch, response.data);
|
||||||
|
done();
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(expandNotificationsFail(error));
|
dispatch(expandNotificationsFail(error));
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,13 +56,6 @@ export function register () {
|
||||||
dispatch(setBrowserSupport(supportsPushNotifications));
|
dispatch(setBrowserSupport(supportsPushNotifications));
|
||||||
const me = getState().getIn(['meta', 'me']);
|
const me = getState().getIn(['meta', 'me']);
|
||||||
|
|
||||||
if (me && !pushNotificationsSetting.get(me)) {
|
|
||||||
const alerts = getState().getIn(['push_notifications', 'alerts']);
|
|
||||||
if (alerts) {
|
|
||||||
pushNotificationsSetting.set(me, { alerts: alerts });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (supportsPushNotifications) {
|
if (supportsPushNotifications) {
|
||||||
if (!getApplicationServerKey()) {
|
if (!getApplicationServerKey()) {
|
||||||
console.error('The VAPID public key is not set. You will not be able to receive Web Push Notifications.');
|
console.error('The VAPID public key is not set. You will not be able to receive Web Push Notifications.');
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import api from 'flavours/glitch/util/api';
|
import api from 'flavours/glitch/util/api';
|
||||||
|
import { fetchRelationships } from './accounts';
|
||||||
|
|
||||||
export const SEARCH_CHANGE = 'SEARCH_CHANGE';
|
export const SEARCH_CHANGE = 'SEARCH_CHANGE';
|
||||||
export const SEARCH_CLEAR = 'SEARCH_CLEAR';
|
export const SEARCH_CLEAR = 'SEARCH_CLEAR';
|
||||||
|
@ -38,6 +39,7 @@ export function submitSearch() {
|
||||||
},
|
},
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
dispatch(fetchSearchSuccess(response.data));
|
dispatch(fetchSearchSuccess(response.data));
|
||||||
|
dispatch(fetchRelationships(response.data.accounts.map(item => item.id)));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(fetchSearchFail(error));
|
dispatch(fetchSearchFail(error));
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,11 +2,10 @@ import { connectStream } from 'flavours/glitch/util/stream';
|
||||||
import {
|
import {
|
||||||
updateTimeline,
|
updateTimeline,
|
||||||
deleteFromTimelines,
|
deleteFromTimelines,
|
||||||
refreshHomeTimeline,
|
expandHomeTimeline,
|
||||||
connectTimeline,
|
|
||||||
disconnectTimeline,
|
disconnectTimeline,
|
||||||
} from './timelines';
|
} from './timelines';
|
||||||
import { updateNotifications, refreshNotifications } from './notifications';
|
import { updateNotifications, expandNotifications } from './notifications';
|
||||||
import { getLocale } from 'mastodon/locales';
|
import { getLocale } from 'mastodon/locales';
|
||||||
|
|
||||||
const { messages } = getLocale();
|
const { messages } = getLocale();
|
||||||
|
@ -16,10 +15,6 @@ export function connectTimelineStream (timelineId, path, pollingRefresh = null)
|
||||||
return connectStream (path, pollingRefresh, (dispatch, getState) => {
|
return connectStream (path, pollingRefresh, (dispatch, getState) => {
|
||||||
const locale = getState().getIn(['meta', 'locale']);
|
const locale = getState().getIn(['meta', 'locale']);
|
||||||
return {
|
return {
|
||||||
onConnect() {
|
|
||||||
dispatch(connectTimeline(timelineId));
|
|
||||||
},
|
|
||||||
|
|
||||||
onDisconnect() {
|
onDisconnect() {
|
||||||
dispatch(disconnectTimeline(timelineId));
|
dispatch(disconnectTimeline(timelineId));
|
||||||
},
|
},
|
||||||
|
@ -41,10 +36,9 @@ export function connectTimelineStream (timelineId, path, pollingRefresh = null)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshHomeTimelineAndNotification (dispatch) {
|
const refreshHomeTimelineAndNotification = (dispatch, done) => {
|
||||||
dispatch(refreshHomeTimeline());
|
dispatch(expandHomeTimeline({}, () => dispatch(expandNotifications({}, done))));
|
||||||
dispatch(refreshNotifications());
|
};
|
||||||
}
|
|
||||||
|
|
||||||
export const connectUserStream = () => connectTimelineStream('home', 'user', refreshHomeTimelineAndNotification);
|
export const connectUserStream = () => connectTimelineStream('home', 'user', refreshHomeTimelineAndNotification);
|
||||||
export const connectCommunityStream = () => connectTimelineStream('community', 'public:local');
|
export const connectCommunityStream = () => connectTimelineStream('community', 'public:local');
|
||||||
|
|
|
@ -4,32 +4,16 @@ import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
|
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
|
||||||
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
|
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
|
||||||
|
|
||||||
export const TIMELINE_REFRESH_REQUEST = 'TIMELINE_REFRESH_REQUEST';
|
|
||||||
export const TIMELINE_REFRESH_SUCCESS = 'TIMELINE_REFRESH_SUCCESS';
|
|
||||||
export const TIMELINE_REFRESH_FAIL = 'TIMELINE_REFRESH_FAIL';
|
|
||||||
|
|
||||||
export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
|
export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
|
||||||
export const TIMELINE_EXPAND_SUCCESS = 'TIMELINE_EXPAND_SUCCESS';
|
export const TIMELINE_EXPAND_SUCCESS = 'TIMELINE_EXPAND_SUCCESS';
|
||||||
export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';
|
export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';
|
||||||
|
|
||||||
export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
|
export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
|
||||||
|
|
||||||
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';
|
|
||||||
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
|
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
|
||||||
|
|
||||||
export const TIMELINE_CONTEXT_UPDATE = 'CONTEXT_UPDATE';
|
export const TIMELINE_CONTEXT_UPDATE = 'CONTEXT_UPDATE';
|
||||||
|
|
||||||
export function refreshTimelineSuccess(timeline, statuses, skipLoading, next, partial) {
|
|
||||||
return {
|
|
||||||
type: TIMELINE_REFRESH_SUCCESS,
|
|
||||||
timeline,
|
|
||||||
statuses,
|
|
||||||
skipLoading,
|
|
||||||
next,
|
|
||||||
partial,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function updateTimeline(timeline, status) {
|
export function updateTimeline(timeline, status) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const references = status.reblog ? getState().get('statuses').filter((item, itemId) => (itemId === status.reblog.id || item.get('reblog') === status.reblog.id)).map((_, itemId) => itemId) : [];
|
const references = status.reblog ? getState().get('statuses').filter((item, itemId) => (itemId === status.reblog.id || item.get('reblog') === status.reblog.id)).map((_, itemId) => itemId) : [];
|
||||||
|
@ -77,97 +61,43 @@ export function deleteFromTimelines(id) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function refreshTimelineRequest(timeline, skipLoading) {
|
const noOp = () => {};
|
||||||
return {
|
|
||||||
type: TIMELINE_REFRESH_REQUEST,
|
|
||||||
timeline,
|
|
||||||
skipLoading,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function refreshTimeline(timelineId, path, params = {}) {
|
export function expandTimeline(timelineId, path, params = {}, done = noOp) {
|
||||||
return function (dispatch, getState) {
|
|
||||||
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
|
|
||||||
|
|
||||||
if (timeline.get('isLoading') || (timeline.get('online') && !timeline.get('isPartial'))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ids = timeline.get('items', ImmutableList());
|
|
||||||
const newestId = ids.size > 0 ? ids.first() : null;
|
|
||||||
|
|
||||||
let skipLoading = timeline.get('loaded');
|
|
||||||
|
|
||||||
if (newestId !== null) {
|
|
||||||
params.since_id = newestId;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(refreshTimelineRequest(timelineId, skipLoading));
|
|
||||||
|
|
||||||
api(getState).get(path, { params }).then(response => {
|
|
||||||
if (response.status === 206) {
|
|
||||||
dispatch(refreshTimelineSuccess(timelineId, [], skipLoading, null, true));
|
|
||||||
} else {
|
|
||||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
|
||||||
dispatch(refreshTimelineSuccess(timelineId, response.data, skipLoading, next ? next.uri : null, false));
|
|
||||||
}
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(refreshTimelineFail(timelineId, error, skipLoading));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const refreshHomeTimeline = () => refreshTimeline('home', '/api/v1/timelines/home');
|
|
||||||
export const refreshPublicTimeline = () => refreshTimeline('public', '/api/v1/timelines/public');
|
|
||||||
export const refreshCommunityTimeline = () => refreshTimeline('community', '/api/v1/timelines/public', { local: true });
|
|
||||||
export const refreshDirectTimeline = () => refreshTimeline('direct', '/api/v1/timelines/direct');
|
|
||||||
export const refreshAccountTimeline = (accountId, withReplies) => refreshTimeline(`account:${accountId}${withReplies ? ':with_replies' : ''}`, `/api/v1/accounts/${accountId}/statuses`, { exclude_replies: !withReplies });
|
|
||||||
export const refreshAccountFeaturedTimeline = accountId => refreshTimeline(`account:${accountId}:pinned`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true });
|
|
||||||
export const refreshAccountMediaTimeline = accountId => refreshTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { only_media: true });
|
|
||||||
export const refreshHashtagTimeline = hashtag => refreshTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`);
|
|
||||||
export const refreshListTimeline = id => refreshTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`);
|
|
||||||
|
|
||||||
export function refreshTimelineFail(timeline, error, skipLoading) {
|
|
||||||
return {
|
|
||||||
type: TIMELINE_REFRESH_FAIL,
|
|
||||||
timeline,
|
|
||||||
error,
|
|
||||||
skipLoading,
|
|
||||||
skipAlert: error.response && error.response.status === 404,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function expandTimeline(timelineId, path, params = {}) {
|
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
|
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
|
||||||
const ids = timeline.get('items', ImmutableList());
|
|
||||||
|
|
||||||
if (timeline.get('isLoading') || ids.size === 0) {
|
if (timeline.get('isLoading')) {
|
||||||
|
done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
params.max_id = ids.last();
|
if (!params.max_id && timeline.get('items', ImmutableList()).size > 0) {
|
||||||
params.limit = 10;
|
params.since_id = timeline.getIn(['items', 0]);
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(expandTimelineRequest(timelineId));
|
dispatch(expandTimelineRequest(timelineId));
|
||||||
|
|
||||||
api(getState).get(path, { params }).then(response => {
|
api(getState).get(path, { params }).then(response => {
|
||||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||||
dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null));
|
dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.code === 206));
|
||||||
|
done();
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(expandTimelineFail(timelineId, error));
|
dispatch(expandTimelineFail(timelineId, error));
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const expandHomeTimeline = () => expandTimeline('home', '/api/v1/timelines/home');
|
export const expandHomeTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('home', '/api/v1/timelines/home', { max_id: maxId }, done);
|
||||||
export const expandPublicTimeline = () => expandTimeline('public', '/api/v1/timelines/public');
|
export const expandPublicTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('public', '/api/v1/timelines/public', { max_id: maxId }, done);
|
||||||
export const expandCommunityTimeline = () => expandTimeline('community', '/api/v1/timelines/public', { local: true });
|
export const expandCommunityTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('community', '/api/v1/timelines/public', { local: true, max_id: maxId }, done);
|
||||||
export const expandDirectTimeline = () => expandTimeline('direct', '/api/v1/timelines/direct');
|
export const expandDirectTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('direct', '/api/v1/timelines/direct', { max_id: maxId }, done);
|
||||||
export const expandAccountTimeline = (accountId, withReplies) => expandTimeline(`account:${accountId}${withReplies ? ':with_replies' : ''}`, `/api/v1/accounts/${accountId}/statuses`, { exclude_replies: !withReplies })
|
export const expandAccountTimeline = (accountId, { maxId, withReplies } = {}) => expandTimeline(`account:${accountId}${withReplies ? ':with_replies' : ''}`, `/api/v1/accounts/${accountId}/statuses`, { exclude_replies: !withReplies, max_id: maxId });
|
||||||
export const expandAccountMediaTimeline = accountId => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { only_media: true });
|
export const expandAccountFeaturedTimeline = accountId => expandTimeline(`account:${accountId}:pinned`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true });
|
||||||
export const expandHashtagTimeline = hashtag => expandTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`);
|
export const expandAccountMediaTimeline = (accountId, { maxId } = {}) => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { max_id: maxId, only_media: true });
|
||||||
export const expandListTimeline = id => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`);
|
export const expandHashtagTimeline = (hashtag, { maxId } = {}, done = noOp) => expandTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`, { max_id: maxId }, done);
|
||||||
|
export const expandListTimeline = (id, { maxId } = {}, done = noOp) => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`, { max_id: maxId }, done);
|
||||||
|
|
||||||
export function expandTimelineRequest(timeline) {
|
export function expandTimelineRequest(timeline) {
|
||||||
return {
|
return {
|
||||||
|
@ -176,12 +106,13 @@ export function expandTimelineRequest(timeline) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function expandTimelineSuccess(timeline, statuses, next) {
|
export function expandTimelineSuccess(timeline, statuses, next, partial) {
|
||||||
return {
|
return {
|
||||||
type: TIMELINE_EXPAND_SUCCESS,
|
type: TIMELINE_EXPAND_SUCCESS,
|
||||||
timeline,
|
timeline,
|
||||||
statuses,
|
statuses,
|
||||||
next,
|
next,
|
||||||
|
partial,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -201,13 +132,6 @@ export function scrollTopTimeline(timeline, top) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function connectTimeline(timeline) {
|
|
||||||
return {
|
|
||||||
type: TIMELINE_CONNECT,
|
|
||||||
timeline,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function disconnectTimeline(timeline) {
|
export function disconnectTimeline(timeline) {
|
||||||
return {
|
return {
|
||||||
type: TIMELINE_DISCONNECT,
|
type: TIMELINE_DISCONNECT,
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { injectIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
load_more: { id: 'status.load_more', defaultMessage: 'Load more' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@injectIntl
|
||||||
|
export default class LoadGap extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
disabled: PropTypes.bool,
|
||||||
|
maxId: PropTypes.string,
|
||||||
|
onClick: PropTypes.func.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClick = () => {
|
||||||
|
this.props.onClick(this.props.maxId);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { disabled, intl } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button className='load-more load-gap' disabled={disabled} onClick={this.handleClick} aria-label={intl.formatMessage(messages.load_more)}>
|
||||||
|
<i className='fa fa-ellipsis-h' />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ export default class LoadMore extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
|
disabled: PropTypes.bool,
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +15,10 @@ export default class LoadMore extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { visible } = this.props;
|
const { disabled, visible } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button className='load-more' disabled={!visible} style={{ visibility: visible ? 'visible' : 'hidden' }} onClick={this.props.onClick}>
|
<button className='load-more' disabled={disabled || !visible} style={{ visibility: visible ? 'visible' : 'hidden' }} onClick={this.props.onClick}>
|
||||||
<FormattedMessage id='status.load_more' defaultMessage='Load more' />
|
<FormattedMessage id='status.load_more' defaultMessage='Load more' />
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,6 +40,7 @@ class Item extends React.PureComponent {
|
||||||
size: PropTypes.number.isRequired,
|
size: PropTypes.number.isRequired,
|
||||||
letterbox: PropTypes.bool,
|
letterbox: PropTypes.bool,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
|
displayWidth: PropTypes.number,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
@ -78,7 +79,7 @@ class Item extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { attachment, index, size, standalone, letterbox } = this.props;
|
const { attachment, index, size, standalone, letterbox, displayWidth } = this.props;
|
||||||
|
|
||||||
let width = 50;
|
let width = 50;
|
||||||
let height = 100;
|
let height = 100;
|
||||||
|
@ -141,7 +142,7 @@ class Item extends React.PureComponent {
|
||||||
const hasSize = typeof originalWidth === 'number' && typeof previewWidth === 'number';
|
const hasSize = typeof originalWidth === 'number' && typeof previewWidth === 'number';
|
||||||
|
|
||||||
const srcSet = hasSize ? `${originalUrl} ${originalWidth}w, ${previewUrl} ${previewWidth}w` : null;
|
const srcSet = hasSize ? `${originalUrl} ${originalWidth}w, ${previewUrl} ${previewWidth}w` : null;
|
||||||
const sizes = hasSize ? `(min-width: 1025px) ${320 * (width / 100)}px, ${width}vw` : null;
|
const sizes = hasSize ? `${displayWidth * (width / 100)}px` : null;
|
||||||
|
|
||||||
const focusX = attachment.getIn(['meta', 'focus', 'x']) || 0;
|
const focusX = attachment.getIn(['meta', 'focus', 'x']) || 0;
|
||||||
const focusY = attachment.getIn(['meta', 'focus', 'y']) || 0;
|
const focusY = attachment.getIn(['meta', 'focus', 'y']) || 0;
|
||||||
|
@ -235,7 +236,7 @@ export default class MediaGallery extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRef = (node) => {
|
handleRef = (node) => {
|
||||||
if (node && this.isStandaloneEligible()) {
|
if (node /*&& this.isStandaloneEligible()*/) {
|
||||||
// offsetWidth triggers a layout, so only calculate when we need to
|
// offsetWidth triggers a layout, so only calculate when we need to
|
||||||
this.setState({
|
this.setState({
|
||||||
width: node.offsetWidth,
|
width: node.offsetWidth,
|
||||||
|
@ -272,9 +273,9 @@ export default class MediaGallery extends React.PureComponent {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (this.isStandaloneEligible()) {
|
if (this.isStandaloneEligible()) {
|
||||||
children = <Item standalone attachment={media.get(0)} onClick={this.handleClick} />;
|
children = <Item standalone attachment={media.get(0)} onClick={this.handleClick} displayWidth={width} />;
|
||||||
} else {
|
} else {
|
||||||
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} letterbox={letterbox} />);
|
children = media.take(4).map((attachment, i) => <Item key={attachment.get('id')} onClick={this.handleClick} attachment={attachment} index={i} size={size} letterbox={letterbox} displayWidth={width} />);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
|
noEsc: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -16,7 +17,7 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
|
|
||||||
handleKeyUp = (e) => {
|
handleKeyUp = (e) => {
|
||||||
if ((e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27)
|
if ((e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27)
|
||||||
&& !!this.props.children && !this.props.props.noEsc) {
|
&& !!this.props.children && !this.props.noEsc) {
|
||||||
this.props.onClose();
|
this.props.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default class ScrollableList extends PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
scrollKey: PropTypes.string.isRequired,
|
scrollKey: PropTypes.string.isRequired,
|
||||||
onScrollToBottom: PropTypes.func,
|
onLoadMore: PropTypes.func,
|
||||||
onScrollToTop: PropTypes.func,
|
onScrollToTop: PropTypes.func,
|
||||||
onScroll: PropTypes.func,
|
onScroll: PropTypes.func,
|
||||||
trackScroll: PropTypes.bool,
|
trackScroll: PropTypes.bool,
|
||||||
|
@ -44,9 +44,11 @@ export default class ScrollableList extends PureComponent {
|
||||||
const { scrollTop, scrollHeight, clientHeight } = this.node;
|
const { scrollTop, scrollHeight, clientHeight } = this.node;
|
||||||
const offset = scrollHeight - scrollTop - clientHeight;
|
const offset = scrollHeight - scrollTop - clientHeight;
|
||||||
|
|
||||||
if (400 > offset && this.props.onScrollToBottom && !this.props.isLoading) {
|
if (400 > offset && this.props.onLoadMore && !this.props.isLoading) {
|
||||||
this.props.onScrollToBottom();
|
this.props.onLoadMore();
|
||||||
} else if (scrollTop < 100 && this.props.onScrollToTop) {
|
}
|
||||||
|
|
||||||
|
if (scrollTop < 100 && this.props.onScrollToTop) {
|
||||||
this.props.onScrollToTop();
|
this.props.onScrollToTop();
|
||||||
} else if (this.props.onScroll) {
|
} else if (this.props.onScroll) {
|
||||||
this.props.onScroll();
|
this.props.onScroll();
|
||||||
|
@ -144,15 +146,15 @@ export default class ScrollableList extends PureComponent {
|
||||||
|
|
||||||
handleLoadMore = (e) => {
|
handleLoadMore = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.props.onScrollToBottom();
|
this.props.onLoadMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { children, scrollKey, trackScroll, shouldUpdateScroll, isLoading, hasMore, prepend, emptyMessage } = this.props;
|
const { children, scrollKey, trackScroll, shouldUpdateScroll, isLoading, hasMore, prepend, emptyMessage, onLoadMore } = this.props;
|
||||||
const { fullscreen } = this.state;
|
const { fullscreen } = this.state;
|
||||||
const childrenCount = React.Children.count(children);
|
const childrenCount = React.Children.count(children);
|
||||||
|
|
||||||
const loadMore = (hasMore && childrenCount > 0) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
const loadMore = (hasMore && childrenCount > 0 && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
||||||
let scrollableArea = null;
|
let scrollableArea = null;
|
||||||
|
|
||||||
if (isLoading || childrenCount > 0 || !emptyMessage) {
|
if (isLoading || childrenCount > 0 || !emptyMessage) {
|
||||||
|
|
|
@ -32,6 +32,8 @@ export default class Status extends ImmutablePureComponent {
|
||||||
onFavourite: PropTypes.func,
|
onFavourite: PropTypes.func,
|
||||||
onReblog: PropTypes.func,
|
onReblog: PropTypes.func,
|
||||||
onDelete: PropTypes.func,
|
onDelete: PropTypes.func,
|
||||||
|
onDirect: PropTypes.func,
|
||||||
|
onMention: PropTypes.func,
|
||||||
onPin: PropTypes.func,
|
onPin: PropTypes.func,
|
||||||
onOpenMedia: PropTypes.func,
|
onOpenMedia: PropTypes.func,
|
||||||
onOpenVideo: PropTypes.func,
|
onOpenVideo: PropTypes.func,
|
||||||
|
@ -257,8 +259,8 @@ export default class Status extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleOpenVideo = startTime => {
|
handleOpenVideo = (media, startTime) => {
|
||||||
this.props.onOpenVideo(this.props.status.getIn(['media_attachments', 0]), startTime);
|
this.props.onOpenVideo(media, startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyReply = e => {
|
handleHotkeyReply = e => {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import RelativeTimestamp from './relative_timestamp';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
||||||
|
direct: { id: 'status.direct', defaultMessage: 'Direct message @{name}' },
|
||||||
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
|
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
|
||||||
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
||||||
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
|
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
|
||||||
|
@ -44,6 +45,7 @@ export default class StatusActionBar extends ImmutablePureComponent {
|
||||||
onFavourite: PropTypes.func,
|
onFavourite: PropTypes.func,
|
||||||
onReblog: PropTypes.func,
|
onReblog: PropTypes.func,
|
||||||
onDelete: PropTypes.func,
|
onDelete: PropTypes.func,
|
||||||
|
onDirect: PropTypes.func,
|
||||||
onMention: PropTypes.func,
|
onMention: PropTypes.func,
|
||||||
onMute: PropTypes.func,
|
onMute: PropTypes.func,
|
||||||
onBlock: PropTypes.func,
|
onBlock: PropTypes.func,
|
||||||
|
@ -98,6 +100,10 @@ export default class StatusActionBar extends ImmutablePureComponent {
|
||||||
this.props.onMention(this.props.status.get('account'), this.context.router.history);
|
this.props.onMention(this.props.status.get('account'), this.context.router.history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDirectClick = () => {
|
||||||
|
this.props.onDirect(this.props.status.get('account'), this.context.router.history);
|
||||||
|
}
|
||||||
|
|
||||||
handleMuteClick = () => {
|
handleMuteClick = () => {
|
||||||
this.props.onMute(this.props.status.get('account'));
|
this.props.onMute(this.props.status.get('account'));
|
||||||
}
|
}
|
||||||
|
@ -157,6 +163,7 @@ export default class StatusActionBar extends ImmutablePureComponent {
|
||||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
||||||
} else {
|
} else {
|
||||||
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
||||||
|
menu.push({ text: intl.formatMessage(messages.direct, { name: status.getIn(['account', 'username']) }), action: this.handleDirectClick });
|
||||||
menu.push(null);
|
menu.push(null);
|
||||||
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
||||||
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
||||||
|
|
|
@ -98,7 +98,7 @@ export default class StatusContent extends React.PureComponent {
|
||||||
const [ startX, startY ] = this.startXY;
|
const [ startX, startY ] = this.startXY;
|
||||||
const [ deltaX, deltaY ] = [Math.abs(e.clientX - startX), Math.abs(e.clientY - startY)];
|
const [ deltaX, deltaY ] = [Math.abs(e.clientX - startX), Math.abs(e.clientY - startY)];
|
||||||
|
|
||||||
if (e.target.localName === 'button' || e.target.localName === 'a' || (e.target.parentNode && (e.target.parentNode.localName === 'button' || e.target.parentNode.localName === 'a'))) {
|
if (e.target.localName === 'button' || e.target.localName == 'video' || e.target.localName === 'a' || (e.target.parentNode && (e.target.parentNode.localName === 'button' || e.target.parentNode.localName === 'a'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,11 +188,9 @@ export default class StatusContent extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames} tabIndex='0'>
|
<div className={classNames} tabIndex='0' onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}>
|
||||||
<p
|
<p
|
||||||
style={{ marginBottom: hidden && status.get('mentions').isEmpty() ? '0px' : null }}
|
style={{ marginBottom: hidden && status.get('mentions').isEmpty() ? '0px' : null }}
|
||||||
onMouseDown={this.handleMouseDown}
|
|
||||||
onMouseUp={this.handleMouseUp}
|
|
||||||
>
|
>
|
||||||
<span dangerouslySetInnerHTML={spoilerContent} />
|
<span dangerouslySetInnerHTML={spoilerContent} />
|
||||||
{' '}
|
{' '}
|
||||||
|
@ -208,8 +206,6 @@ export default class StatusContent extends React.PureComponent {
|
||||||
ref={this.setRef}
|
ref={this.setRef}
|
||||||
style={directionStyle}
|
style={directionStyle}
|
||||||
tabIndex={!hidden ? 0 : null}
|
tabIndex={!hidden ? 0 : null}
|
||||||
onMouseDown={this.handleMouseDown}
|
|
||||||
onMouseUp={this.handleMouseUp}
|
|
||||||
dangerouslySetInnerHTML={content}
|
dangerouslySetInnerHTML={content}
|
||||||
/>
|
/>
|
||||||
{media}
|
{media}
|
||||||
|
@ -222,12 +218,12 @@ export default class StatusContent extends React.PureComponent {
|
||||||
<div
|
<div
|
||||||
className={classNames}
|
className={classNames}
|
||||||
style={directionStyle}
|
style={directionStyle}
|
||||||
|
onMouseDown={this.handleMouseDown}
|
||||||
|
onMouseUp={this.handleMouseUp}
|
||||||
tabIndex='0'
|
tabIndex='0'
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={this.setRef}
|
ref={this.setRef}
|
||||||
onMouseDown={this.handleMouseDown}
|
|
||||||
onMouseUp={this.handleMouseUp}
|
|
||||||
dangerouslySetInnerHTML={content}
|
dangerouslySetInnerHTML={content}
|
||||||
tabIndex='0'
|
tabIndex='0'
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
import { debounce } from 'lodash';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import StatusContainer from 'flavours/glitch/containers/status_container';
|
import StatusContainer from 'flavours/glitch/containers/status_container';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
import LoadGap from './load_gap';
|
||||||
import ScrollableList from './scrollable_list';
|
import ScrollableList from './scrollable_list';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
@ -12,7 +14,7 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
scrollKey: PropTypes.string.isRequired,
|
scrollKey: PropTypes.string.isRequired,
|
||||||
statusIds: ImmutablePropTypes.list.isRequired,
|
statusIds: ImmutablePropTypes.list.isRequired,
|
||||||
featuredStatusIds: ImmutablePropTypes.list,
|
featuredStatusIds: ImmutablePropTypes.list,
|
||||||
onScrollToBottom: PropTypes.func,
|
onLoadMore: PropTypes.func,
|
||||||
onScrollToTop: PropTypes.func,
|
onScrollToTop: PropTypes.func,
|
||||||
onScroll: PropTypes.func,
|
onScroll: PropTypes.func,
|
||||||
trackScroll: PropTypes.bool,
|
trackScroll: PropTypes.bool,
|
||||||
|
@ -50,6 +52,10 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
this._selectChild(elementIndex);
|
this._selectChild(elementIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleLoadOlder = debounce(() => {
|
||||||
|
this.props.onLoadMore(this.props.statusIds.last());
|
||||||
|
}, 300, { leading: true })
|
||||||
|
|
||||||
_selectChild (index) {
|
_selectChild (index) {
|
||||||
const element = this.node.node.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
|
const element = this.node.node.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
|
||||||
|
|
||||||
|
@ -63,7 +69,7 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { statusIds, featuredStatusIds, ...other } = this.props;
|
const { statusIds, featuredStatusIds, onLoadMore, ...other } = this.props;
|
||||||
const { isLoading, isPartial } = other;
|
const { isLoading, isPartial } = other;
|
||||||
|
|
||||||
if (isPartial) {
|
if (isPartial) {
|
||||||
|
@ -82,7 +88,14 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
let scrollableContent = (isLoading || statusIds.size > 0) ? (
|
let scrollableContent = (isLoading || statusIds.size > 0) ? (
|
||||||
statusIds.map(statusId => (
|
statusIds.map((statusId, index) => statusId === null ? (
|
||||||
|
<LoadGap
|
||||||
|
key={'gap:' + statusIds.get(index + 1)}
|
||||||
|
disabled={isLoading}
|
||||||
|
maxId={index > 0 ? statusIds.get(index - 1) : null}
|
||||||
|
onClick={onLoadMore}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<StatusContainer
|
<StatusContainer
|
||||||
key={statusId}
|
key={statusId}
|
||||||
id={statusId}
|
id={statusId}
|
||||||
|
@ -105,7 +118,7 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollableList {...other} ref={this.setRef}>
|
<ScrollableList {...other} onLoadMore={onLoadMore && this.handleLoadOlder} ref={this.setRef}>
|
||||||
{scrollableContent}
|
{scrollableContent}
|
||||||
</ScrollableList>
|
</ScrollableList>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Card from 'flavours/glitch/features/status/components/card';
|
|
||||||
import { fromJS } from 'immutable';
|
|
||||||
|
|
||||||
export default class CardContainer extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
locale: PropTypes.string,
|
|
||||||
card: PropTypes.array.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { card, ...props } = this.props;
|
|
||||||
return <Card card={fromJS(card)} {...props} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
import React, { PureComponent, Fragment } from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
||||||
|
import { getLocale } from 'mastodon/locales';
|
||||||
|
import MediaGallery from 'flavours/glitch/components/media_gallery';
|
||||||
|
import Video from 'flavours/glitch/features/video';
|
||||||
|
import Card from 'flavours/glitch/features/status/components/card';
|
||||||
|
import ModalRoot from 'flavours/glitch/components/modal_root';
|
||||||
|
import MediaModal from 'flavours/glitch/features/ui/components/media_modal';
|
||||||
|
import { List as ImmutableList, fromJS } from 'immutable';
|
||||||
|
|
||||||
|
const { localeData, messages } = getLocale();
|
||||||
|
addLocaleData(localeData);
|
||||||
|
|
||||||
|
const MEDIA_COMPONENTS = { MediaGallery, Video, Card };
|
||||||
|
|
||||||
|
export default class MediaContainer extends PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
locale: PropTypes.string.isRequired,
|
||||||
|
components: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
media: null,
|
||||||
|
index: null,
|
||||||
|
time: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleOpenMedia = (media, index) => {
|
||||||
|
document.body.classList.add('media-standalone__body');
|
||||||
|
this.setState({ media, index });
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOpenVideo = (video, time) => {
|
||||||
|
const media = ImmutableList([video]);
|
||||||
|
|
||||||
|
document.body.classList.add('media-standalone__body');
|
||||||
|
this.setState({ media, time });
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCloseMedia = () => {
|
||||||
|
document.body.classList.remove('media-standalone__body');
|
||||||
|
this.setState({ media: null, index: null, time: null });
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { locale, components } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IntlProvider locale={locale} messages={messages}>
|
||||||
|
<Fragment>
|
||||||
|
{[].map.call(components, (component, i) => {
|
||||||
|
const componentName = component.getAttribute('data-component');
|
||||||
|
const Component = MEDIA_COMPONENTS[componentName];
|
||||||
|
const { media, card, ...props } = JSON.parse(component.getAttribute('data-props'));
|
||||||
|
|
||||||
|
Object.assign(props, {
|
||||||
|
...(media ? { media: fromJS(media) } : {}),
|
||||||
|
...(card ? { card: fromJS(card) } : {}),
|
||||||
|
|
||||||
|
...(componentName === 'Video' ? {
|
||||||
|
onOpenVideo: this.handleOpenVideo,
|
||||||
|
} : {
|
||||||
|
onOpenMedia: this.handleOpenMedia,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
return ReactDOM.createPortal(
|
||||||
|
<Component {...props} key={`media-${i}`} />,
|
||||||
|
component,
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
<ModalRoot onClose={this.handleCloseMedia}>
|
||||||
|
{this.state.media && (
|
||||||
|
<MediaModal
|
||||||
|
media={this.state.media}
|
||||||
|
index={this.state.index || 0}
|
||||||
|
time={this.state.time}
|
||||||
|
onClose={this.handleCloseMedia}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ModalRoot>
|
||||||
|
</Fragment>
|
||||||
|
</IntlProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,68 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { IntlProvider, addLocaleData } from 'react-intl';
|
|
||||||
import { getLocale } from 'mastodon/locales';
|
|
||||||
import MediaGallery from 'flavours/glitch/components/media_gallery';
|
|
||||||
import ModalRoot from 'flavours/glitch/components/modal_root';
|
|
||||||
import MediaModal from 'flavours/glitch/features/ui/components/media_modal';
|
|
||||||
import { fromJS } from 'immutable';
|
|
||||||
|
|
||||||
const { localeData, messages } = getLocale();
|
|
||||||
addLocaleData(localeData);
|
|
||||||
|
|
||||||
export default class MediaGalleriesContainer extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
locale: PropTypes.string.isRequired,
|
|
||||||
galleries: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
media: null,
|
|
||||||
index: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleOpenMedia = (media, index) => {
|
|
||||||
document.body.classList.add('media-gallery-standalone__body');
|
|
||||||
this.setState({ media, index });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleCloseMedia = () => {
|
|
||||||
document.body.classList.remove('media-gallery-standalone__body');
|
|
||||||
this.setState({ media: null, index: null });
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { locale, galleries } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<IntlProvider locale={locale} messages={messages}>
|
|
||||||
<React.Fragment>
|
|
||||||
{[].map.call(galleries, gallery => {
|
|
||||||
const { media, ...props } = JSON.parse(gallery.getAttribute('data-props'));
|
|
||||||
|
|
||||||
return ReactDOM.createPortal(
|
|
||||||
<MediaGallery
|
|
||||||
{...props}
|
|
||||||
media={fromJS(media)}
|
|
||||||
onOpenMedia={this.handleOpenMedia}
|
|
||||||
/>,
|
|
||||||
gallery
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
<ModalRoot onClose={this.handleCloseMedia}>
|
|
||||||
{this.state.media === null || this.state.index === null ? null : (
|
|
||||||
<MediaModal
|
|
||||||
media={this.state.media}
|
|
||||||
index={this.state.index}
|
|
||||||
onClose={this.handleCloseMedia}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</ModalRoot>
|
|
||||||
</React.Fragment>
|
|
||||||
</IntlProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -5,6 +5,7 @@ import { makeGetStatus } from 'flavours/glitch/selectors';
|
||||||
import {
|
import {
|
||||||
replyCompose,
|
replyCompose,
|
||||||
mentionCompose,
|
mentionCompose,
|
||||||
|
directCompose,
|
||||||
} from 'flavours/glitch/actions/compose';
|
} from 'flavours/glitch/actions/compose';
|
||||||
import {
|
import {
|
||||||
reblog,
|
reblog,
|
||||||
|
@ -131,6 +132,10 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onDirect (account, router) {
|
||||||
|
dispatch(directCompose(account, router));
|
||||||
|
},
|
||||||
|
|
||||||
onMention (account, router) {
|
onMention (account, router) {
|
||||||
dispatch(mentionCompose(account, router));
|
dispatch(mentionCompose(account, router));
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { hydrateStore } from 'flavours/glitch/actions/store';
|
||||||
import { IntlProvider, addLocaleData } from 'react-intl';
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
||||||
import { getLocale } from 'mastodon/locales';
|
import { getLocale } from 'mastodon/locales';
|
||||||
import PublicTimeline from 'flavours/glitch/features/standalone/public_timeline';
|
import PublicTimeline from 'flavours/glitch/features/standalone/public_timeline';
|
||||||
|
import CommunityTimeline from 'flavours/glitch/features/standalone/community_timeline';
|
||||||
import HashtagTimeline from 'flavours/glitch/features/standalone/hashtag_timeline';
|
import HashtagTimeline from 'flavours/glitch/features/standalone/hashtag_timeline';
|
||||||
import initialState from 'flavours/glitch/util/initial_state';
|
import initialState from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
|
@ -23,17 +24,24 @@ export default class TimelineContainer extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
locale: PropTypes.string.isRequired,
|
locale: PropTypes.string.isRequired,
|
||||||
hashtag: PropTypes.string,
|
hashtag: PropTypes.string,
|
||||||
|
showPublicTimeline: PropTypes.bool.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
showPublicTimeline: initialState.settings.known_fediverse,
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { locale, hashtag } = this.props;
|
const { locale, hashtag, showPublicTimeline } = this.props;
|
||||||
|
|
||||||
let timeline;
|
let timeline;
|
||||||
|
|
||||||
if (hashtag) {
|
if (hashtag) {
|
||||||
timeline = <HashtagTimeline hashtag={hashtag} />;
|
timeline = <HashtagTimeline hashtag={hashtag} />;
|
||||||
} else {
|
} else if (showPublicTimeline) {
|
||||||
timeline = <PublicTimeline />;
|
timeline = <PublicTimeline />;
|
||||||
|
} else {
|
||||||
|
timeline = <CommunityTimeline />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { IntlProvider, addLocaleData } from 'react-intl';
|
|
||||||
import { getLocale } from 'mastodon/locales';
|
|
||||||
import Video from 'flavours/glitch/features/video';
|
|
||||||
|
|
||||||
const { localeData, messages } = getLocale();
|
|
||||||
addLocaleData(localeData);
|
|
||||||
|
|
||||||
export default class VideoContainer extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
locale: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { locale, ...props } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<IntlProvider locale={locale} messages={messages}>
|
|
||||||
<Video {...props} />
|
|
||||||
</IntlProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -8,6 +8,7 @@ import { me } from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' },
|
mention: { id: 'account.mention', defaultMessage: 'Mention @{name}' },
|
||||||
|
direct: { id: 'account.direct', defaultMessage: 'Direct message @{name}' },
|
||||||
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
||||||
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
|
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
|
||||||
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
||||||
|
@ -32,6 +33,7 @@ export default class ActionBar extends React.PureComponent {
|
||||||
onFollow: PropTypes.func,
|
onFollow: PropTypes.func,
|
||||||
onBlock: PropTypes.func.isRequired,
|
onBlock: PropTypes.func.isRequired,
|
||||||
onMention: PropTypes.func.isRequired,
|
onMention: PropTypes.func.isRequired,
|
||||||
|
onDirect: PropTypes.func.isRequired,
|
||||||
onReblogToggle: PropTypes.func.isRequired,
|
onReblogToggle: PropTypes.func.isRequired,
|
||||||
onReport: PropTypes.func.isRequired,
|
onReport: PropTypes.func.isRequired,
|
||||||
onMute: PropTypes.func.isRequired,
|
onMute: PropTypes.func.isRequired,
|
||||||
|
@ -53,6 +55,7 @@ export default class ActionBar extends React.PureComponent {
|
||||||
let extraInfo = '';
|
let extraInfo = '';
|
||||||
|
|
||||||
menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.props.onMention });
|
menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.props.onMention });
|
||||||
|
menu.push({ text: intl.formatMessage(messages.direct, { name: account.get('username') }), action: this.props.onDirect });
|
||||||
|
|
||||||
if ('share' in navigator) {
|
if ('share' in navigator) {
|
||||||
menu.push({ text: intl.formatMessage(messages.share, { name: account.get('username') }), action: this.handleShare });
|
menu.push({ text: intl.formatMessage(messages.share, { name: account.get('username') }), action: this.handleShare });
|
||||||
|
|
|
@ -38,6 +38,8 @@ export default class Header extends ImmutablePureComponent {
|
||||||
|
|
||||||
let displayName = account.get('display_name_html');
|
let displayName = account.get('display_name_html');
|
||||||
let fields = account.get('fields');
|
let fields = account.get('fields');
|
||||||
|
let badge = account.get('bot') ? (<div className='roles'><div className='account-role bot'><FormattedMessage id='account.badges.bot' defaultMessage='Bot' /></div></div>) : null;
|
||||||
|
|
||||||
let info = '';
|
let info = '';
|
||||||
let mutingInfo = '';
|
let mutingInfo = '';
|
||||||
let actionBtn = '';
|
let actionBtn = '';
|
||||||
|
@ -99,38 +101,31 @@ export default class Header extends ImmutablePureComponent {
|
||||||
|
|
||||||
<span className='account__header__display-name' dangerouslySetInnerHTML={{ __html: displayName }} />
|
<span className='account__header__display-name' dangerouslySetInnerHTML={{ __html: displayName }} />
|
||||||
<span className='account__header__username'>@{account.get('acct')} {account.get('locked') ? <i className='fa fa-lock' /> : null}</span>
|
<span className='account__header__username'>@{account.get('acct')} {account.get('locked') ? <i className='fa fa-lock' /> : null}</span>
|
||||||
|
|
||||||
|
{badge}
|
||||||
|
|
||||||
<div className='account__header__content' dangerouslySetInnerHTML={{ __html: emojify(text) }} />
|
<div className='account__header__content' dangerouslySetInnerHTML={{ __html: emojify(text) }} />
|
||||||
|
|
||||||
{fields.size > 0 && (
|
{fields.size > 0 && (
|
||||||
<table className='account__header__fields'>
|
<div className='account__header__fields'>
|
||||||
<tbody>
|
|
||||||
{fields.map((pair, i) => (
|
{fields.map((pair, i) => (
|
||||||
<tr key={i}>
|
<dl key={i}>
|
||||||
<th dangerouslySetInnerHTML={{ __html: pair.get('name_emojified') }} />
|
<dt dangerouslySetInnerHTML={{ __html: pair.get('name_emojified') }} title={pair.get('name')} />
|
||||||
<td dangerouslySetInnerHTML={{ __html: pair.get('value_emojified') }} />
|
<dd dangerouslySetInnerHTML={{ __html: pair.get('value_emojified') }} title={pair.get('value_plain')} />
|
||||||
</tr>
|
</dl>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{fields.size == 0 && metadata.length && (
|
{fields.size == 0 && metadata.length && (
|
||||||
<table className='account__header__fields'>
|
<div className='account__header__fields'>
|
||||||
<tbody>
|
{metadata.map((pair, i) => (
|
||||||
{(() => {
|
<dl key={i}>
|
||||||
let data = [];
|
<dt dangerouslySetInnerHTML={{ __html: emojify(pair[0]) }} title={pair[0]} />
|
||||||
for (let i = 0; i < metadata.length; i++) {
|
<dd dangerouslySetInnerHTML={{ __html: emojify(pair[1]) }} title={pair[1]} />
|
||||||
data.push(
|
</dl>
|
||||||
<tr key={i}>
|
))}
|
||||||
<th scope='row'><div dangerouslySetInnerHTML={{ __html: emojify(metadata[i][0]) }} /></th>
|
</div>
|
||||||
<td><div dangerouslySetInnerHTML={{ __html: emojify(metadata[i][1]) }} /></td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
})()}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
) || null}
|
) || null}
|
||||||
|
|
||||||
{info}
|
{info}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { connect } from 'react-redux';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { fetchAccount } from 'flavours/glitch/actions/accounts';
|
import { fetchAccount } from 'flavours/glitch/actions/accounts';
|
||||||
import { refreshAccountMediaTimeline, expandAccountMediaTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandAccountMediaTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
|
import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
|
||||||
import Column from 'flavours/glitch/features/ui/components/column';
|
import Column from 'flavours/glitch/features/ui/components/column';
|
||||||
import ColumnBackButton from 'flavours/glitch/components/column_back_button';
|
import ColumnBackButton from 'flavours/glitch/components/column_back_button';
|
||||||
|
@ -17,9 +17,31 @@ import LoadMore from 'flavours/glitch/components/load_more';
|
||||||
const mapStateToProps = (state, props) => ({
|
const mapStateToProps = (state, props) => ({
|
||||||
medias: getAccountGallery(state, props.params.accountId),
|
medias: getAccountGallery(state, props.params.accountId),
|
||||||
isLoading: state.getIn(['timelines', `account:${props.params.accountId}:media`, 'isLoading']),
|
isLoading: state.getIn(['timelines', `account:${props.params.accountId}:media`, 'isLoading']),
|
||||||
hasMore: !!state.getIn(['timelines', `account:${props.params.accountId}:media`, 'next']),
|
hasMore: state.getIn(['timelines', `account:${props.params.accountId}:media`, 'hasMore']),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
class LoadMoreMedia extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
maxId: PropTypes.string,
|
||||||
|
onLoadMore: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleLoadMore = () => {
|
||||||
|
this.props.onLoadMore(this.props.maxId);
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<LoadMore
|
||||||
|
disabled={this.props.disabled}
|
||||||
|
onLoadMore={this.handleLoadMore}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@connect(mapStateToProps)
|
@connect(mapStateToProps)
|
||||||
export default class AccountGallery extends ImmutablePureComponent {
|
export default class AccountGallery extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
@ -33,19 +55,19 @@ export default class AccountGallery extends ImmutablePureComponent {
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.props.dispatch(fetchAccount(this.props.params.accountId));
|
this.props.dispatch(fetchAccount(this.props.params.accountId));
|
||||||
this.props.dispatch(refreshAccountMediaTimeline(this.props.params.accountId));
|
this.props.dispatch(expandAccountMediaTimeline(this.props.params.accountId));
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if (nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) {
|
if (nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) {
|
||||||
this.props.dispatch(fetchAccount(nextProps.params.accountId));
|
this.props.dispatch(fetchAccount(nextProps.params.accountId));
|
||||||
this.props.dispatch(refreshAccountMediaTimeline(this.props.params.accountId));
|
this.props.dispatch(expandAccountMediaTimeline(this.props.params.accountId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScrollToBottom = () => {
|
handleScrollToBottom = () => {
|
||||||
if (this.props.hasMore) {
|
if (this.props.hasMore) {
|
||||||
this.props.dispatch(expandAccountMediaTimeline(this.props.params.accountId));
|
this.handleLoadMore(this.props.medias.last().getIn(['status', 'id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +80,11 @@ export default class AccountGallery extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = (e) => {
|
handleLoadMore = maxId => {
|
||||||
|
this.props.dispatch(expandAccountMediaTimeline(this.props.params.accountId, { maxId }));
|
||||||
|
};
|
||||||
|
|
||||||
|
handleLoadOlder = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.handleScrollToBottom();
|
this.handleScrollToBottom();
|
||||||
}
|
}
|
||||||
|
@ -66,7 +92,7 @@ export default class AccountGallery extends ImmutablePureComponent {
|
||||||
render () {
|
render () {
|
||||||
const { medias, isLoading, hasMore } = this.props;
|
const { medias, isLoading, hasMore } = this.props;
|
||||||
|
|
||||||
let loadMore = null;
|
let loadOlder = null;
|
||||||
|
|
||||||
if (!medias && isLoading) {
|
if (!medias && isLoading) {
|
||||||
return (
|
return (
|
||||||
|
@ -77,7 +103,7 @@ export default class AccountGallery extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoading && medias.size > 0 && hasMore) {
|
if (!isLoading && medias.size > 0 && hasMore) {
|
||||||
loadMore = <LoadMore onClick={this.handleLoadMore} />;
|
loadOlder = <LoadMore onClick={this.handleLoadOlder} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -89,13 +115,18 @@ export default class AccountGallery extends ImmutablePureComponent {
|
||||||
<HeaderContainer accountId={this.props.params.accountId} />
|
<HeaderContainer accountId={this.props.params.accountId} />
|
||||||
|
|
||||||
<div className='account-gallery__container'>
|
<div className='account-gallery__container'>
|
||||||
{medias.map(media =>
|
{medias.map((media, index) => media === null ? (
|
||||||
(<MediaItem
|
<LoadMoreMedia
|
||||||
|
key={'more:' + medias.getIn(index + 1, 'id')}
|
||||||
|
maxId={index > 0 ? medias.getIn(index - 1, 'id') : null}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<MediaItem
|
||||||
key={media.get('id')}
|
key={media.get('id')}
|
||||||
media={media}
|
media={media}
|
||||||
/>)
|
/>
|
||||||
)}
|
))}
|
||||||
{loadMore}
|
{loadOlder}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ScrollContainer>
|
</ScrollContainer>
|
||||||
|
|
|
@ -16,6 +16,7 @@ export default class Header extends ImmutablePureComponent {
|
||||||
onFollow: PropTypes.func.isRequired,
|
onFollow: PropTypes.func.isRequired,
|
||||||
onBlock: PropTypes.func.isRequired,
|
onBlock: PropTypes.func.isRequired,
|
||||||
onMention: PropTypes.func.isRequired,
|
onMention: PropTypes.func.isRequired,
|
||||||
|
onDirect: PropTypes.func.isRequired,
|
||||||
onReblogToggle: PropTypes.func.isRequired,
|
onReblogToggle: PropTypes.func.isRequired,
|
||||||
onReport: PropTypes.func.isRequired,
|
onReport: PropTypes.func.isRequired,
|
||||||
onMute: PropTypes.func.isRequired,
|
onMute: PropTypes.func.isRequired,
|
||||||
|
@ -40,6 +41,10 @@ export default class Header extends ImmutablePureComponent {
|
||||||
this.props.onMention(this.props.account, this.context.router.history);
|
this.props.onMention(this.props.account, this.context.router.history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDirect = () => {
|
||||||
|
this.props.onDirect(this.props.account, this.context.router.history);
|
||||||
|
}
|
||||||
|
|
||||||
handleReport = () => {
|
handleReport = () => {
|
||||||
this.props.onReport(this.props.account);
|
this.props.onReport(this.props.account);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +94,7 @@ export default class Header extends ImmutablePureComponent {
|
||||||
account={account}
|
account={account}
|
||||||
onBlock={this.handleBlock}
|
onBlock={this.handleBlock}
|
||||||
onMention={this.handleMention}
|
onMention={this.handleMention}
|
||||||
|
onDirect={this.handleDirect}
|
||||||
onReblogToggle={this.handleReblogToggle}
|
onReblogToggle={this.handleReblogToggle}
|
||||||
onReport={this.handleReport}
|
onReport={this.handleReport}
|
||||||
onMute={this.handleMute}
|
onMute={this.handleMute}
|
||||||
|
|
|
@ -9,7 +9,10 @@ import {
|
||||||
unblockAccount,
|
unblockAccount,
|
||||||
unmuteAccount,
|
unmuteAccount,
|
||||||
} from 'flavours/glitch/actions/accounts';
|
} from 'flavours/glitch/actions/accounts';
|
||||||
import { mentionCompose } from 'flavours/glitch/actions/compose';
|
import {
|
||||||
|
mentionCompose,
|
||||||
|
directCompose
|
||||||
|
} from 'flavours/glitch/actions/compose';
|
||||||
import { initMuteModal } from 'flavours/glitch/actions/mutes';
|
import { initMuteModal } from 'flavours/glitch/actions/mutes';
|
||||||
import { initReport } from 'flavours/glitch/actions/reports';
|
import { initReport } from 'flavours/glitch/actions/reports';
|
||||||
import { openModal } from 'flavours/glitch/actions/modal';
|
import { openModal } from 'flavours/glitch/actions/modal';
|
||||||
|
@ -67,6 +70,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
dispatch(mentionCompose(account, router));
|
dispatch(mentionCompose(account, router));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onDirect (account, router) {
|
||||||
|
dispatch(directCompose(account, router));
|
||||||
|
},
|
||||||
|
|
||||||
|
onDirect (account, router) {
|
||||||
|
dispatch(directCompose(account, router));
|
||||||
|
},
|
||||||
|
|
||||||
onReblogToggle (account) {
|
onReblogToggle (account) {
|
||||||
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
||||||
dispatch(followAccount(account.get('id'), false));
|
dispatch(followAccount(account.get('id'), false));
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { connect } from 'react-redux';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { fetchAccount } from 'flavours/glitch/actions/accounts';
|
import { fetchAccount } from 'flavours/glitch/actions/accounts';
|
||||||
import { refreshAccountTimeline, refreshAccountFeaturedTimeline, expandAccountTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandAccountFeaturedTimeline, expandAccountTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import StatusList from '../../components/status_list';
|
import StatusList from '../../components/status_list';
|
||||||
import LoadingIndicator from '../../components/loading_indicator';
|
import LoadingIndicator from '../../components/loading_indicator';
|
||||||
import Column from '../ui/components/column';
|
import Column from '../ui/components/column';
|
||||||
|
@ -19,7 +19,7 @@ const mapStateToProps = (state, { params: { accountId }, withReplies = false })
|
||||||
statusIds: state.getIn(['timelines', `account:${path}`, 'items'], ImmutableList()),
|
statusIds: state.getIn(['timelines', `account:${path}`, 'items'], ImmutableList()),
|
||||||
featuredStatusIds: withReplies ? ImmutableList() : state.getIn(['timelines', `account:${accountId}:pinned`, 'items'], ImmutableList()),
|
featuredStatusIds: withReplies ? ImmutableList() : state.getIn(['timelines', `account:${accountId}:pinned`, 'items'], ImmutableList()),
|
||||||
isLoading: state.getIn(['timelines', `account:${path}`, 'isLoading']),
|
isLoading: state.getIn(['timelines', `account:${path}`, 'isLoading']),
|
||||||
hasMore: !!state.getIn(['timelines', `account:${path}`, 'next']),
|
hasMore: state.getIn(['timelines', `account:${path}`, 'hasMore']),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,22 +40,24 @@ export default class AccountTimeline extends ImmutablePureComponent {
|
||||||
const { params: { accountId }, withReplies } = this.props;
|
const { params: { accountId }, withReplies } = this.props;
|
||||||
|
|
||||||
this.props.dispatch(fetchAccount(accountId));
|
this.props.dispatch(fetchAccount(accountId));
|
||||||
this.props.dispatch(refreshAccountFeaturedTimeline(accountId));
|
if (!withReplies) {
|
||||||
this.props.dispatch(refreshAccountTimeline(accountId, withReplies));
|
this.props.dispatch(expandAccountFeaturedTimeline(accountId));
|
||||||
|
}
|
||||||
|
this.props.dispatch(expandAccountTimeline(accountId, { withReplies }));
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if ((nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) || nextProps.withReplies !== this.props.withReplies) {
|
if ((nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) || nextProps.withReplies !== this.props.withReplies) {
|
||||||
this.props.dispatch(fetchAccount(nextProps.params.accountId));
|
this.props.dispatch(fetchAccount(nextProps.params.accountId));
|
||||||
this.props.dispatch(refreshAccountFeaturedTimeline(nextProps.params.accountId));
|
if (!nextProps.withReplies) {
|
||||||
this.props.dispatch(refreshAccountTimeline(nextProps.params.accountId, nextProps.params.withReplies));
|
this.props.dispatch(expandAccountFeaturedTimeline(nextProps.params.accountId));
|
||||||
|
}
|
||||||
|
this.props.dispatch(expandAccountTimeline(nextProps.params.accountId, { withReplies: nextProps.params.withReplies }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScrollToBottom = () => {
|
handleLoadMore = maxId => {
|
||||||
if (!this.props.isLoading && this.props.hasMore) {
|
this.props.dispatch(expandAccountTimeline(this.props.params.accountId, { maxId, withReplies: this.props.withReplies }));
|
||||||
this.props.dispatch(expandAccountTimeline(this.props.params.accountId, this.props.withReplies));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -80,7 +82,7 @@ export default class AccountTimeline extends ImmutablePureComponent {
|
||||||
featuredStatusIds={featuredStatusIds}
|
featuredStatusIds={featuredStatusIds}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadMore}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class Bookmarks extends ImmutablePureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScrollToBottom = debounce(() => {
|
handleLoadMore = debounce(() => {
|
||||||
this.props.dispatch(expandBookmarkedStatuses());
|
this.props.dispatch(expandBookmarkedStatuses());
|
||||||
}, 300, { leading: true })
|
}, 300, { leading: true })
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export default class Bookmarks extends ImmutablePureComponent {
|
||||||
scrollKey={`bookmarked_statuses-${columnId}`}
|
scrollKey={`bookmarked_statuses-${columnId}`}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadMore}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,10 +4,7 @@ import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import {
|
import { expandCommunityTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
refreshCommunityTimeline,
|
|
||||||
expandCommunityTimeline,
|
|
||||||
} from 'flavours/glitch/actions/timelines';
|
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
|
@ -55,7 +52,7 @@ export default class CommunityTimeline extends React.PureComponent {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
dispatch(refreshCommunityTimeline());
|
dispatch(expandCommunityTimeline());
|
||||||
this.disconnect = dispatch(connectCommunityStream());
|
this.disconnect = dispatch(connectCommunityStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +67,8 @@ export default class CommunityTimeline extends React.PureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
this.props.dispatch(expandCommunityTimeline());
|
this.props.dispatch(expandCommunityTimeline({ maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -97,7 +94,7 @@ export default class CommunityTimeline extends React.PureComponent {
|
||||||
trackScroll={!pinned}
|
trackScroll={!pinned}
|
||||||
scrollKey={`community_timeline-${columnId}`}
|
scrollKey={`community_timeline-${columnId}`}
|
||||||
timelineId='community'
|
timelineId='community'
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />}
|
emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
import React from 'react';
|
||||||
|
import Motion from 'flavours/glitch/util/optional_motion';
|
||||||
|
import spring from 'react-motion/lib/spring';
|
||||||
|
import { defineMessages, FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
// This is the spring used with our motion.
|
||||||
|
const motionSpring = spring(1, { damping: 35, stiffness: 400 });
|
||||||
|
|
||||||
|
// Messages.
|
||||||
|
const messages = defineMessages({
|
||||||
|
disclaimer: {
|
||||||
|
defaultMessage: 'This toot will only be sent to all the mentioned users.',
|
||||||
|
id: 'compose_form.direct_message_warning',
|
||||||
|
},
|
||||||
|
learn_more: {
|
||||||
|
defaultMessage: 'Learn more',
|
||||||
|
id: 'compose_form.direct_message_warning_learn_more'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// The component.
|
||||||
|
export default function ComposerDirectWarning () {
|
||||||
|
return (
|
||||||
|
<Motion
|
||||||
|
defaultStyle={{
|
||||||
|
opacity: 0,
|
||||||
|
scaleX: 0.85,
|
||||||
|
scaleY: 0.75,
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
opacity: motionSpring,
|
||||||
|
scaleX: motionSpring,
|
||||||
|
scaleY: motionSpring,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{({ opacity, scaleX, scaleY }) => (
|
||||||
|
<div
|
||||||
|
className='composer--warning'
|
||||||
|
style={{
|
||||||
|
opacity: opacity,
|
||||||
|
transform: `scale(${scaleX}, ${scaleY})`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<FormattedMessage {...messages.disclaimer} /> <a href='/terms' target='_blank'><FormattedMessage {...messages.learn_more} /></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Motion>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ComposerDirectWarning.propTypes = {};
|
|
@ -39,6 +39,7 @@ import ComposerTextarea from './textarea';
|
||||||
import ComposerUploadForm from './upload_form';
|
import ComposerUploadForm from './upload_form';
|
||||||
import ComposerWarning from './warning';
|
import ComposerWarning from './warning';
|
||||||
import ComposerHashtagWarning from './hashtag_warning';
|
import ComposerHashtagWarning from './hashtag_warning';
|
||||||
|
import ComposerDirectWarning from './direct_warning';
|
||||||
|
|
||||||
// Utils.
|
// Utils.
|
||||||
import { countableText } from 'flavours/glitch/util/counter';
|
import { countableText } from 'flavours/glitch/util/counter';
|
||||||
|
@ -55,6 +56,7 @@ function mapStateToProps (state) {
|
||||||
advancedOptions: state.getIn(['compose', 'advanced_options']),
|
advancedOptions: state.getIn(['compose', 'advanced_options']),
|
||||||
amUnlocked: !state.getIn(['accounts', me, 'locked']),
|
amUnlocked: !state.getIn(['accounts', me, 'locked']),
|
||||||
focusDate: state.getIn(['compose', 'focusDate']),
|
focusDate: state.getIn(['compose', 'focusDate']),
|
||||||
|
caretPosition: state.getIn(['compose', 'caretPosition']),
|
||||||
isSubmitting: state.getIn(['compose', 'is_submitting']),
|
isSubmitting: state.getIn(['compose', 'is_submitting']),
|
||||||
isUploading: state.getIn(['compose', 'is_uploading']),
|
isUploading: state.getIn(['compose', 'is_uploading']),
|
||||||
layout: state.getIn(['local_settings', 'layout']),
|
layout: state.getIn(['local_settings', 'layout']),
|
||||||
|
@ -116,7 +118,6 @@ const handlers = {
|
||||||
handleEmoji (data) {
|
handleEmoji (data) {
|
||||||
const { textarea: { selectionStart } } = this;
|
const { textarea: { selectionStart } } = this;
|
||||||
const { onInsertEmoji } = this.props;
|
const { onInsertEmoji } = this.props;
|
||||||
this.caretPos = selectionStart + data.native.length + 1;
|
|
||||||
if (onInsertEmoji) {
|
if (onInsertEmoji) {
|
||||||
onInsertEmoji(selectionStart, data);
|
onInsertEmoji(selectionStart, data);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +139,6 @@ const handlers = {
|
||||||
// Selects a suggestion from the autofill.
|
// Selects a suggestion from the autofill.
|
||||||
handleSelect (tokenStart, token, value) {
|
handleSelect (tokenStart, token, value) {
|
||||||
const { onSelectSuggestion } = this.props;
|
const { onSelectSuggestion } = this.props;
|
||||||
this.caretPos = null;
|
|
||||||
if (onSelectSuggestion) {
|
if (onSelectSuggestion) {
|
||||||
onSelectSuggestion(tokenStart, token, value);
|
onSelectSuggestion(tokenStart, token, value);
|
||||||
}
|
}
|
||||||
|
@ -190,20 +190,9 @@ class Composer extends React.Component {
|
||||||
assignHandlers(this, handlers);
|
assignHandlers(this, handlers);
|
||||||
|
|
||||||
// Instance variables.
|
// Instance variables.
|
||||||
this.caretPos = null;
|
|
||||||
this.textarea = null;
|
this.textarea = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is the update where we've finished uploading,
|
|
||||||
// save the last caret position so we can restore it below!
|
|
||||||
componentWillReceiveProps (nextProps) {
|
|
||||||
const { textarea } = this;
|
|
||||||
const { isUploading } = this.props;
|
|
||||||
if (textarea && isUploading && !nextProps.isUploading) {
|
|
||||||
this.caretPos = textarea.selectionStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tells our state the composer has been mounted.
|
// Tells our state the composer has been mounted.
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { onMount } = this.props;
|
const { onMount } = this.props;
|
||||||
|
@ -227,17 +216,13 @@ class Composer extends React.Component {
|
||||||
// - Replying to more than one user, selects any usernames past
|
// - Replying to more than one user, selects any usernames past
|
||||||
// the first; this provides a convenient shortcut to drop
|
// the first; this provides a convenient shortcut to drop
|
||||||
// everyone else from the conversation.
|
// everyone else from the conversation.
|
||||||
// - If we've just finished uploading an image, and have a saved
|
|
||||||
// caret position, restores the cursor to that position after the
|
|
||||||
// text changes.
|
|
||||||
componentDidUpdate (prevProps) {
|
componentDidUpdate (prevProps) {
|
||||||
const {
|
const {
|
||||||
caretPos,
|
|
||||||
textarea,
|
textarea,
|
||||||
} = this;
|
} = this;
|
||||||
const {
|
const {
|
||||||
focusDate,
|
focusDate,
|
||||||
isUploading,
|
caretPosition,
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
preselectDate,
|
preselectDate,
|
||||||
text,
|
text,
|
||||||
|
@ -245,14 +230,14 @@ class Composer extends React.Component {
|
||||||
let selectionEnd, selectionStart;
|
let selectionEnd, selectionStart;
|
||||||
|
|
||||||
// Caret/selection handling.
|
// Caret/selection handling.
|
||||||
if (focusDate !== prevProps.focusDate || (prevProps.isUploading && !isUploading && !isNaN(caretPos) && caretPos !== null)) {
|
if (focusDate !== prevProps.focusDate) {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case preselectDate !== prevProps.preselectDate:
|
case preselectDate !== prevProps.preselectDate:
|
||||||
selectionStart = text.search(/\s/) + 1;
|
selectionStart = text.search(/\s/) + 1;
|
||||||
selectionEnd = text.length;
|
selectionEnd = text.length;
|
||||||
break;
|
break;
|
||||||
case !isNaN(caretPos) && caretPos !== null:
|
case !isNaN(caretPosition) && caretPosition !== null:
|
||||||
selectionStart = selectionEnd = caretPos;
|
selectionStart = selectionEnd = caretPosition;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
selectionStart = selectionEnd = text.length;
|
selectionStart = selectionEnd = text.length;
|
||||||
|
@ -326,6 +311,7 @@ class Composer extends React.Component {
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
text={spoilerText}
|
text={spoilerText}
|
||||||
/>
|
/>
|
||||||
|
{privacy === 'direct' ? <ComposerDirectWarning /> : null}
|
||||||
{privacy === 'private' && amUnlocked ? <ComposerWarning /> : null}
|
{privacy === 'private' && amUnlocked ? <ComposerWarning /> : null}
|
||||||
{privacy !== 'public' && APPROX_HASHTAG_RE.test(text) ? <ComposerHashtagWarning /> : null}
|
{privacy !== 'public' && APPROX_HASHTAG_RE.test(text) ? <ComposerHashtagWarning /> : null}
|
||||||
{replyContent ? (
|
{replyContent ? (
|
||||||
|
@ -408,6 +394,7 @@ Composer.propTypes = {
|
||||||
advancedOptions: ImmutablePropTypes.map,
|
advancedOptions: ImmutablePropTypes.map,
|
||||||
amUnlocked: PropTypes.bool,
|
amUnlocked: PropTypes.bool,
|
||||||
focusDate: PropTypes.instanceOf(Date),
|
focusDate: PropTypes.instanceOf(Date),
|
||||||
|
caretPosition: PropTypes.number,
|
||||||
isSubmitting: PropTypes.bool,
|
isSubmitting: PropTypes.bool,
|
||||||
isUploading: PropTypes.bool,
|
isUploading: PropTypes.bool,
|
||||||
layout: PropTypes.string,
|
layout: PropTypes.string,
|
||||||
|
|
|
@ -58,6 +58,7 @@ export default class ComposerReply extends React.PureComponent {
|
||||||
icon='times'
|
icon='times'
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
title={intl.formatMessage(messages.cancel)}
|
title={intl.formatMessage(messages.cancel)}
|
||||||
|
inverted
|
||||||
/>
|
/>
|
||||||
{account ? (
|
{account ? (
|
||||||
<AccountContainer
|
<AccountContainer
|
||||||
|
|
|
@ -4,10 +4,7 @@ import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import {
|
import { expandDirectTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
refreshDirectTimeline,
|
|
||||||
expandDirectTimeline,
|
|
||||||
} from 'flavours/glitch/actions/timelines';
|
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
|
@ -55,7 +52,7 @@ export default class DirectTimeline extends React.PureComponent {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
dispatch(refreshDirectTimeline());
|
dispatch(expandDirectTimeline());
|
||||||
this.disconnect = dispatch(connectDirectStream());
|
this.disconnect = dispatch(connectDirectStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +67,8 @@ export default class DirectTimeline extends React.PureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
this.props.dispatch(expandDirectTimeline());
|
this.props.dispatch(expandDirectTimeline({ maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -97,7 +94,7 @@ export default class DirectTimeline extends React.PureComponent {
|
||||||
trackScroll={!pinned}
|
trackScroll={!pinned}
|
||||||
scrollKey={`direct_timeline-${columnId}`}
|
scrollKey={`direct_timeline-${columnId}`}
|
||||||
timelineId='direct'
|
timelineId='direct'
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={<FormattedMessage id='empty_column.direct' defaultMessage="You don't have any direct messages yet. When you send or receive one, it will show up here." />}
|
emptyMessage={<FormattedMessage id='empty_column.direct' defaultMessage="You don't have any direct messages yet. When you send or receive one, it will show up here." />}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
|
@ -52,7 +52,7 @@ export default class Blocks extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column icon='ban' heading={intl.formatMessage(messages.heading)}>
|
<Column icon='minus-circle' heading={intl.formatMessage(messages.heading)}>
|
||||||
<ColumnBackButtonSlim />
|
<ColumnBackButtonSlim />
|
||||||
<ScrollableList scrollKey='domain_blocks' onLoadMore={this.handleLoadMore}>
|
<ScrollableList scrollKey='domain_blocks' onLoadMore={this.handleLoadMore}>
|
||||||
{domains.map(domain =>
|
{domains.map(domain =>
|
||||||
|
|
|
@ -68,6 +68,8 @@ export default function DrawerResults ({
|
||||||
</header>
|
</header>
|
||||||
{accounts && accounts.size ? (
|
{accounts && accounts.size ? (
|
||||||
<section>
|
<section>
|
||||||
|
<h5><FormattedMessage id='search_results.accounts' defaultMessage='People' /></h5>
|
||||||
|
|
||||||
{accounts.map(
|
{accounts.map(
|
||||||
accountId => (
|
accountId => (
|
||||||
<AccountContainer
|
<AccountContainer
|
||||||
|
@ -80,6 +82,8 @@ export default function DrawerResults ({
|
||||||
) : null}
|
) : null}
|
||||||
{statuses && statuses.size ? (
|
{statuses && statuses.size ? (
|
||||||
<section>
|
<section>
|
||||||
|
<h5><FormattedMessage id='search_results.statuses' defaultMessage='Toots' /></h5>
|
||||||
|
|
||||||
{statuses.map(
|
{statuses.map(
|
||||||
statusId => (
|
statusId => (
|
||||||
<StatusContainer
|
<StatusContainer
|
||||||
|
@ -92,6 +96,8 @@ export default function DrawerResults ({
|
||||||
) : null}
|
) : null}
|
||||||
{hashtags && hashtags.size ? (
|
{hashtags && hashtags.size ? (
|
||||||
<section>
|
<section>
|
||||||
|
<h5><FormattedMessage id='search_results.hashtags' defaultMessage='Hashtags' /></h5>
|
||||||
|
|
||||||
{hashtags.map(
|
{hashtags.map(
|
||||||
hashtag => (
|
hashtag => (
|
||||||
<Link
|
<Link
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class Favourites extends ImmutablePureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScrollToBottom = debounce(() => {
|
handleLoadMore = debounce(() => {
|
||||||
this.props.dispatch(expandFavouritedStatuses());
|
this.props.dispatch(expandFavouritedStatuses());
|
||||||
}, 300, { leading: true })
|
}, 300, { leading: true })
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export default class Favourites extends ImmutablePureComponent {
|
||||||
scrollKey={`favourited_statuses-${columnId}`}
|
scrollKey={`favourited_statuses-${columnId}`}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadMore}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -50,7 +50,7 @@ export default class gettingStartedMisc extends ImmutablePureComponent {
|
||||||
<ColumnLink key='20' icon='thumb-tack' text={intl.formatMessage(messages.pins)} to='/pinned' />
|
<ColumnLink key='20' icon='thumb-tack' text={intl.formatMessage(messages.pins)} to='/pinned' />
|
||||||
<ColumnLink key='21' icon='volume-off' text={intl.formatMessage(messages.mutes)} to='/mutes' />
|
<ColumnLink key='21' icon='volume-off' text={intl.formatMessage(messages.mutes)} to='/mutes' />
|
||||||
<ColumnLink key='22' icon='ban' text={intl.formatMessage(messages.blocks)} to='/blocks' />
|
<ColumnLink key='22' icon='ban' text={intl.formatMessage(messages.blocks)} to='/blocks' />
|
||||||
<ColumnLink icon='ban' text={intl.formatMessage(messages.domain_blocks)} to='/domain_blocks' />
|
<ColumnLink icon='minus-circle' text={intl.formatMessage(messages.domain_blocks)} to='/domain_blocks' />
|
||||||
<ColumnLink key='23' icon='question' text={intl.formatMessage(messages.keyboard_shortcuts)} to='/keyboard-shortcuts' />
|
<ColumnLink key='23' icon='question' text={intl.formatMessage(messages.keyboard_shortcuts)} to='/keyboard-shortcuts' />
|
||||||
<ColumnLink icon='book' text={intl.formatMessage(messages.info)} href='/about/more' />
|
<ColumnLink icon='book' text={intl.formatMessage(messages.info)} href='/about/more' />
|
||||||
<ColumnLink icon='hand-o-right' text={intl.formatMessage(messages.show_me_around)} onClick={this.openOnboardingModal} />
|
<ColumnLink icon='hand-o-right' text={intl.formatMessage(messages.show_me_around)} onClick={this.openOnboardingModal} />
|
||||||
|
|
|
@ -4,10 +4,7 @@ import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import {
|
import { expandHashtagTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
refreshHashtagTimeline,
|
|
||||||
expandHashtagTimeline,
|
|
||||||
} from 'flavours/glitch/actions/timelines';
|
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { connectHashtagStream } from 'flavours/glitch/actions/streaming';
|
import { connectHashtagStream } from 'flavours/glitch/actions/streaming';
|
||||||
|
@ -61,13 +58,13 @@ export default class HashtagTimeline extends React.PureComponent {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
const { id } = this.props.params;
|
const { id } = this.props.params;
|
||||||
|
|
||||||
dispatch(refreshHashtagTimeline(id));
|
dispatch(expandHashtagTimeline(id));
|
||||||
this._subscribe(dispatch, id);
|
this._subscribe(dispatch, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if (nextProps.params.id !== this.props.params.id) {
|
if (nextProps.params.id !== this.props.params.id) {
|
||||||
this.props.dispatch(refreshHashtagTimeline(nextProps.params.id));
|
this.props.dispatch(expandHashtagTimeline(nextProps.params.id));
|
||||||
this._unsubscribe();
|
this._unsubscribe();
|
||||||
this._subscribe(this.props.dispatch, nextProps.params.id);
|
this._subscribe(this.props.dispatch, nextProps.params.id);
|
||||||
}
|
}
|
||||||
|
@ -81,8 +78,8 @@ export default class HashtagTimeline extends React.PureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
this.props.dispatch(expandHashtagTimeline(this.props.params.id));
|
this.props.dispatch(expandHashtagTimeline(this.props.params.id, { maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -108,7 +105,7 @@ export default class HashtagTimeline extends React.PureComponent {
|
||||||
trackScroll={!pinned}
|
trackScroll={!pinned}
|
||||||
scrollKey={`hashtag_timeline-${columnId}`}
|
scrollKey={`hashtag_timeline-${columnId}`}
|
||||||
timelineId={`hashtag:${id}`}
|
timelineId={`hashtag:${id}`}
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={<FormattedMessage id='empty_column.hashtag' defaultMessage='There is nothing in this hashtag yet.' />}
|
emptyMessage={<FormattedMessage id='empty_column.hashtag' defaultMessage='There is nothing in this hashtag yet.' />}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { expandHomeTimeline, refreshHomeTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandHomeTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
|
@ -16,7 +16,7 @@ const messages = defineMessages({
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0,
|
hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0,
|
||||||
isPartial: state.getIn(['timelines', 'home', 'isPartial'], false),
|
isPartial: state.getIn(['timelines', 'home', 'items', 0], null) === null,
|
||||||
});
|
});
|
||||||
|
|
||||||
@connect(mapStateToProps)
|
@connect(mapStateToProps)
|
||||||
|
@ -55,8 +55,8 @@ export default class HomeTimeline extends React.PureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
this.props.dispatch(expandHomeTimeline());
|
this.props.dispatch(expandHomeTimeline({ maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
@ -78,7 +78,7 @@ export default class HomeTimeline extends React.PureComponent {
|
||||||
return;
|
return;
|
||||||
} else if (!wasPartial && isPartial) {
|
} else if (!wasPartial && isPartial) {
|
||||||
this.polling = setInterval(() => {
|
this.polling = setInterval(() => {
|
||||||
dispatch(refreshHomeTimeline());
|
dispatch(expandHomeTimeline());
|
||||||
}, 3000);
|
}, 3000);
|
||||||
} else if (wasPartial && !isPartial) {
|
} else if (wasPartial && !isPartial) {
|
||||||
this._stopPolling();
|
this._stopPolling();
|
||||||
|
@ -114,7 +114,7 @@ export default class HomeTimeline extends React.PureComponent {
|
||||||
<StatusListContainer
|
<StatusListContainer
|
||||||
trackScroll={!pinned}
|
trackScroll={!pinned}
|
||||||
scrollKey={`home_timeline-${columnId}`}
|
scrollKey={`home_timeline-${columnId}`}
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
timelineId='home'
|
timelineId='home'
|
||||||
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Visit {public} or use search to get started and meet other users.' values={{ public: <Link to='/timelines/public'><FormattedMessage id='empty_column.home.public_timeline' defaultMessage='the public timeline' /></Link> }} />}
|
emptyMessage={<FormattedMessage id='empty_column.home' defaultMessage='Your home timeline is empty! Visit {public} or use search to get started and meet other users.' values={{ public: <Link to='/timelines/public'><FormattedMessage id='empty_column.home.public_timeline' defaultMessage='the public timeline' /></Link> }} />}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -8,7 +8,7 @@ import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
||||||
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
|
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
|
||||||
import { connectListStream } from 'flavours/glitch/actions/streaming';
|
import { connectListStream } from 'flavours/glitch/actions/streaming';
|
||||||
import { refreshListTimeline, expandListTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandListTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import { fetchList, deleteList } from 'flavours/glitch/actions/lists';
|
import { fetchList, deleteList } from 'flavours/glitch/actions/lists';
|
||||||
import { openModal } from 'flavours/glitch/actions/modal';
|
import { openModal } from 'flavours/glitch/actions/modal';
|
||||||
import MissingIndicator from 'flavours/glitch/components/missing_indicator';
|
import MissingIndicator from 'flavours/glitch/components/missing_indicator';
|
||||||
|
@ -67,7 +67,7 @@ export default class ListTimeline extends React.PureComponent {
|
||||||
const { id } = this.props.params;
|
const { id } = this.props.params;
|
||||||
|
|
||||||
dispatch(fetchList(id));
|
dispatch(fetchList(id));
|
||||||
dispatch(refreshListTimeline(id));
|
dispatch(expandListTimeline(id));
|
||||||
|
|
||||||
this.disconnect = dispatch(connectListStream(id));
|
this.disconnect = dispatch(connectListStream(id));
|
||||||
}
|
}
|
||||||
|
@ -83,9 +83,9 @@ export default class ListTimeline extends React.PureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
const { id } = this.props.params;
|
const { id } = this.props.params;
|
||||||
this.props.dispatch(expandListTimeline(id));
|
this.props.dispatch(expandListTimeline(id, { maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEditClick = () => {
|
handleEditClick = () => {
|
||||||
|
@ -164,7 +164,7 @@ export default class ListTimeline extends React.PureComponent {
|
||||||
trackScroll={!pinned}
|
trackScroll={!pinned}
|
||||||
scrollKey={`list_timeline-${columnId}`}
|
scrollKey={`list_timeline-${columnId}`}
|
||||||
timelineId={`list:${id}`}
|
timelineId={`list:${id}`}
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet.' />}
|
emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet.' />}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { createSelector } from 'reselect';
|
||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import ScrollableList from 'flavours/glitch/components/scrollable_list';
|
import ScrollableList from 'flavours/glitch/components/scrollable_list';
|
||||||
|
import LoadGap from 'flavours/glitch/components/load_gap';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
|
title: { id: 'column.notifications', defaultMessage: 'Notifications' },
|
||||||
|
@ -25,14 +26,14 @@ const messages = defineMessages({
|
||||||
const getNotifications = createSelector([
|
const getNotifications = createSelector([
|
||||||
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
|
state => ImmutableList(state.getIn(['settings', 'notifications', 'shows']).filter(item => !item).keys()),
|
||||||
state => state.getIn(['notifications', 'items']),
|
state => state.getIn(['notifications', 'items']),
|
||||||
], (excludedTypes, notifications) => notifications.filterNot(item => excludedTypes.includes(item.get('type'))));
|
], (excludedTypes, notifications) => notifications.filterNot(item => item !== null && excludedTypes.includes(item.get('type'))));
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
notifications: getNotifications(state),
|
notifications: getNotifications(state),
|
||||||
localSettings: state.get('local_settings'),
|
localSettings: state.get('local_settings'),
|
||||||
isLoading: state.getIn(['notifications', 'isLoading'], true),
|
isLoading: state.getIn(['notifications', 'isLoading'], true),
|
||||||
isUnread: state.getIn(['notifications', 'unread']) > 0,
|
isUnread: state.getIn(['notifications', 'unread']) > 0,
|
||||||
hasMore: !!state.getIn(['notifications', 'next']),
|
hasMore: state.getIn(['notifications', 'hasMore']),
|
||||||
notifCleaningActive: state.getIn(['notifications', 'cleaningMode']),
|
notifCleaningActive: state.getIn(['notifications', 'cleaningMode']),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -67,9 +68,13 @@ export default class Notifications extends React.PureComponent {
|
||||||
trackScroll: true,
|
trackScroll: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleScrollToBottom = debounce(() => {
|
handleLoadGap = (maxId) => {
|
||||||
this.props.dispatch(scrollTopNotifications(false));
|
this.props.dispatch(expandNotifications({ maxId }));
|
||||||
this.props.dispatch(expandNotifications());
|
};
|
||||||
|
|
||||||
|
handleLoadOlder = debounce(() => {
|
||||||
|
const last = this.props.notifications.last();
|
||||||
|
this.props.dispatch(expandNotifications({ maxId: last && last.get('id') }));
|
||||||
}, 300, { leading: true });
|
}, 300, { leading: true });
|
||||||
|
|
||||||
handleScrollToTop = debounce(() => {
|
handleScrollToTop = debounce(() => {
|
||||||
|
@ -104,12 +109,12 @@ export default class Notifications extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMoveUp = id => {
|
handleMoveUp = id => {
|
||||||
const elementIndex = this.props.notifications.findIndex(item => item.get('id') === id) - 1;
|
const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1;
|
||||||
this._selectChild(elementIndex);
|
this._selectChild(elementIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMoveDown = id => {
|
handleMoveDown = id => {
|
||||||
const elementIndex = this.props.notifications.findIndex(item => item.get('id') === id) + 1;
|
const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1;
|
||||||
this._selectChild(elementIndex);
|
this._selectChild(elementIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +136,14 @@ export default class Notifications extends React.PureComponent {
|
||||||
if (isLoading && this.scrollableContent) {
|
if (isLoading && this.scrollableContent) {
|
||||||
scrollableContent = this.scrollableContent;
|
scrollableContent = this.scrollableContent;
|
||||||
} else if (notifications.size > 0 || hasMore) {
|
} else if (notifications.size > 0 || hasMore) {
|
||||||
scrollableContent = notifications.map((item) => (
|
scrollableContent = notifications.map((item, index) => item === null ? (
|
||||||
|
<LoadGap
|
||||||
|
key={'gap:' + notifications.getIn([index + 1, 'id'])}
|
||||||
|
disabled={isLoading}
|
||||||
|
maxId={index > 0 ? notifications.getIn([index - 1, 'id']) : null}
|
||||||
|
onClick={this.handleLoadGap}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<NotificationContainer
|
<NotificationContainer
|
||||||
key={item.get('id')}
|
key={item.get('id')}
|
||||||
notification={item}
|
notification={item}
|
||||||
|
@ -153,7 +165,7 @@ export default class Notifications extends React.PureComponent {
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
hasMore={hasMore}
|
hasMore={hasMore}
|
||||||
emptyMessage={emptyMessage}
|
emptyMessage={emptyMessage}
|
||||||
onScrollToBottom={this.handleScrollToBottom}
|
onLoadMore={this.handleLoadOlder}
|
||||||
onScrollToTop={this.handleScrollToTop}
|
onScrollToTop={this.handleScrollToTop}
|
||||||
onScroll={this.handleScroll}
|
onScroll={this.handleScroll}
|
||||||
shouldUpdateScroll={shouldUpdateScroll}
|
shouldUpdateScroll={shouldUpdateScroll}
|
||||||
|
|
|
@ -4,10 +4,7 @@ import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import {
|
import { expandPublicTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
refreshPublicTimeline,
|
|
||||||
expandPublicTimeline,
|
|
||||||
} from 'flavours/glitch/actions/timelines';
|
|
||||||
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import ColumnSettingsContainer from './containers/column_settings_container';
|
import ColumnSettingsContainer from './containers/column_settings_container';
|
||||||
|
@ -55,7 +52,7 @@ export default class PublicTimeline extends React.PureComponent {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
dispatch(refreshPublicTimeline());
|
dispatch(expandPublicTimeline());
|
||||||
this.disconnect = dispatch(connectPublicStream());
|
this.disconnect = dispatch(connectPublicStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,8 +67,8 @@ export default class PublicTimeline extends React.PureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
this.props.dispatch(expandPublicTimeline());
|
this.props.dispatch(expandPublicTimeline({ maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -95,7 +92,7 @@ export default class PublicTimeline extends React.PureComponent {
|
||||||
|
|
||||||
<StatusListContainer
|
<StatusListContainer
|
||||||
timelineId='public'
|
timelineId='public'
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
trackScroll={!pinned}
|
trackScroll={!pinned}
|
||||||
scrollKey={`public_timeline-${columnId}`}
|
scrollKey={`public_timeline-${columnId}`}
|
||||||
emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other instances to fill it up' />}
|
emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other instances to fill it up' />}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
|
import { expandCommunityTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
|
import Column from 'flavours/glitch/components/column';
|
||||||
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
import { connectCommunityStream } from 'flavours/glitch/actions/streaming';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
title: { id: 'standalone.public_title', defaultMessage: 'A look inside...' },
|
||||||
|
});
|
||||||
|
|
||||||
|
@connect()
|
||||||
|
@injectIntl
|
||||||
|
export default class CommunityTimeline extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
dispatch: PropTypes.func.isRequired,
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
handleHeaderClick = () => {
|
||||||
|
this.column.scrollTop();
|
||||||
|
}
|
||||||
|
|
||||||
|
setRef = c => {
|
||||||
|
this.column = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
|
dispatch(expandCommunityTimeline());
|
||||||
|
this.disconnect = dispatch(connectCommunityStream());
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
if (this.disconnect) {
|
||||||
|
this.disconnect();
|
||||||
|
this.disconnect = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLoadMore = maxId => {
|
||||||
|
this.props.dispatch(expandCommunityTimeline({ maxId }));
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { intl } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Column ref={this.setRef}>
|
||||||
|
<ColumnHeader
|
||||||
|
icon='users'
|
||||||
|
title={intl.formatMessage(messages.title)}
|
||||||
|
onClick={this.handleHeaderClick}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<StatusListContainer
|
||||||
|
timelineId='community'
|
||||||
|
onLoadMore={this.handleLoadMore}
|
||||||
|
scrollKey='standalone_public_timeline'
|
||||||
|
trackScroll={false}
|
||||||
|
/>
|
||||||
|
</Column>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,12 +2,10 @@ import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import {
|
import { expandHashtagTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
refreshHashtagTimeline,
|
|
||||||
expandHashtagTimeline,
|
|
||||||
} from 'flavours/glitch/actions/timelines';
|
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
|
import { connectHashtagStream } from 'flavours/glitch/actions/streaming';
|
||||||
|
|
||||||
@connect()
|
@connect()
|
||||||
export default class HashtagTimeline extends React.PureComponent {
|
export default class HashtagTimeline extends React.PureComponent {
|
||||||
|
@ -28,22 +26,19 @@ export default class HashtagTimeline extends React.PureComponent {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { dispatch, hashtag } = this.props;
|
const { dispatch, hashtag } = this.props;
|
||||||
|
|
||||||
dispatch(refreshHashtagTimeline(hashtag));
|
dispatch(expandHashtagTimeline(hashtag));
|
||||||
|
this.disconnect = dispatch(connectHashtagStream(hashtag));
|
||||||
this.polling = setInterval(() => {
|
|
||||||
dispatch(refreshHashtagTimeline(hashtag));
|
|
||||||
}, 10000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
if (typeof this.polling !== 'undefined') {
|
if (this.disconnect) {
|
||||||
clearInterval(this.polling);
|
this.disconnect();
|
||||||
this.polling = null;
|
this.disconnect = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
this.props.dispatch(expandHashtagTimeline(this.props.hashtag));
|
this.props.dispatch(expandHashtagTimeline(this.props.hashtag, { maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -61,7 +56,7 @@ export default class HashtagTimeline extends React.PureComponent {
|
||||||
trackScroll={false}
|
trackScroll={false}
|
||||||
scrollKey='standalone_hashtag_timeline'
|
scrollKey='standalone_hashtag_timeline'
|
||||||
timelineId={`hashtag:${hashtag}`}
|
timelineId={`hashtag:${hashtag}`}
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
/>
|
/>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,13 +2,11 @@ import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
|
||||||
import {
|
import { expandPublicTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
refreshPublicTimeline,
|
|
||||||
expandPublicTimeline,
|
|
||||||
} from 'flavours/glitch/actions/timelines';
|
|
||||||
import Column from 'flavours/glitch/components/column';
|
import Column from 'flavours/glitch/components/column';
|
||||||
import ColumnHeader from 'flavours/glitch/components/column_header';
|
import ColumnHeader from 'flavours/glitch/components/column_header';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
import { connectPublicStream } from 'flavours/glitch/actions/streaming';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
title: { id: 'standalone.public_title', defaultMessage: 'A look inside...' },
|
title: { id: 'standalone.public_title', defaultMessage: 'A look inside...' },
|
||||||
|
@ -34,22 +32,19 @@ export default class PublicTimeline extends React.PureComponent {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
|
|
||||||
dispatch(refreshPublicTimeline());
|
dispatch(expandPublicTimeline());
|
||||||
|
this.disconnect = dispatch(connectPublicStream());
|
||||||
this.polling = setInterval(() => {
|
|
||||||
dispatch(refreshPublicTimeline());
|
|
||||||
}, 3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
if (typeof this.polling !== 'undefined') {
|
if (this.disconnect) {
|
||||||
clearInterval(this.polling);
|
this.disconnect();
|
||||||
this.polling = null;
|
this.disconnect = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLoadMore = () => {
|
handleLoadMore = maxId => {
|
||||||
this.props.dispatch(expandPublicTimeline());
|
this.props.dispatch(expandPublicTimeline({ maxId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -65,7 +60,7 @@ export default class PublicTimeline extends React.PureComponent {
|
||||||
|
|
||||||
<StatusListContainer
|
<StatusListContainer
|
||||||
timelineId='public'
|
timelineId='public'
|
||||||
loadMore={this.handleLoadMore}
|
onLoadMore={this.handleLoadMore}
|
||||||
scrollKey='standalone_public_timeline'
|
scrollKey='standalone_public_timeline'
|
||||||
trackScroll={false}
|
trackScroll={false}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { me } from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
||||||
|
direct: { id: 'status.direct', defaultMessage: 'Direct message @{name}' },
|
||||||
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
|
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
|
||||||
reply: { id: 'status.reply', defaultMessage: 'Reply' },
|
reply: { id: 'status.reply', defaultMessage: 'Reply' },
|
||||||
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
|
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
|
||||||
|
@ -43,6 +44,7 @@ export default class ActionBar extends React.PureComponent {
|
||||||
onMuteConversation: PropTypes.func,
|
onMuteConversation: PropTypes.func,
|
||||||
onBlock: PropTypes.func,
|
onBlock: PropTypes.func,
|
||||||
onDelete: PropTypes.func.isRequired,
|
onDelete: PropTypes.func.isRequired,
|
||||||
|
onDirect: PropTypes.func.isRequired,
|
||||||
onMention: PropTypes.func.isRequired,
|
onMention: PropTypes.func.isRequired,
|
||||||
onReport: PropTypes.func,
|
onReport: PropTypes.func,
|
||||||
onPin: PropTypes.func,
|
onPin: PropTypes.func,
|
||||||
|
@ -70,6 +72,10 @@ export default class ActionBar extends React.PureComponent {
|
||||||
this.props.onDelete(this.props.status);
|
this.props.onDelete(this.props.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDirectClick = () => {
|
||||||
|
this.props.onDirect(this.props.status.get('account'), this.context.router.history);
|
||||||
|
}
|
||||||
|
|
||||||
handleMentionClick = () => {
|
handleMentionClick = () => {
|
||||||
this.props.onMention(this.props.status.get('account'), this.context.router.history);
|
this.props.onMention(this.props.status.get('account'), this.context.router.history);
|
||||||
}
|
}
|
||||||
|
@ -115,6 +121,7 @@ export default class ActionBar extends React.PureComponent {
|
||||||
|
|
||||||
if (publicStatus) {
|
if (publicStatus) {
|
||||||
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed });
|
||||||
|
menu.push(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me === status.getIn(['account', 'id'])) {
|
if (me === status.getIn(['account', 'id'])) {
|
||||||
|
@ -128,6 +135,7 @@ export default class ActionBar extends React.PureComponent {
|
||||||
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
||||||
} else {
|
} else {
|
||||||
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
||||||
|
menu.push({ text: intl.formatMessage(messages.direct, { name: status.getIn(['account', 'username']) }), action: this.handleDirectClick });
|
||||||
menu.push(null);
|
menu.push(null);
|
||||||
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
||||||
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
||||||
|
@ -149,7 +157,7 @@ export default class ActionBar extends React.PureComponent {
|
||||||
<div className='detailed-status__action-bar'>
|
<div className='detailed-status__action-bar'>
|
||||||
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={status.get('in_reply_to_id', null) === null ? 'reply' : 'reply-all'} onClick={this.handleReplyClick} /></div>
|
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={status.get('in_reply_to_id', null) === null ? 'reply' : 'reply-all'} onClick={this.handleReplyClick} /></div>
|
||||||
<div className='detailed-status__button'><IconButton disabled={reblog_disabled} active={status.get('reblogged')} title={reblog_disabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(reblog_message)} icon={reblogIcon} onClick={this.handleReblogClick} /></div>
|
<div className='detailed-status__button'><IconButton disabled={reblog_disabled} active={status.get('reblogged')} title={reblog_disabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(reblog_message)} icon={reblogIcon} onClick={this.handleReblogClick} /></div>
|
||||||
<div className='detailed-status__button'><IconButton animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} activeStyle={{ color: '#ca8f04' }} /></div>
|
<div className='detailed-status__button'><IconButton className='star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} /></div>
|
||||||
{shareButton}
|
{shareButton}
|
||||||
<div className='detailed-status__button'><IconButton active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' onClick={this.handleBookmarkClick} /></div>
|
<div className='detailed-status__button'><IconButton active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' onClick={this.handleBookmarkClick} /></div>
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ export default class DetailedStatus extends ImmutablePureComponent {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOpenVideo = startTime => {
|
handleOpenVideo = (media, startTime) => {
|
||||||
this.props.onOpenVideo(this.props.status.getIn(['media_attachments', 0]), startTime);
|
this.props.onOpenVideo(media, startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {
|
||||||
import {
|
import {
|
||||||
replyCompose,
|
replyCompose,
|
||||||
mentionCompose,
|
mentionCompose,
|
||||||
|
directCompose,
|
||||||
} from 'flavours/glitch/actions/compose';
|
} from 'flavours/glitch/actions/compose';
|
||||||
import { blockAccount } from 'flavours/glitch/actions/accounts';
|
import { blockAccount } from 'flavours/glitch/actions/accounts';
|
||||||
import { muteStatus, unmuteStatus, deleteStatus } from 'flavours/glitch/actions/statuses';
|
import { muteStatus, unmuteStatus, deleteStatus } from 'flavours/glitch/actions/statuses';
|
||||||
|
@ -170,6 +171,10 @@ export default class Status extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDirectClick = (account, router) => {
|
||||||
|
this.props.dispatch(directCompose(account, router));
|
||||||
|
}
|
||||||
|
|
||||||
handleMentionClick = (account, router) => {
|
handleMentionClick = (account, router) => {
|
||||||
this.props.dispatch(mentionCompose(account, router));
|
this.props.dispatch(mentionCompose(account, router));
|
||||||
}
|
}
|
||||||
|
@ -399,6 +404,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
onReblog={this.handleReblogClick}
|
onReblog={this.handleReblogClick}
|
||||||
onBookmark={this.handleBookmarkClick}
|
onBookmark={this.handleBookmarkClick}
|
||||||
onDelete={this.handleDeleteClick}
|
onDelete={this.handleDeleteClick}
|
||||||
|
onDirect={this.handleDirectClick}
|
||||||
onMention={this.handleMentionClick}
|
onMention={this.handleMentionClick}
|
||||||
onMute={this.handleMuteClick}
|
onMute={this.handleMuteClick}
|
||||||
onMuteConversation={this.handleConversationMuteClick}
|
onMuteConversation={this.handleConversationMuteClick}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||||
import ReactSwipeableViews from 'react-swipeable-views';
|
import ReactSwipeableViews from 'react-swipeable-views';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import Video from 'flavours/glitch/features/video';
|
||||||
import ExtendedVideoPlayer from 'flavours/glitch/components/extended_video_player';
|
import ExtendedVideoPlayer from 'flavours/glitch/components/extended_video_player';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
|
@ -112,6 +113,22 @@ export default class MediaModal extends ImmutablePureComponent {
|
||||||
onClick={this.toggleNavigation}
|
onClick={this.toggleNavigation}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
} else if (image.get('type') === 'video') {
|
||||||
|
const { time } = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Video
|
||||||
|
preview={image.get('preview_url')}
|
||||||
|
src={image.get('url')}
|
||||||
|
width={image.get('width')}
|
||||||
|
height={image.get('height')}
|
||||||
|
startTime={time || 0}
|
||||||
|
onCloseVideo={onClose}
|
||||||
|
detailed
|
||||||
|
description={image.get('description')}
|
||||||
|
key={image.get('url')}
|
||||||
|
/>
|
||||||
|
);
|
||||||
} else if (image.get('type') === 'gifv') {
|
} else if (image.get('type') === 'gifv') {
|
||||||
return (
|
return (
|
||||||
<ExtendedVideoPlayer
|
<ExtendedVideoPlayer
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
const visible = !!type;
|
const visible = !!type;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Base onClose={onClose}>
|
<Base onClose={onClose} noEsc={props ? props.noEsc : false}>
|
||||||
{visible && (
|
{visible && (
|
||||||
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
|
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
|
||||||
{(SpecificComponent) => <SpecificComponent {...props} onClose={onClose} />}
|
{(SpecificComponent) => <SpecificComponent {...props} onClose={onClose} />}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { changeReportComment, changeReportForward, submitReport } from 'flavours/glitch/actions/reports';
|
import { changeReportComment, changeReportForward, submitReport } from 'flavours/glitch/actions/reports';
|
||||||
import { refreshAccountTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandAccountTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { makeGetAccount } from 'flavours/glitch/selectors';
|
import { makeGetAccount } from 'flavours/glitch/selectors';
|
||||||
|
@ -64,12 +64,12 @@ export default class ReportModal extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.props.dispatch(refreshAccountTimeline(this.props.account.get('id'), true));
|
this.props.dispatch(expandAccountTimeline(this.props.account.get('id'), { withReplies: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if (this.props.account !== nextProps.account && nextProps.account) {
|
if (this.props.account !== nextProps.account && nextProps.account) {
|
||||||
this.props.dispatch(refreshAccountTimeline(nextProps.account.get('id'), true));
|
this.props.dispatch(expandAccountTimeline(nextProps.account.get('id'), { withReplies: true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ const makeGetStatusIds = () => createSelector([
|
||||||
}
|
}
|
||||||
|
|
||||||
return statusIds.filter(id => {
|
return statusIds.filter(id => {
|
||||||
|
if (id === null) return true;
|
||||||
|
|
||||||
const statusForId = statuses.get(id);
|
const statusForId = statuses.get(id);
|
||||||
let showStatus = true;
|
let showStatus = true;
|
||||||
|
|
||||||
|
@ -52,18 +54,13 @@ const makeMapStateToProps = () => {
|
||||||
statusIds: getStatusIds(state, { type: timelineId }),
|
statusIds: getStatusIds(state, { type: timelineId }),
|
||||||
isLoading: state.getIn(['timelines', timelineId, 'isLoading'], true),
|
isLoading: state.getIn(['timelines', timelineId, 'isLoading'], true),
|
||||||
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
|
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
|
||||||
hasMore: !!state.getIn(['timelines', timelineId, 'next']),
|
hasMore: state.getIn(['timelines', timelineId, 'hasMore']),
|
||||||
});
|
});
|
||||||
|
|
||||||
return mapStateToProps;
|
return mapStateToProps;
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch, { timelineId, loadMore }) => ({
|
const mapDispatchToProps = (dispatch, { timelineId }) => ({
|
||||||
|
|
||||||
onScrollToBottom: debounce(() => {
|
|
||||||
dispatch(scrollTopTimeline(timelineId, false));
|
|
||||||
loadMore();
|
|
||||||
}, 300, { leading: true }),
|
|
||||||
|
|
||||||
onScrollToTop: debounce(() => {
|
onScrollToTop: debounce(() => {
|
||||||
dispatch(scrollTopTimeline(timelineId, true));
|
dispatch(scrollTopTimeline(timelineId, true));
|
||||||
|
|
|
@ -9,8 +9,8 @@ import { Redirect, withRouter } from 'react-router-dom';
|
||||||
import { isMobile } from 'flavours/glitch/util/is_mobile';
|
import { isMobile } from 'flavours/glitch/util/is_mobile';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { uploadCompose, resetCompose } from 'flavours/glitch/actions/compose';
|
import { uploadCompose, resetCompose } from 'flavours/glitch/actions/compose';
|
||||||
import { refreshHomeTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandHomeTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
import { refreshNotifications } from 'flavours/glitch/actions/notifications';
|
import { expandNotifications } from 'flavours/glitch/actions/notifications';
|
||||||
import { clearHeight } from 'flavours/glitch/actions/height_cache';
|
import { clearHeight } from 'flavours/glitch/actions/height_cache';
|
||||||
import { WrappedSwitch, WrappedRoute } from 'flavours/glitch/util/react_router_helpers';
|
import { WrappedSwitch, WrappedRoute } from 'flavours/glitch/util/react_router_helpers';
|
||||||
import UploadArea from './components/upload_area';
|
import UploadArea from './components/upload_area';
|
||||||
|
@ -219,8 +219,8 @@ export default class UI extends React.Component {
|
||||||
navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage);
|
navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.dispatch(refreshHomeTimeline());
|
this.props.dispatch(expandHomeTimeline());
|
||||||
this.props.dispatch(refreshNotifications());
|
this.props.dispatch(expandNotifications());
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
|
import { fromJS } from 'immutable';
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { isFullscreen, requestFullscreen, exitFullscreen } from 'flavours/glitch/util/fullscreen';
|
import { isFullscreen, requestFullscreen, exitFullscreen } from 'flavours/glitch/util/fullscreen';
|
||||||
|
@ -133,6 +134,8 @@ export default class Video extends React.PureComponent {
|
||||||
this.seek = c;
|
this.seek = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleClickRoot = e => e.stopPropagation();
|
||||||
|
|
||||||
handlePlay = () => {
|
handlePlay = () => {
|
||||||
this.setState({ paused: false });
|
this.setState({ paused: false });
|
||||||
}
|
}
|
||||||
|
@ -246,8 +249,17 @@ export default class Video extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOpenVideo = () => {
|
handleOpenVideo = () => {
|
||||||
|
const { src, preview, width, height } = this.props;
|
||||||
|
const media = fromJS({
|
||||||
|
type: 'video',
|
||||||
|
url: src,
|
||||||
|
preview_url: preview,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
});
|
||||||
|
|
||||||
this.video.pause();
|
this.video.pause();
|
||||||
this.props.onOpenVideo(this.video.currentTime);
|
this.props.onOpenVideo(media, this.video.currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCloseVideo = () => {
|
handleCloseVideo = () => {
|
||||||
|
@ -279,7 +291,15 @@ export default class Video extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames('video-player', { inactive: !revealed, detailed, inline: inline && !fullscreen, fullscreen, letterbox, 'full-width': fullwidth })} style={playerStyle} ref={this.setPlayerRef} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
|
<div
|
||||||
|
className={classNames('video-player', { inactive: !revealed, detailed, inline: inline && !fullscreen, fullscreen, letterbox, 'full-width': fullwidth })}
|
||||||
|
style={playerStyle}
|
||||||
|
ref={this.setPlayerRef}
|
||||||
|
onMouseEnter={this.handleMouseEnter}
|
||||||
|
onMouseLeave={this.handleMouseLeave}
|
||||||
|
onClick={this.handleClickRoot}
|
||||||
|
tabIndex={0}
|
||||||
|
>
|
||||||
<video
|
<video
|
||||||
ref={this.setVideoRef}
|
ref={this.setVideoRef}
|
||||||
src={src}
|
src={src}
|
||||||
|
|
|
@ -6,8 +6,6 @@ function main() {
|
||||||
const emojify = require('flavours/glitch/util/emoji').default;
|
const emojify = require('flavours/glitch/util/emoji').default;
|
||||||
const { getLocale } = require('locales');
|
const { getLocale } = require('locales');
|
||||||
const { localeData } = getLocale();
|
const { localeData } = getLocale();
|
||||||
const VideoContainer = require('flavours/glitch/containers/video_container').default;
|
|
||||||
const CardContainer = require('flavours/glitch/containers/card_container').default;
|
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const ReactDOM = require('react-dom');
|
const ReactDOM = require('react-dom');
|
||||||
|
|
||||||
|
@ -52,24 +50,15 @@ function main() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
[].forEach.call(document.querySelectorAll('[data-component="Video"]'), (content) => {
|
const reactComponents = document.querySelectorAll('[data-component]');
|
||||||
const props = JSON.parse(content.getAttribute('data-props'));
|
if (reactComponents.length > 0) {
|
||||||
ReactDOM.render(<VideoContainer locale={locale} {...props} />, content);
|
import(/* webpackChunkName: "containers/media_container" */ 'flavours/glitch/containers/media_container')
|
||||||
});
|
.then(({ default: MediaContainer }) => {
|
||||||
|
|
||||||
[].forEach.call(document.querySelectorAll('[data-component="Card"]'), (content) => {
|
|
||||||
const props = JSON.parse(content.getAttribute('data-props'));
|
|
||||||
ReactDOM.render(<CardContainer locale={locale} {...props} />, content);
|
|
||||||
});
|
|
||||||
|
|
||||||
const mediaGalleries = document.querySelectorAll('[data-component="MediaGallery"]');
|
|
||||||
|
|
||||||
if (mediaGalleries.length > 0) {
|
|
||||||
const MediaGalleriesContainer = require('flavours/glitch/containers/media_galleries_container').default;
|
|
||||||
const content = document.createElement('div');
|
const content = document.createElement('div');
|
||||||
|
ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
|
||||||
ReactDOM.render(<MediaGalleriesContainer locale={locale} galleries={mediaGalleries} />, content);
|
|
||||||
document.body.appendChild(content);
|
document.body.appendChild(content);
|
||||||
|
})
|
||||||
|
.catch(error => console.error(error));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,12 @@ import { STORE_HYDRATE } from 'flavours/glitch/actions/store';
|
||||||
import emojify from 'flavours/glitch/util/emoji';
|
import emojify from 'flavours/glitch/util/emoji';
|
||||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
import escapeTextContentForBrowser from 'escape-html';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
|
import { unescapeHTML } from 'flavours/glitch/util/html';
|
||||||
|
|
||||||
|
const makeEmojiMap = record => record.emojis.reduce((obj, emoji) => {
|
||||||
|
obj[`:${emoji.shortcode}:`] = emoji;
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
|
|
||||||
const normalizeAccount = (state, account) => {
|
const normalizeAccount = (state, account) => {
|
||||||
account = { ...account };
|
account = { ...account };
|
||||||
|
@ -65,15 +71,17 @@ const normalizeAccount = (state, account) => {
|
||||||
delete account.following_count;
|
delete account.following_count;
|
||||||
delete account.statuses_count;
|
delete account.statuses_count;
|
||||||
|
|
||||||
|
const emojiMap = makeEmojiMap(account);
|
||||||
const displayName = account.display_name.length === 0 ? account.username : account.display_name;
|
const displayName = account.display_name.length === 0 ? account.username : account.display_name;
|
||||||
account.display_name_html = emojify(escapeTextContentForBrowser(displayName));
|
account.display_name_html = emojify(escapeTextContentForBrowser(displayName), emojiMap);
|
||||||
account.note_emojified = emojify(account.note);
|
account.note_emojified = emojify(account.note, emojiMap);
|
||||||
|
|
||||||
if (account.fields) {
|
if (account.fields) {
|
||||||
account.fields = account.fields.map(pair => ({
|
account.fields = account.fields.map(pair => ({
|
||||||
...pair,
|
...pair,
|
||||||
name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
|
name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
|
||||||
value_emojified: emojify(pair.value),
|
value_emojified: emojify(pair.value, emojiMap),
|
||||||
|
value_plain: unescapeHTML(pair.value),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
COMPOSE_CYCLE_ELEFRIEND,
|
COMPOSE_CYCLE_ELEFRIEND,
|
||||||
COMPOSE_REPLY,
|
COMPOSE_REPLY,
|
||||||
COMPOSE_REPLY_CANCEL,
|
COMPOSE_REPLY_CANCEL,
|
||||||
|
COMPOSE_DIRECT,
|
||||||
COMPOSE_MENTION,
|
COMPOSE_MENTION,
|
||||||
COMPOSE_SUBMIT_REQUEST,
|
COMPOSE_SUBMIT_REQUEST,
|
||||||
COMPOSE_SUBMIT_SUCCESS,
|
COMPOSE_SUBMIT_SUCCESS,
|
||||||
|
@ -55,6 +56,7 @@ const initialState = ImmutableMap({
|
||||||
privacy: null,
|
privacy: null,
|
||||||
text: '',
|
text: '',
|
||||||
focusDate: null,
|
focusDate: null,
|
||||||
|
caretPosition: null,
|
||||||
preselectDate: null,
|
preselectDate: null,
|
||||||
in_reply_to: null,
|
in_reply_to: null,
|
||||||
is_submitting: false,
|
is_submitting: false,
|
||||||
|
@ -147,6 +149,7 @@ function continueThread (state, status) {
|
||||||
map.update('media_attachments', list => list.clear());
|
map.update('media_attachments', list => list.clear());
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
map.set('focusDate', new Date());
|
map.set('focusDate', new Date());
|
||||||
|
map.set('caretPosition', null);
|
||||||
map.set('preselectDate', new Date());
|
map.set('preselectDate', new Date());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -158,7 +161,6 @@ function appendMedia(state, media) {
|
||||||
map.update('media_attachments', list => list.push(media));
|
map.update('media_attachments', list => list.push(media));
|
||||||
map.set('is_uploading', false);
|
map.set('is_uploading', false);
|
||||||
map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
|
map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
|
||||||
map.set('focusDate', new Date());
|
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
|
|
||||||
if (prevSize === 0 && (state.get('default_sensitive') || state.get('spoiler'))) {
|
if (prevSize === 0 && (state.get('default_sensitive') || state.get('spoiler'))) {
|
||||||
|
@ -186,6 +188,7 @@ const insertSuggestion = (state, position, token, completion) => {
|
||||||
map.set('suggestion_token', null);
|
map.set('suggestion_token', null);
|
||||||
map.update('suggestions', ImmutableList(), list => list.clear());
|
map.update('suggestions', ImmutableList(), list => list.clear());
|
||||||
map.set('focusDate', new Date());
|
map.set('focusDate', new Date());
|
||||||
|
map.set('caretPosition', position + completion.length + 1);
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -196,6 +199,7 @@ const insertEmoji = (state, position, emojiData) => {
|
||||||
return state.withMutations(map => {
|
return state.withMutations(map => {
|
||||||
map.update('text', oldText => `${oldText.slice(0, position)}${emoji}\u200B${oldText.slice(position)}`);
|
map.update('text', oldText => `${oldText.slice(0, position)}${emoji}\u200B${oldText.slice(position)}`);
|
||||||
map.set('focusDate', new Date());
|
map.set('focusDate', new Date());
|
||||||
|
map.set('caretPosition', position + emoji.length + 1);
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -277,6 +281,7 @@ export default function compose(state = initialState, action) {
|
||||||
map => map.merge(new ImmutableMap({ do_not_federate: /👁\ufe0f?\u200b?(?:<\/p>)?$/.test(action.status.get('content')) }))
|
map => map.merge(new ImmutableMap({ do_not_federate: /👁\ufe0f?\u200b?(?:<\/p>)?$/.test(action.status.get('content')) }))
|
||||||
);
|
);
|
||||||
map.set('focusDate', new Date());
|
map.set('focusDate', new Date());
|
||||||
|
map.set('caretPosition', null);
|
||||||
map.set('preselectDate', new Date());
|
map.set('preselectDate', new Date());
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
|
|
||||||
|
@ -321,10 +326,20 @@ export default function compose(state = initialState, action) {
|
||||||
case COMPOSE_UPLOAD_PROGRESS:
|
case COMPOSE_UPLOAD_PROGRESS:
|
||||||
return state.set('progress', Math.round((action.loaded / action.total) * 100));
|
return state.set('progress', Math.round((action.loaded / action.total) * 100));
|
||||||
case COMPOSE_MENTION:
|
case COMPOSE_MENTION:
|
||||||
return state
|
return state.withMutations(map => {
|
||||||
.update('text', text => `${text}@${action.account.get('acct')} `)
|
map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' '));
|
||||||
.set('focusDate', new Date())
|
map.set('focusDate', new Date());
|
||||||
.set('idempotencyKey', uuid());
|
map.set('caretPosition', null);
|
||||||
|
map.set('idempotencyKey', uuid());
|
||||||
|
});
|
||||||
|
case COMPOSE_DIRECT:
|
||||||
|
return state.withMutations(map => {
|
||||||
|
map.update('text', text => [text.trim(), `@${action.account.get('acct')} `].filter((str) => str.length !== 0).join(' '));
|
||||||
|
map.set('privacy', 'direct');
|
||||||
|
map.set('focusDate', new Date());
|
||||||
|
map.set('caretPosition', null);
|
||||||
|
map.set('idempotencyKey', uuid());
|
||||||
|
});
|
||||||
case COMPOSE_SUGGESTIONS_CLEAR:
|
case COMPOSE_SUGGESTIONS_CLEAR:
|
||||||
return state.update('suggestions', ImmutableList(), list => list.clear()).set('suggestion_token', null);
|
return state.update('suggestions', ImmutableList(), list => list.clear()).set('suggestion_token', null);
|
||||||
case COMPOSE_SUGGESTIONS_READY:
|
case COMPOSE_SUGGESTIONS_READY:
|
||||||
|
|
|
@ -6,7 +6,9 @@ import {
|
||||||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
blocks: ImmutableMap(),
|
blocks: ImmutableMap({
|
||||||
|
items: ImmutableOrderedSet(),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function domainLists(state = initialState, action) {
|
export default function domainLists(state = initialState, action) {
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import {
|
import {
|
||||||
NOTIFICATIONS_UPDATE,
|
NOTIFICATIONS_UPDATE,
|
||||||
NOTIFICATIONS_REFRESH_SUCCESS,
|
|
||||||
NOTIFICATIONS_EXPAND_SUCCESS,
|
NOTIFICATIONS_EXPAND_SUCCESS,
|
||||||
NOTIFICATIONS_REFRESH_REQUEST,
|
|
||||||
NOTIFICATIONS_EXPAND_REQUEST,
|
NOTIFICATIONS_EXPAND_REQUEST,
|
||||||
NOTIFICATIONS_REFRESH_FAIL,
|
|
||||||
NOTIFICATIONS_EXPAND_FAIL,
|
NOTIFICATIONS_EXPAND_FAIL,
|
||||||
NOTIFICATIONS_CLEAR,
|
NOTIFICATIONS_CLEAR,
|
||||||
NOTIFICATIONS_SCROLL_TOP,
|
NOTIFICATIONS_SCROLL_TOP,
|
||||||
|
@ -19,16 +16,16 @@ import {
|
||||||
ACCOUNT_BLOCK_SUCCESS,
|
ACCOUNT_BLOCK_SUCCESS,
|
||||||
ACCOUNT_MUTE_SUCCESS,
|
ACCOUNT_MUTE_SUCCESS,
|
||||||
} from 'flavours/glitch/actions/accounts';
|
} from 'flavours/glitch/actions/accounts';
|
||||||
import { TIMELINE_DELETE } from 'flavours/glitch/actions/timelines';
|
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from 'flavours/glitch/actions/timelines';
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
import compareId from 'flavours/glitch/util/compare_id';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
items: ImmutableList(),
|
items: ImmutableList(),
|
||||||
next: null,
|
hasMore: true,
|
||||||
top: true,
|
top: true,
|
||||||
unread: 0,
|
unread: 0,
|
||||||
loaded: false,
|
isLoading: false,
|
||||||
isLoading: true,
|
|
||||||
cleaningMode: false,
|
cleaningMode: false,
|
||||||
// notification removal mark of new notifs loaded whilst cleaningMode is true.
|
// notification removal mark of new notifs loaded whilst cleaningMode is true.
|
||||||
markNewForDelete: false,
|
markNewForDelete: false,
|
||||||
|
@ -58,39 +55,38 @@ const normalizeNotification = (state, notification) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeNotifications = (state, notifications, next) => {
|
const expandNormalizedNotifications = (state, notifications, next) => {
|
||||||
let items = ImmutableList();
|
let items = ImmutableList();
|
||||||
const loaded = state.get('loaded');
|
|
||||||
|
|
||||||
notifications.forEach((n, i) => {
|
notifications.forEach((n, i) => {
|
||||||
items = items.set(i, notificationToMap(state, n));
|
items = items.set(i, notificationToMap(state, n));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (state.get('next') === null) {
|
return state.withMutations(mutable => {
|
||||||
state = state.set('next', next);
|
if (!items.isEmpty()) {
|
||||||
|
mutable.update('items', list => {
|
||||||
|
const lastIndex = 1 + list.findLastIndex(
|
||||||
|
item => item !== null && (compareId(item.get('id'), items.last().get('id')) > 0 || item.get('id') === items.last().get('id'))
|
||||||
|
);
|
||||||
|
|
||||||
|
const firstIndex = 1 + list.take(lastIndex).findLastIndex(
|
||||||
|
item => item !== null && compareId(item.get('id'), items.first().get('id')) > 0
|
||||||
|
);
|
||||||
|
|
||||||
|
return list.take(firstIndex).concat(items, list.skip(lastIndex));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return state
|
if (!next) {
|
||||||
.update('items', list => loaded ? items.concat(list) : list.concat(items))
|
mutable.set('hasMore', true);
|
||||||
.set('loaded', true)
|
}
|
||||||
.set('isLoading', false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const appendNormalizedNotifications = (state, notifications, next) => {
|
mutable.set('isLoading', false);
|
||||||
let items = ImmutableList();
|
|
||||||
|
|
||||||
notifications.forEach((n, i) => {
|
|
||||||
items = items.set(i, notificationToMap(state, n));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return state
|
|
||||||
.update('items', list => list.concat(items))
|
|
||||||
.set('next', next)
|
|
||||||
.set('isLoading', false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterNotifications = (state, relationship) => {
|
const filterNotifications = (state, relationship) => {
|
||||||
return state.update('items', list => list.filterNot(item => item.get('account') === relationship.id));
|
return state.update('items', list => list.filterNot(item => item !== null && item.get('account') === relationship.id));
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateTop = (state, top) => {
|
const updateTop = (state, top) => {
|
||||||
|
@ -102,7 +98,7 @@ const updateTop = (state, top) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteByStatus = (state, statusId) => {
|
const deleteByStatus = (state, statusId) => {
|
||||||
return state.update('items', list => list.filterNot(item => item.get('status') === statusId));
|
return state.update('items', list => list.filterNot(item => item !== null && item.get('status') === statusId));
|
||||||
};
|
};
|
||||||
|
|
||||||
const markForDelete = (state, notificationId, yes) => {
|
const markForDelete = (state, notificationId, yes) => {
|
||||||
|
@ -137,29 +133,29 @@ export default function notifications(state = initialState, action) {
|
||||||
let st;
|
let st;
|
||||||
|
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case NOTIFICATIONS_REFRESH_REQUEST:
|
|
||||||
case NOTIFICATIONS_EXPAND_REQUEST:
|
case NOTIFICATIONS_EXPAND_REQUEST:
|
||||||
case NOTIFICATIONS_DELETE_MARKED_REQUEST:
|
case NOTIFICATIONS_DELETE_MARKED_REQUEST:
|
||||||
return state.set('isLoading', true);
|
return state.set('isLoading', true);
|
||||||
case NOTIFICATIONS_DELETE_MARKED_FAIL:
|
case NOTIFICATIONS_DELETE_MARKED_FAIL:
|
||||||
case NOTIFICATIONS_REFRESH_FAIL:
|
|
||||||
case NOTIFICATIONS_EXPAND_FAIL:
|
case NOTIFICATIONS_EXPAND_FAIL:
|
||||||
return state.set('isLoading', false);
|
return state.set('isLoading', false);
|
||||||
case NOTIFICATIONS_SCROLL_TOP:
|
case NOTIFICATIONS_SCROLL_TOP:
|
||||||
return updateTop(state, action.top);
|
return updateTop(state, action.top);
|
||||||
case NOTIFICATIONS_UPDATE:
|
case NOTIFICATIONS_UPDATE:
|
||||||
return normalizeNotification(state, action.notification);
|
return normalizeNotification(state, action.notification);
|
||||||
case NOTIFICATIONS_REFRESH_SUCCESS:
|
|
||||||
return normalizeNotifications(state, action.notifications, action.next);
|
|
||||||
case NOTIFICATIONS_EXPAND_SUCCESS:
|
case NOTIFICATIONS_EXPAND_SUCCESS:
|
||||||
return appendNormalizedNotifications(state, action.notifications, action.next);
|
return expandNormalizedNotifications(state, action.notifications, action.next);
|
||||||
case ACCOUNT_BLOCK_SUCCESS:
|
case ACCOUNT_BLOCK_SUCCESS:
|
||||||
case ACCOUNT_MUTE_SUCCESS:
|
case ACCOUNT_MUTE_SUCCESS:
|
||||||
return filterNotifications(state, action.relationship);
|
return filterNotifications(state, action.relationship);
|
||||||
case NOTIFICATIONS_CLEAR:
|
case NOTIFICATIONS_CLEAR:
|
||||||
return state.set('items', ImmutableList()).set('next', null);
|
return state.set('items', ImmutableList()).set('hasMore', false);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
return deleteByStatus(state, action.id);
|
return deleteByStatus(state, action.id);
|
||||||
|
case TIMELINE_DISCONNECT:
|
||||||
|
return action.timeline === 'home' ?
|
||||||
|
state.update('items', items => items.first() ? items.unshift(null) : items) :
|
||||||
|
state;
|
||||||
|
|
||||||
case NOTIFICATION_MARK_FOR_DELETE:
|
case NOTIFICATION_MARK_FOR_DELETE:
|
||||||
return markForDelete(state, action.id, action.yes);
|
return markForDelete(state, action.id, action.yes);
|
||||||
|
|
|
@ -4,7 +4,11 @@ import {
|
||||||
SEARCH_FETCH_SUCCESS,
|
SEARCH_FETCH_SUCCESS,
|
||||||
SEARCH_SHOW,
|
SEARCH_SHOW,
|
||||||
} from 'flavours/glitch/actions/search';
|
} from 'flavours/glitch/actions/search';
|
||||||
import { COMPOSE_MENTION, COMPOSE_REPLY } from 'flavours/glitch/actions/compose';
|
import {
|
||||||
|
COMPOSE_MENTION,
|
||||||
|
COMPOSE_REPLY,
|
||||||
|
COMPOSE_DIRECT,
|
||||||
|
} from 'flavours/glitch/actions/compose';
|
||||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
|
@ -29,6 +33,7 @@ export default function search(state = initialState, action) {
|
||||||
return state.set('hidden', false);
|
return state.set('hidden', false);
|
||||||
case COMPOSE_REPLY:
|
case COMPOSE_REPLY:
|
||||||
case COMPOSE_MENTION:
|
case COMPOSE_MENTION:
|
||||||
|
case COMPOSE_DIRECT:
|
||||||
return state.set('hidden', true);
|
return state.set('hidden', true);
|
||||||
case SEARCH_FETCH_SUCCESS:
|
case SEARCH_FETCH_SUCCESS:
|
||||||
return state.set('results', ImmutableMap({
|
return state.set('results', ImmutableMap({
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
import {
|
import {
|
||||||
TIMELINE_REFRESH_REQUEST,
|
|
||||||
TIMELINE_REFRESH_SUCCESS,
|
|
||||||
TIMELINE_REFRESH_FAIL,
|
|
||||||
TIMELINE_UPDATE,
|
TIMELINE_UPDATE,
|
||||||
TIMELINE_DELETE,
|
TIMELINE_DELETE,
|
||||||
TIMELINE_EXPAND_SUCCESS,
|
TIMELINE_EXPAND_SUCCESS,
|
||||||
TIMELINE_EXPAND_REQUEST,
|
TIMELINE_EXPAND_REQUEST,
|
||||||
TIMELINE_EXPAND_FAIL,
|
TIMELINE_EXPAND_FAIL,
|
||||||
TIMELINE_SCROLL_TOP,
|
TIMELINE_SCROLL_TOP,
|
||||||
TIMELINE_CONNECT,
|
|
||||||
TIMELINE_DISCONNECT,
|
TIMELINE_DISCONNECT,
|
||||||
} from 'flavours/glitch/actions/timelines';
|
} from 'flavours/glitch/actions/timelines';
|
||||||
import {
|
import {
|
||||||
|
@ -17,42 +13,39 @@ import {
|
||||||
ACCOUNT_UNFOLLOW_SUCCESS,
|
ACCOUNT_UNFOLLOW_SUCCESS,
|
||||||
} from 'flavours/glitch/actions/accounts';
|
} from 'flavours/glitch/actions/accounts';
|
||||||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||||
|
import compareId from 'flavours/glitch/util/compare_id';
|
||||||
|
|
||||||
const initialState = ImmutableMap();
|
const initialState = ImmutableMap();
|
||||||
|
|
||||||
const initialTimeline = ImmutableMap({
|
const initialTimeline = ImmutableMap({
|
||||||
unread: 0,
|
unread: 0,
|
||||||
online: false,
|
|
||||||
top: true,
|
top: true,
|
||||||
loaded: false,
|
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
next: false,
|
hasMore: true,
|
||||||
items: ImmutableList(),
|
items: ImmutableList(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeTimeline = (state, timeline, statuses, next, isPartial) => {
|
const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial) => {
|
||||||
const oldIds = state.getIn([timeline, 'items'], ImmutableList());
|
|
||||||
const ids = ImmutableList(statuses.map(status => status.get('id'))).filter(newId => !oldIds.includes(newId));
|
|
||||||
const wasLoaded = state.getIn([timeline, 'loaded']);
|
|
||||||
const hadNext = state.getIn([timeline, 'next']);
|
|
||||||
|
|
||||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
|
||||||
mMap.set('loaded', true);
|
|
||||||
mMap.set('isLoading', false);
|
|
||||||
if (!hadNext) mMap.set('next', next);
|
|
||||||
mMap.set('items', wasLoaded ? ids.concat(oldIds) : oldIds.concat(ids));
|
|
||||||
mMap.set('isPartial', isPartial);
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
const appendNormalizedTimeline = (state, timeline, statuses, next) => {
|
|
||||||
const oldIds = state.getIn([timeline, 'items'], ImmutableList());
|
|
||||||
const ids = ImmutableList(statuses.map(status => status.get('id'))).filter(newId => !oldIds.includes(newId));
|
|
||||||
|
|
||||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||||
mMap.set('isLoading', false);
|
mMap.set('isLoading', false);
|
||||||
mMap.set('next', next);
|
if (!next) mMap.set('hasMore', false);
|
||||||
mMap.set('items', oldIds.concat(ids));
|
|
||||||
|
if (!statuses.isEmpty()) {
|
||||||
|
mMap.update('items', ImmutableList(), oldIds => {
|
||||||
|
const newIds = statuses.map(status => status.get('id'));
|
||||||
|
const lastIndex = oldIds.findLastIndex(id => id !== null && compareId(id, newIds.last()) >= 0) + 1;
|
||||||
|
const firstIndex = oldIds.take(lastIndex).findLastIndex(id => id !== null && compareId(id, newIds.first()) > 0);
|
||||||
|
|
||||||
|
if (firstIndex < 0) {
|
||||||
|
return (isPartial ? newIds.unshift(null) : newIds).concat(oldIds.skip(lastIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
return oldIds.take(firstIndex + 1).concat(
|
||||||
|
isPartial && oldIds.get(firstIndex) !== null ? newIds.unshift(null) : newIds,
|
||||||
|
oldIds.skip(lastIndex)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,16 +112,12 @@ const updateTop = (state, timeline, top) => {
|
||||||
|
|
||||||
export default function timelines(state = initialState, action) {
|
export default function timelines(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case TIMELINE_REFRESH_REQUEST:
|
|
||||||
case TIMELINE_EXPAND_REQUEST:
|
case TIMELINE_EXPAND_REQUEST:
|
||||||
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', true));
|
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', true));
|
||||||
case TIMELINE_REFRESH_FAIL:
|
|
||||||
case TIMELINE_EXPAND_FAIL:
|
case TIMELINE_EXPAND_FAIL:
|
||||||
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', false));
|
return state.update(action.timeline, initialTimeline, map => map.set('isLoading', false));
|
||||||
case TIMELINE_REFRESH_SUCCESS:
|
|
||||||
return normalizeTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial);
|
|
||||||
case TIMELINE_EXPAND_SUCCESS:
|
case TIMELINE_EXPAND_SUCCESS:
|
||||||
return appendNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next);
|
return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial);
|
||||||
case TIMELINE_UPDATE:
|
case TIMELINE_UPDATE:
|
||||||
return updateTimeline(state, action.timeline, fromJS(action.status), action.references);
|
return updateTimeline(state, action.timeline, fromJS(action.status), action.references);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
|
@ -140,10 +129,15 @@ export default function timelines(state = initialState, action) {
|
||||||
return filterTimeline('home', state, action.relationship, action.statuses);
|
return filterTimeline('home', state, action.relationship, action.statuses);
|
||||||
case TIMELINE_SCROLL_TOP:
|
case TIMELINE_SCROLL_TOP:
|
||||||
return updateTop(state, action.timeline, action.top);
|
return updateTop(state, action.timeline, action.top);
|
||||||
case TIMELINE_CONNECT:
|
|
||||||
return state.update(action.timeline, initialTimeline, map => map.set('online', true));
|
|
||||||
case TIMELINE_DISCONNECT:
|
case TIMELINE_DISCONNECT:
|
||||||
return state.update(action.timeline, initialTimeline, map => map.set('online', false));
|
return state.update(
|
||||||
|
action.timeline,
|
||||||
|
initialTimeline,
|
||||||
|
map => map.update(
|
||||||
|
'items',
|
||||||
|
items => items.first() ? items.unshift(null) : items
|
||||||
|
)
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue