mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 08:19:05 +00:00
Compare commits
339 Commits
no-dm-opti
...
thread-mod
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c71d848855 | ||
|
|
e4bc013d6f | ||
|
|
6932b464e6 | ||
|
|
ad10a80a99 | ||
|
|
8bf9d9362a | ||
|
|
03aeab857f | ||
|
|
f441770e50 | ||
|
|
b4e667f86b | ||
|
|
faf20eeaa4 | ||
|
|
f6adb409fd | ||
|
|
10f6793fd0 | ||
|
|
a594139115 | ||
|
|
95bd85d9e8 | ||
|
|
8d51ce4290 | ||
|
|
f41b33eb01 | ||
|
|
9fc08e4861 | ||
|
|
6236577734 | ||
|
|
06636c6eca | ||
|
|
d7ce339c2e | ||
|
|
e9822a4e4e | ||
|
|
9a61b0ef22 | ||
|
|
42f50049ff | ||
|
|
b4a3792201 | ||
|
|
083170bec7 | ||
|
|
8713659dff | ||
|
|
3c29f57404 | ||
|
|
924ffe81d4 | ||
|
|
c69a23ae46 | ||
|
|
d872902997 | ||
|
|
5ec25ff3e1 | ||
|
|
49e296e1b0 | ||
|
|
7347d4f8bb | ||
|
|
7571c37c99 | ||
|
|
3c18964256 | ||
|
|
c61dd918a2 | ||
|
|
0f69a90588 | ||
|
|
02ba03d6db | ||
|
|
3bee0996c5 | ||
|
|
89daeb43a8 | ||
|
|
7d4f4f9aab | ||
|
|
256c2b1de0 | ||
|
|
02e3e1ec09 | ||
|
|
ff924f95bb | ||
|
|
c10f4bdb03 | ||
|
|
fc884d015a | ||
|
|
d907d4352e | ||
|
|
a8b51124ba | ||
|
|
161c72d66d | ||
|
|
53d99ebf4f | ||
|
|
1001922156 | ||
|
|
933840bebf | ||
|
|
99f962ba73 | ||
|
|
2471796d75 | ||
|
|
545095b3ce | ||
|
|
d319b3dbe4 | ||
|
|
d60fd87e01 | ||
|
|
94230fe565 | ||
|
|
04ecf44c2f | ||
|
|
b6af88192f | ||
|
|
1419f656e2 | ||
|
|
3ba7cde38d | ||
|
|
ce854ed506 | ||
|
|
21b9da6418 | ||
|
|
fa768abf5c | ||
|
|
54148b9a4a | ||
|
|
764f876953 | ||
|
|
2c1ed5f872 | ||
|
|
72b99f6ee4 | ||
|
|
fa9b7ece2e | ||
|
|
7d376e41be | ||
|
|
d817c0a958 | ||
|
|
4cca1d1e7e | ||
|
|
e4944d065b | ||
|
|
513d982f29 | ||
|
|
4ce44ba470 | ||
|
|
0dce26b82b | ||
|
|
f4b80e6511 | ||
|
|
a56c4742d3 | ||
|
|
38fc1b498d | ||
|
|
65c87ca0ae | ||
|
|
511c6f9625 | ||
|
|
832a93e67c | ||
|
|
868568d1c1 | ||
|
|
7174d1c955 | ||
|
|
65f30f65a2 | ||
|
|
e0ef7f9d79 | ||
|
|
7347bc7334 | ||
|
|
e6ab869d95 | ||
|
|
20ad071931 | ||
|
|
14243bf80a | ||
|
|
337c2e77ee | ||
|
|
46565ed746 | ||
|
|
815524412b | ||
|
|
083571915f | ||
|
|
2bbd22e91c | ||
|
|
6b85dba8da | ||
|
|
127bfda521 | ||
|
|
1494509468 | ||
|
|
cc6a2ffd0a | ||
|
|
22818d2a16 | ||
|
|
bed13f22e2 | ||
|
|
1e5d1fa5c8 | ||
|
|
a3b369337f | ||
|
|
43c37a4768 | ||
|
|
f77c47d01b | ||
|
|
cafe27fb29 | ||
|
|
7e6214b869 | ||
|
|
a8eb0bf44f | ||
|
|
35fdf561be | ||
|
|
081956742c | ||
|
|
8528fd89d2 | ||
|
|
6d00ca1c71 | ||
|
|
4a7782d5c9 | ||
|
|
fb57ec41df | ||
|
|
4694dcfe16 | ||
|
|
02db8aa3a0 | ||
|
|
9592b5e31e | ||
|
|
cea98e0c12 | ||
|
|
6eb60260b1 | ||
|
|
60d415bc5e | ||
|
|
f78d169d71 | ||
|
|
191b625a27 | ||
|
|
a3cb5a6b64 | ||
|
|
7bb99ca3cf | ||
|
|
d736739e8f | ||
|
|
7917d45396 | ||
|
|
bc0152974f | ||
|
|
4d34b3495d | ||
|
|
dbd5f8b9a5 | ||
|
|
00d1f8eea1 | ||
|
|
a1ddc89da6 | ||
|
|
9042f9a813 | ||
|
|
bf1eb0912c | ||
|
|
6f11aa8383 | ||
|
|
81d29e4126 | ||
|
|
c11a52d888 | ||
|
|
e52293482e | ||
|
|
6cb47f17fc | ||
|
|
d3b2677775 | ||
|
|
14aae9c05c | ||
|
|
be50e45a74 | ||
|
|
e4ebbf4f07 | ||
|
|
e7fa7fce25 | ||
|
|
f38e6a14f2 | ||
|
|
05a2a70ca2 | ||
|
|
e202efdf8a | ||
|
|
5325c2ab3e | ||
|
|
9e8fa3caee | ||
|
|
e677dda07c | ||
|
|
a434d9c0cc | ||
|
|
82b2e224a2 | ||
|
|
40afadfb01 | ||
|
|
a29432f0cd | ||
|
|
e0a573a2ce | ||
|
|
e9a5bde9a0 | ||
|
|
61ed5b972c | ||
|
|
37254c4f5d | ||
|
|
098c7d27fe | ||
|
|
3d3b403359 | ||
|
|
25b0d7538e | ||
|
|
a3b2ea599d | ||
|
|
573414f728 | ||
|
|
aa273a2718 | ||
|
|
6abb0950c6 | ||
|
|
e35a350119 | ||
|
|
e5a9831a56 | ||
|
|
0d3ffa691e | ||
|
|
5ad45552b3 | ||
|
|
dc313f27bb | ||
|
|
10f800ab46 | ||
|
|
7cad926401 | ||
|
|
3487460f00 | ||
|
|
82236a3703 | ||
|
|
72314d26ae | ||
|
|
cc75d47926 | ||
|
|
8bf4cc72b6 | ||
|
|
ad941f5a21 | ||
|
|
0aeec0390b | ||
|
|
fef6625496 | ||
|
|
775c3056b6 | ||
|
|
ccf4f170de | ||
|
|
90e7da16a0 | ||
|
|
ad75ec8b5b | ||
|
|
57fcc21a86 | ||
|
|
6855baa0c5 | ||
|
|
07b4427865 | ||
|
|
a8deb6648b | ||
|
|
20a6584d2d | ||
|
|
155e211dd0 | ||
|
|
81923f88ba | ||
|
|
17e53b931c | ||
|
|
9719983f2d | ||
|
|
5706fe18c2 | ||
|
|
71965cbef2 | ||
|
|
0128b86d30 | ||
|
|
0370ba7b0a | ||
|
|
c986218c3a | ||
|
|
0c8b1eb577 | ||
|
|
cfa3f55221 | ||
|
|
f9f6918148 | ||
|
|
b6ded7119e | ||
|
|
65d083338d | ||
|
|
2a61b9f000 | ||
|
|
cfea28216f | ||
|
|
19257d91bf | ||
|
|
fe180f18ff | ||
|
|
1486fd64cc | ||
|
|
504c3d650f | ||
|
|
be33247235 | ||
|
|
a057ed5cfe | ||
|
|
9b7208f4b4 | ||
|
|
b358483ef2 | ||
|
|
37ced4c903 | ||
|
|
b93ad3d0e8 | ||
|
|
c0c4526283 | ||
|
|
04eaa1943f | ||
|
|
c95af71da5 | ||
|
|
14c4a33cd9 | ||
|
|
30d2ea03b0 | ||
|
|
1356ed72cd | ||
|
|
481fac7c84 | ||
|
|
0a52e37648 | ||
|
|
44992df257 | ||
|
|
2efffe77dc | ||
|
|
c5a4eda694 | ||
|
|
3ec47e732b | ||
|
|
c588fcf4bc | ||
|
|
8aa527434c | ||
|
|
7d024a6b68 | ||
|
|
d8206d1931 | ||
|
|
771b950feb | ||
|
|
feed07227b | ||
|
|
0cd5f2a61f | ||
|
|
e56323a4dd | ||
|
|
204688e803 | ||
|
|
9d5ecdbf41 | ||
|
|
1138d0c321 | ||
|
|
ed7231947c | ||
|
|
bdca1614d5 | ||
|
|
dabf66e676 | ||
|
|
08b0861b96 | ||
|
|
01a3461bef | ||
|
|
288f1293ef | ||
|
|
0c46058a43 | ||
|
|
c1410af368 | ||
|
|
24f36ca912 | ||
|
|
84d5bfb35e | ||
|
|
f080a9fac7 | ||
|
|
d420e2f047 | ||
|
|
279231c5dd | ||
|
|
a98b0a47ef | ||
|
|
6bd18e43ba | ||
|
|
5ef65aab8f | ||
|
|
cfbb95605b | ||
|
|
08519cd4f4 | ||
|
|
434c70fd98 | ||
|
|
0466aa8d08 | ||
|
|
072ab191cc | ||
|
|
eec5d350fd | ||
|
|
26c9b9fa27 | ||
|
|
64b839b769 | ||
|
|
cd107e92cb | ||
|
|
6b7085a33e | ||
|
|
1c728df92e | ||
|
|
b28cd6769c | ||
|
|
8394430081 | ||
|
|
d08d0f9f33 | ||
|
|
6a82939adb | ||
|
|
98aa96b8d6 | ||
|
|
3caec1ecc2 | ||
|
|
066458a659 | ||
|
|
2950de86c6 | ||
|
|
7a8711ccac | ||
|
|
7d4ebeecbd | ||
|
|
0e56797792 | ||
|
|
282f48ddd1 | ||
|
|
ef53c972b1 | ||
|
|
eb2b971a52 | ||
|
|
6e3f176b8e | ||
|
|
a4710f9af8 | ||
|
|
fcc0795a40 | ||
|
|
0f8140d26a | ||
|
|
8606e53384 | ||
|
|
fbd2a0127c | ||
|
|
c5a688d70e | ||
|
|
7284e36fbd | ||
|
|
22cdbca82c | ||
|
|
a489e5d5cd | ||
|
|
baf9ea8018 | ||
|
|
abe95b614b | ||
|
|
e7d55df38d | ||
|
|
a72d03f43c | ||
|
|
4bce376fdc | ||
|
|
a865b62efc | ||
|
|
84cebad49d | ||
|
|
931e66e572 | ||
|
|
cdae7e4c8b | ||
|
|
3a52c90de1 | ||
|
|
17e26f8afe | ||
|
|
02d71c6a11 | ||
|
|
4a5401a58e | ||
|
|
28423dd046 | ||
|
|
b165950ca7 | ||
|
|
47157e07b2 | ||
|
|
2526ef10c2 | ||
|
|
f44c8fd130 | ||
|
|
99242b92bc | ||
|
|
ec3b449baa | ||
|
|
2f4c5f504f | ||
|
|
f08e6e9ab5 | ||
|
|
86b4d5439c | ||
|
|
c36b9cc5a6 | ||
|
|
70ce2a2095 | ||
|
|
b0db4dad79 | ||
|
|
776867ea73 | ||
|
|
dad0a09675 | ||
|
|
bca9e2e57a | ||
|
|
369f40bb9f | ||
|
|
65e0bbd958 | ||
|
|
717b7d555c | ||
|
|
753535c3c7 | ||
|
|
9cdd81e9dd | ||
|
|
96126a5b01 | ||
|
|
832a7f9a05 | ||
|
|
7fcf15adf3 | ||
|
|
a1fc626e57 | ||
|
|
9a6fc03332 | ||
|
|
7445f17571 | ||
|
|
67d625c42d | ||
|
|
ddb61decce | ||
|
|
935c1944e2 | ||
|
|
744447b3c0 | ||
|
|
0c4ca3e549 | ||
|
|
c083816c24 | ||
|
|
432761f375 | ||
|
|
de56209951 | ||
|
|
133f5b3b53 | ||
|
|
c63e6c9a2c | ||
|
|
9302369aa5 |
@@ -11,10 +11,11 @@ DB_PASS=
|
|||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
|
|
||||||
# Federation
|
# Federation
|
||||||
# Note: Changing LOCAL_DOMAIN or LOCAL_HTTPS at a later time will cause unwanted side effects.
|
# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation.
|
||||||
# LOCAL_DOMAIN should *NOT* contain the protocol part of the domain e.g https://example.com.
|
# LOCAL_DOMAIN should *NOT* contain the protocol part of the domain e.g https://example.com.
|
||||||
LOCAL_DOMAIN=example.com
|
LOCAL_DOMAIN=example.com
|
||||||
LOCAL_HTTPS=true
|
|
||||||
|
# Changing LOCAL_HTTPS in production is no longer supported. (Mastodon will always serve https:// links)
|
||||||
|
|
||||||
# Use this only if you need to run mastodon on a different domain than the one used for federation.
|
# Use this only if you need to run mastodon on a different domain than the one used for federation.
|
||||||
# You can read more about this option on https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Serving_a_different_domain.md
|
# You can read more about this option on https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Serving_a_different_domain.md
|
||||||
|
|||||||
0
CODEOWNERS → .github/CODEOWNERS
vendored
0
CODEOWNERS → .github/CODEOWNERS
vendored
6
Gemfile
6
Gemfile
@@ -14,12 +14,13 @@ gem 'pg', '~> 0.20'
|
|||||||
gem 'pghero', '~> 1.7'
|
gem 'pghero', '~> 1.7'
|
||||||
gem 'dotenv-rails', '~> 2.2'
|
gem 'dotenv-rails', '~> 2.2'
|
||||||
|
|
||||||
gem 'fog-aws', '~> 1.4', require: false
|
gem 'aws-sdk', '~> 2.10', require: false
|
||||||
gem 'fog-core', '~> 1.45'
|
gem 'fog-core', '~> 1.45'
|
||||||
gem 'fog-local', '~> 0.4', require: false
|
gem 'fog-local', '~> 0.4', require: false
|
||||||
gem 'fog-openstack', '~> 0.1', require: false
|
gem 'fog-openstack', '~> 0.1', require: false
|
||||||
gem 'paperclip', '~> 5.1'
|
gem 'paperclip', '~> 5.1'
|
||||||
gem 'paperclip-av-transcoder', '~> 0.6'
|
gem 'paperclip-av-transcoder', '~> 0.6'
|
||||||
|
gem 'posix-spawn'
|
||||||
|
|
||||||
gem 'active_model_serializers', '~> 0.10'
|
gem 'active_model_serializers', '~> 0.10'
|
||||||
gem 'addressable', '~> 2.5'
|
gem 'addressable', '~> 2.5'
|
||||||
@@ -28,7 +29,7 @@ gem 'browser'
|
|||||||
gem 'charlock_holmes', '~> 0.7.5'
|
gem 'charlock_holmes', '~> 0.7.5'
|
||||||
gem 'iso-639'
|
gem 'iso-639'
|
||||||
gem 'cld3', '~> 3.2.0'
|
gem 'cld3', '~> 3.2.0'
|
||||||
gem 'devise', '~> 4.2'
|
gem 'devise', '~> 4.3'
|
||||||
gem 'devise-two-factor', '~> 3.0'
|
gem 'devise-two-factor', '~> 3.0'
|
||||||
gem 'doorkeeper', '~> 4.2'
|
gem 'doorkeeper', '~> 4.2'
|
||||||
gem 'fast_blank', '~> 1.0'
|
gem 'fast_blank', '~> 1.0'
|
||||||
@@ -58,6 +59,7 @@ gem 'redis', '~> 3.3', require: ['redis', 'redis/connection/hiredis']
|
|||||||
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
|
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
|
||||||
gem 'rqrcode', '~> 0.10'
|
gem 'rqrcode', '~> 0.10'
|
||||||
gem 'ruby-oembed', '~> 0.12', require: 'oembed'
|
gem 'ruby-oembed', '~> 0.12', require: 'oembed'
|
||||||
|
gem 'ruby-progressbar', '~> 1.4'
|
||||||
gem 'sanitize', '~> 4.4'
|
gem 'sanitize', '~> 4.4'
|
||||||
gem 'sidekiq', '~> 5.0'
|
gem 'sidekiq', '~> 5.0'
|
||||||
gem 'sidekiq-scheduler', '~> 2.1'
|
gem 'sidekiq-scheduler', '~> 2.1'
|
||||||
|
|||||||
30
Gemfile.lock
30
Gemfile.lock
@@ -57,6 +57,14 @@ GEM
|
|||||||
encryptor (~> 3.0.0)
|
encryptor (~> 3.0.0)
|
||||||
av (0.9.0)
|
av (0.9.0)
|
||||||
cocaine (~> 0.5.3)
|
cocaine (~> 0.5.3)
|
||||||
|
aws-sdk (2.10.100)
|
||||||
|
aws-sdk-resources (= 2.10.100)
|
||||||
|
aws-sdk-core (2.10.100)
|
||||||
|
aws-sigv4 (~> 1.0)
|
||||||
|
jmespath (~> 1.0)
|
||||||
|
aws-sdk-resources (2.10.100)
|
||||||
|
aws-sdk-core (= 2.10.100)
|
||||||
|
aws-sigv4 (1.0.2)
|
||||||
bcrypt (3.1.11)
|
bcrypt (3.1.11)
|
||||||
better_errors (2.4.0)
|
better_errors (2.4.0)
|
||||||
coderay (>= 1.0.0)
|
coderay (>= 1.0.0)
|
||||||
@@ -152,11 +160,6 @@ GEM
|
|||||||
i18n (~> 0.5)
|
i18n (~> 0.5)
|
||||||
fast_blank (1.0.0)
|
fast_blank (1.0.0)
|
||||||
ffi (1.9.18)
|
ffi (1.9.18)
|
||||||
fog-aws (1.4.1)
|
|
||||||
fog-core (~> 1.38)
|
|
||||||
fog-json (~> 1.0)
|
|
||||||
fog-xml (~> 0.1)
|
|
||||||
ipaddress (~> 0.8)
|
|
||||||
fog-core (1.45.0)
|
fog-core (1.45.0)
|
||||||
builder
|
builder
|
||||||
excon (~> 0.58)
|
excon (~> 0.58)
|
||||||
@@ -170,9 +173,6 @@ GEM
|
|||||||
fog-core (>= 1.40)
|
fog-core (>= 1.40)
|
||||||
fog-json (>= 1.0)
|
fog-json (>= 1.0)
|
||||||
ipaddress (>= 0.8)
|
ipaddress (>= 0.8)
|
||||||
fog-xml (0.1.3)
|
|
||||||
fog-core
|
|
||||||
nokogiri (>= 1.5.11, < 2.0.0)
|
|
||||||
formatador (0.2.5)
|
formatador (0.2.5)
|
||||||
fuubar (2.2.0)
|
fuubar (2.2.0)
|
||||||
rspec-core (~> 3.0)
|
rspec-core (~> 3.0)
|
||||||
@@ -228,6 +228,7 @@ GEM
|
|||||||
idn-ruby (0.1.0)
|
idn-ruby (0.1.0)
|
||||||
ipaddress (0.8.3)
|
ipaddress (0.8.3)
|
||||||
iso-639 (0.2.8)
|
iso-639 (0.2.8)
|
||||||
|
jmespath (1.3.1)
|
||||||
json (2.1.0)
|
json (2.1.0)
|
||||||
json-ld (2.1.7)
|
json-ld (2.1.7)
|
||||||
multi_json (~> 1.12)
|
multi_json (~> 1.12)
|
||||||
@@ -298,13 +299,11 @@ GEM
|
|||||||
sidekiq (>= 3.5.0)
|
sidekiq (>= 3.5.0)
|
||||||
statsd-ruby (~> 1.2.0)
|
statsd-ruby (~> 1.2.0)
|
||||||
oj (3.3.9)
|
oj (3.3.9)
|
||||||
openssl (2.0.6)
|
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
ostatus2 (2.0.1)
|
ostatus2 (2.0.2)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
http (~> 2.0)
|
http (~> 2.0)
|
||||||
nokogiri (~> 1.6)
|
nokogiri (~> 1.6)
|
||||||
openssl (~> 2.0)
|
|
||||||
ox (2.8.2)
|
ox (2.8.2)
|
||||||
paperclip (5.1.0)
|
paperclip (5.1.0)
|
||||||
activemodel (>= 4.2.0)
|
activemodel (>= 4.2.0)
|
||||||
@@ -324,6 +323,7 @@ GEM
|
|||||||
pghero (1.7.0)
|
pghero (1.7.0)
|
||||||
activerecord
|
activerecord
|
||||||
pkg-config (1.2.8)
|
pkg-config (1.2.8)
|
||||||
|
posix-spawn (0.3.13)
|
||||||
powerpack (0.1.1)
|
powerpack (0.1.1)
|
||||||
pry (0.11.3)
|
pry (0.11.3)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
@@ -544,6 +544,7 @@ DEPENDENCIES
|
|||||||
active_record_query_trace (~> 1.5)
|
active_record_query_trace (~> 1.5)
|
||||||
addressable (~> 2.5)
|
addressable (~> 2.5)
|
||||||
annotate (~> 2.7)
|
annotate (~> 2.7)
|
||||||
|
aws-sdk (~> 2.10)
|
||||||
better_errors (~> 2.4)
|
better_errors (~> 2.4)
|
||||||
binding_of_caller (~> 0.7)
|
binding_of_caller (~> 0.7)
|
||||||
bootsnap
|
bootsnap
|
||||||
@@ -559,14 +560,13 @@ DEPENDENCIES
|
|||||||
charlock_holmes (~> 0.7.5)
|
charlock_holmes (~> 0.7.5)
|
||||||
cld3 (~> 3.2.0)
|
cld3 (~> 3.2.0)
|
||||||
climate_control (~> 0.2)
|
climate_control (~> 0.2)
|
||||||
devise (~> 4.2)
|
devise (~> 4.3)
|
||||||
devise-two-factor (~> 3.0)
|
devise-two-factor (~> 3.0)
|
||||||
doorkeeper (~> 4.2)
|
doorkeeper (~> 4.2)
|
||||||
dotenv-rails (~> 2.2)
|
dotenv-rails (~> 2.2)
|
||||||
fabrication (~> 2.18)
|
fabrication (~> 2.18)
|
||||||
faker (~> 1.7)
|
faker (~> 1.7)
|
||||||
fast_blank (~> 1.0)
|
fast_blank (~> 1.0)
|
||||||
fog-aws (~> 1.4)
|
|
||||||
fog-core (~> 1.45)
|
fog-core (~> 1.45)
|
||||||
fog-local (~> 0.4)
|
fog-local (~> 0.4)
|
||||||
fog-openstack (~> 0.1)
|
fog-openstack (~> 0.1)
|
||||||
@@ -601,6 +601,7 @@ DEPENDENCIES
|
|||||||
pg (~> 0.20)
|
pg (~> 0.20)
|
||||||
pghero (~> 1.7)
|
pghero (~> 1.7)
|
||||||
pkg-config (~> 1.2)
|
pkg-config (~> 1.2)
|
||||||
|
posix-spawn
|
||||||
pry-rails (~> 0.3)
|
pry-rails (~> 0.3)
|
||||||
puma (~> 3.10)
|
puma (~> 3.10)
|
||||||
pundit (~> 1.1)
|
pundit (~> 1.1)
|
||||||
@@ -620,6 +621,7 @@ DEPENDENCIES
|
|||||||
rspec-sidekiq (~> 3.0)
|
rspec-sidekiq (~> 3.0)
|
||||||
rubocop
|
rubocop
|
||||||
ruby-oembed (~> 0.12)
|
ruby-oembed (~> 0.12)
|
||||||
|
ruby-progressbar (~> 1.4)
|
||||||
sanitize (~> 4.4)
|
sanitize (~> 4.4)
|
||||||
scss_lint (~> 0.55)
|
scss_lint (~> 0.55)
|
||||||
sidekiq (~> 5.0)
|
sidekiq (~> 5.0)
|
||||||
@@ -642,4 +644,4 @@ RUBY VERSION
|
|||||||
ruby 2.4.2p198
|
ruby 2.4.2p198
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.0
|
1.16.1
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
class AccountsController < ApplicationController
|
class AccountsController < ApplicationController
|
||||||
include AccountControllerConcern
|
include AccountControllerConcern
|
||||||
include SignatureVerification
|
|
||||||
|
before_action :set_cache_headers
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -27,10 +28,11 @@ class AccountsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
render json: @account,
|
skip_session!
|
||||||
serializer: ActivityPub::ActorSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
render_cached_json(['activitypub', 'actor', @account.cache_key], content_type: 'application/activity+json') do
|
||||||
content_type: 'application/activity+json'
|
ActiveModelSerializers::SerializableResource.new(@account, serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -49,7 +51,7 @@ class AccountsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def default_statuses
|
def default_statuses
|
||||||
@account.statuses.where(visibility: [:public, :unlisted])
|
@account.statuses.not_local_only.where(visibility: [:public, :unlisted])
|
||||||
end
|
end
|
||||||
|
|
||||||
def only_media_scope
|
def only_media_scope
|
||||||
|
|||||||
22
app/controllers/activitypub/follows_controller.rb
Normal file
22
app/controllers/activitypub/follows_controller.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class ActivityPub::FollowsController < Api::BaseController
|
||||||
|
include SignatureVerification
|
||||||
|
|
||||||
|
def show
|
||||||
|
render json: follow_request,
|
||||||
|
serializer: ActivityPub::FollowSerializer,
|
||||||
|
adapter: ActivityPub::Adapter,
|
||||||
|
content_type: 'application/activity+json'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def follow_request
|
||||||
|
FollowRequest.includes(:account).references(:account).find_by!(
|
||||||
|
id: params.require(:id),
|
||||||
|
accounts: { domain: nil, username: params.require(:account_username) },
|
||||||
|
target_account: signed_request_account
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -89,7 +89,8 @@ module Admin
|
|||||||
:username,
|
:username,
|
||||||
:display_name,
|
:display_name,
|
||||||
:email,
|
:email,
|
||||||
:ip
|
:ip,
|
||||||
|
:staff
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
module Admin
|
module Admin
|
||||||
class CustomEmojisController < BaseController
|
class CustomEmojisController < BaseController
|
||||||
before_action :set_custom_emoji, except: [:index, :new, :create]
|
before_action :set_custom_emoji, except: [:index, :new, :create]
|
||||||
|
before_action :set_filter_params
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :custom_emoji, :index?
|
authorize :custom_emoji, :index?
|
||||||
@@ -32,23 +33,26 @@ module Admin
|
|||||||
|
|
||||||
if @custom_emoji.update(resource_params)
|
if @custom_emoji.update(resource_params)
|
||||||
log_action :update, @custom_emoji
|
log_action :update, @custom_emoji
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.updated_msg')
|
flash[:notice] = I18n.t('admin.custom_emojis.updated_msg')
|
||||||
else
|
else
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.update_failed_msg')
|
flash[:alert] = I18n.t('admin.custom_emojis.update_failed_msg')
|
||||||
end
|
end
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
authorize @custom_emoji, :destroy?
|
authorize @custom_emoji, :destroy?
|
||||||
@custom_emoji.destroy!
|
@custom_emoji.destroy!
|
||||||
log_action :destroy, @custom_emoji
|
log_action :destroy, @custom_emoji
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.destroyed_msg')
|
flash[:notice] = I18n.t('admin.custom_emojis.destroyed_msg')
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy
|
def copy
|
||||||
authorize @custom_emoji, :copy?
|
authorize @custom_emoji, :copy?
|
||||||
|
|
||||||
emoji = CustomEmoji.find_or_initialize_by(domain: nil, shortcode: @custom_emoji.shortcode)
|
emoji = CustomEmoji.find_or_initialize_by(domain: nil,
|
||||||
|
shortcode: @custom_emoji.shortcode)
|
||||||
emoji.image = @custom_emoji.image
|
emoji.image = @custom_emoji.image
|
||||||
|
|
||||||
if emoji.save
|
if emoji.save
|
||||||
@@ -58,21 +62,23 @@ module Admin
|
|||||||
flash[:alert] = I18n.t('admin.custom_emojis.copy_failed_msg')
|
flash[:alert] = I18n.t('admin.custom_emojis.copy_failed_msg')
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to admin_custom_emojis_path(page: params[:page])
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable
|
def enable
|
||||||
authorize @custom_emoji, :enable?
|
authorize @custom_emoji, :enable?
|
||||||
@custom_emoji.update!(disabled: false)
|
@custom_emoji.update!(disabled: false)
|
||||||
log_action :enable, @custom_emoji
|
log_action :enable, @custom_emoji
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.enabled_msg')
|
flash[:notice] = I18n.t('admin.custom_emojis.enabled_msg')
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable
|
def disable
|
||||||
authorize @custom_emoji, :disable?
|
authorize @custom_emoji, :disable?
|
||||||
@custom_emoji.update!(disabled: true)
|
@custom_emoji.update!(disabled: true)
|
||||||
log_action :disable, @custom_emoji
|
log_action :disable, @custom_emoji
|
||||||
redirect_to admin_custom_emojis_path, notice: I18n.t('admin.custom_emojis.disabled_msg')
|
flash[:notice] = I18n.t('admin.custom_emojis.disabled_msg')
|
||||||
|
redirect_to admin_custom_emojis_path(page: params[:page], **@filter_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -81,6 +87,10 @@ module Admin
|
|||||||
@custom_emoji = CustomEmoji.find(params[:id])
|
@custom_emoji = CustomEmoji.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_filter_params
|
||||||
|
@filter_params = filter_params.to_hash.symbolize_keys
|
||||||
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker)
|
params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker)
|
||||||
end
|
end
|
||||||
@@ -92,7 +102,9 @@ module Admin
|
|||||||
def filter_params
|
def filter_params
|
||||||
params.permit(
|
params.permit(
|
||||||
:local,
|
:local,
|
||||||
:remote
|
:remote,
|
||||||
|
:by_domain,
|
||||||
|
:shortcode
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ module Admin
|
|||||||
bootstrap_timeline_accounts
|
bootstrap_timeline_accounts
|
||||||
thumbnail
|
thumbnail
|
||||||
min_invite_role
|
min_invite_role
|
||||||
|
activity_api_enabled
|
||||||
|
peers_api_enabled
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
BOOLEAN_SETTINGS = %w(
|
BOOLEAN_SETTINGS = %w(
|
||||||
@@ -24,6 +26,8 @@ module Admin
|
|||||||
open_deletion
|
open_deletion
|
||||||
timeline_preview
|
timeline_preview
|
||||||
show_staff_badge
|
show_staff_badge
|
||||||
|
activity_api_enabled
|
||||||
|
peers_api_enabled
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
UPLOAD_SETTINGS = %w(
|
UPLOAD_SETTINGS = %w(
|
||||||
|
|||||||
@@ -72,19 +72,4 @@ class Api::BaseController < ApplicationController
|
|||||||
def render_empty
|
def render_empty
|
||||||
render json: {}, status: 200
|
render json: {}, status: 200
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_maps(statuses) # rubocop:disable Style/AccessorMethodName
|
|
||||||
if current_account.nil?
|
|
||||||
@reblogs_map = {}
|
|
||||||
@favourites_map = {}
|
|
||||||
@mutes_map = {}
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
status_ids = statuses.compact.flat_map { |s| [s.id, s.reblog_of_id] }.uniq
|
|
||||||
conversation_ids = statuses.compact.map(&:conversation_id).compact.uniq
|
|
||||||
@reblogs_map = Status.reblogs_map(status_ids, current_account)
|
|
||||||
@favourites_map = Status.favourites_map(status_ids, current_account)
|
|
||||||
@mutes_map = Status.mutes_map(conversation_ids, current_account)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
20
app/controllers/api/v1/accounts/lists_controller.rb
Normal file
20
app/controllers/api/v1/accounts/lists_controller.rb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Accounts::ListsController < Api::BaseController
|
||||||
|
before_action -> { doorkeeper_authorize! :read }
|
||||||
|
before_action :require_user!
|
||||||
|
before_action :set_account
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def index
|
||||||
|
@lists = @account.lists.where(account: current_account)
|
||||||
|
render json: @lists, each_serializer: REST::ListSerializer
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find(params[:account_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
36
app/controllers/api/v1/instances/activity_controller.rb
Normal file
36
app/controllers/api/v1/instances/activity_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Instances::ActivityController < Api::BaseController
|
||||||
|
before_action :require_enabled_api!
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def show
|
||||||
|
render_cached_json('api:v1:instances:activity:show', expires_in: 1.day) { activity }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def activity
|
||||||
|
weeks = []
|
||||||
|
|
||||||
|
12.times do |i|
|
||||||
|
day = i.weeks.ago.to_date
|
||||||
|
week_id = day.cweek
|
||||||
|
week = Date.commercial(day.cwyear, week_id)
|
||||||
|
|
||||||
|
weeks << {
|
||||||
|
week: week.to_time.to_i.to_s,
|
||||||
|
statuses: Redis.current.get("activity:statuses:local:#{week_id}") || '0',
|
||||||
|
logins: Redis.current.pfcount("activity:logins:#{week_id}").to_s,
|
||||||
|
registrations: Redis.current.get("activity:accounts:local:#{week_id}") || '0',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
weeks
|
||||||
|
end
|
||||||
|
|
||||||
|
def require_enabled_api!
|
||||||
|
head 404 unless Setting.activity_api_enabled
|
||||||
|
end
|
||||||
|
end
|
||||||
17
app/controllers/api/v1/instances/peers_controller.rb
Normal file
17
app/controllers/api/v1/instances/peers_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Api::V1::Instances::PeersController < Api::BaseController
|
||||||
|
before_action :require_enabled_api!
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def index
|
||||||
|
render_cached_json('api:v1:instances:peers:index', expires_in: 1.day) { Account.remote.domains }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def require_enabled_api!
|
||||||
|
head 404 unless Setting.peers_api_enabled
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Api::V1::ListsController < Api::BaseController
|
class Api::V1::ListsController < Api::BaseController
|
||||||
LISTS_LIMIT = 50
|
|
||||||
|
|
||||||
before_action -> { doorkeeper_authorize! :read }, only: [:index, :show]
|
before_action -> { doorkeeper_authorize! :read }, only: [:index, :show]
|
||||||
before_action -> { doorkeeper_authorize! :write }, except: [:index, :show]
|
before_action -> { doorkeeper_authorize! :write }, except: [:index, :show]
|
||||||
|
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
before_action :set_list, except: [:index, :create]
|
before_action :set_list, except: [:index, :create]
|
||||||
|
|
||||||
after_action :insert_pagination_headers, only: :index
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@lists = List.where(account: current_account).paginate_by_max_id(limit_param(LISTS_LIMIT), params[:max_id], params[:since_id])
|
@lists = List.where(account: current_account).all
|
||||||
render json: @lists, each_serializer: REST::ListSerializer
|
render json: @lists, each_serializer: REST::ListSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -44,36 +40,4 @@ class Api::V1::ListsController < Api::BaseController
|
|||||||
def list_params
|
def list_params
|
||||||
params.permit(:title)
|
params.permit(:title)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
|
||||||
set_pagination_headers(next_path, prev_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_path
|
|
||||||
if records_continue?
|
|
||||||
api_v1_lists_url pagination_params(max_id: pagination_max_id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def prev_path
|
|
||||||
unless @lists.empty?
|
|
||||||
api_v1_lists_url pagination_params(since_id: pagination_since_id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_max_id
|
|
||||||
@lists.last.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_since_id
|
|
||||||
@lists.first.id
|
|
||||||
end
|
|
||||||
|
|
||||||
def records_continue?
|
|
||||||
@lists.size == limit_param(LISTS_LIMIT)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pagination_params(core_params)
|
|
||||||
params.permit(:limit).merge(core_params)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class Api::Web::PushSubscriptionsController < Api::BaseController
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.deep_merge!(params[:data]) if params[:data]
|
||||||
|
|
||||||
web_subscription = ::Web::PushSubscription.create!(
|
web_subscription = ::Web::PushSubscription.create!(
|
||||||
endpoint: params[:subscription][:endpoint],
|
endpoint: params[:subscription][:endpoint],
|
||||||
key_p256dh: params[:subscription][:keys][:p256dh],
|
key_p256dh: params[:subscription][:keys][:p256dh],
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class ApplicationController < ActionController::Base
|
|||||||
pack: pack_name,
|
pack: pack_name,
|
||||||
preload: nil,
|
preload: nil,
|
||||||
skin: nil,
|
skin: nil,
|
||||||
|
supported_locales: data['locales'],
|
||||||
}
|
}
|
||||||
if data['pack'][pack_name].is_a?(Hash)
|
if data['pack'][pack_name].is_a?(Hash)
|
||||||
pack_data[:common] = nil if data['pack'][pack_name]['use_common'] == false
|
pack_data[:common] = nil if data['pack'][pack_name]['use_common'] == false
|
||||||
@@ -93,6 +94,7 @@ class ApplicationController < ActionController::Base
|
|||||||
pack: nil,
|
pack: nil,
|
||||||
preload: nil,
|
preload: nil,
|
||||||
skin: nil,
|
skin: nil,
|
||||||
|
supported_locales: data['locales'],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -103,15 +105,15 @@ class ApplicationController < ActionController::Base
|
|||||||
if data['fallback'].nil?
|
if data['fallback'].nil?
|
||||||
return nil_pack(data, pack_name, skin)
|
return nil_pack(data, pack_name, skin)
|
||||||
elsif data['fallback'].is_a?(String) && Themes.instance.flavour(data['fallback'])
|
elsif data['fallback'].is_a?(String) && Themes.instance.flavour(data['fallback'])
|
||||||
return resolve_pack(Themes.instance.flavour(data['fallback']), pack_name, skin)
|
return resolve_pack(Themes.instance.flavour(data['fallback']), pack_name)
|
||||||
elsif data['fallback'].is_a?(Array)
|
elsif data['fallback'].is_a?(Array)
|
||||||
data['fallback'].each do |fallback|
|
data['fallback'].each do |fallback|
|
||||||
return resolve_pack(Themes.instance.flavour(fallback), pack_name, skin) if Themes.instance.flavour(fallback)
|
return resolve_pack(Themes.instance.flavour(fallback), pack_name) if Themes.instance.flavour(fallback)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil_pack(data, pack_name, skin)
|
return nil_pack(data, pack_name, skin)
|
||||||
end
|
end
|
||||||
return data.key?('name') && data['name'] != Setting.default_settings['flavour'] ? resolve_pack(Themes.instance.flavour(Setting.default_settings['flavour']), pack_name, skin) : nil_pack(data, pack_name, skin)
|
return data.key?('name') && data['name'] != Setting.default_settings['flavour'] ? resolve_pack(Themes.instance.flavour(Setting.default_settings['flavour']), pack_name) : nil_pack(data, pack_name, skin)
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
@@ -194,4 +196,26 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_cached_json(cache_key, **options)
|
||||||
|
options[:expires_in] ||= 3.minutes
|
||||||
|
options[:public] ||= true
|
||||||
|
cache_key = cache_key.join(':') if cache_key.is_a?(Enumerable)
|
||||||
|
content_type = options.delete(:content_type) || 'application/json'
|
||||||
|
|
||||||
|
data = Rails.cache.fetch(cache_key, { raw: true }.merge(options)) do
|
||||||
|
yield.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
expires_in options[:expires_in], public: options[:public]
|
||||||
|
render json: data, content_type: content_type
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_cache_headers
|
||||||
|
response.headers['Vary'] = 'Accept'
|
||||||
|
end
|
||||||
|
|
||||||
|
def skip_session!
|
||||||
|
request.session_options[:skip] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,14 +2,9 @@
|
|||||||
|
|
||||||
class Auth::ConfirmationsController < Devise::ConfirmationsController
|
class Auth::ConfirmationsController < Devise::ConfirmationsController
|
||||||
layout 'auth'
|
layout 'auth'
|
||||||
|
|
||||||
before_action :set_pack
|
before_action :set_pack
|
||||||
|
|
||||||
def show
|
|
||||||
super do |user|
|
|
||||||
BootstrapTimelineWorker.perform_async(user.account_id) if user.errors.empty?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_pack
|
def set_pack
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
|||||||
new_user_session_path
|
new_user_session_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def after_update_path_for(_resource)
|
||||||
|
edit_user_registration_path
|
||||||
|
end
|
||||||
|
|
||||||
def check_enabled_registrations
|
def check_enabled_registrations
|
||||||
redirect_to root_path if single_user_mode? || !allowed_registrations?
|
redirect_to root_path if single_user_mode? || !allowed_registrations?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ class Auth::SessionsController < Devise::SessionsController
|
|||||||
skip_before_action :require_no_authentication, only: [:create]
|
skip_before_action :require_no_authentication, only: [:create]
|
||||||
skip_before_action :check_suspension, only: [:destroy]
|
skip_before_action :check_suspension, only: [:destroy]
|
||||||
prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create]
|
prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create]
|
||||||
|
prepend_before_action :set_pack
|
||||||
before_action :set_instance_presenter, only: [:new]
|
before_action :set_instance_presenter, only: [:new]
|
||||||
before_action :set_pack
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
super do |resource|
|
super do |resource|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class AuthorizeFollowsController < ApplicationController
|
|||||||
|
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :set_pack
|
before_action :set_pack
|
||||||
|
before_action :set_body_classes
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@account = located_account || render(:error)
|
@account = located_account || render(:error)
|
||||||
@@ -63,4 +64,8 @@ class AuthorizeFollowsController < ApplicationController
|
|||||||
def acct_params
|
def acct_params
|
||||||
params.fetch(:acct, '')
|
params.fetch(:acct, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_body_classes
|
||||||
|
@body_classes = 'modal-layout'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ module RateLimitHeaders
|
|||||||
end
|
end
|
||||||
|
|
||||||
def api_throttle_data
|
def api_throttle_data
|
||||||
request.env['rack.attack.throttle_data']['api']
|
most_limited_type, = request.env['rack.attack.throttle_data'].min_by { |_, v| v[:limit] }
|
||||||
|
request.env['rack.attack.throttle_data'][most_limited_type]
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_time
|
def request_time
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ module UserTrackingConcern
|
|||||||
|
|
||||||
# Mark as signed-in today
|
# Mark as signed-in today
|
||||||
current_user.update_tracked_fields!(request)
|
current_user.update_tracked_fields!(request)
|
||||||
|
ActivityTracker.record('activity:logins', current_user.id)
|
||||||
|
|
||||||
# Regenerate feed if needed
|
# Regenerate feed if needed
|
||||||
regenerate_feed! if user_needs_feed_update?
|
regenerate_feed! if user_needs_feed_update?
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
class EmojisController < ApplicationController
|
class EmojisController < ApplicationController
|
||||||
before_action :set_emoji
|
before_action :set_emoji
|
||||||
|
before_action :set_cache_headers
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
render json: @emoji,
|
skip_session!
|
||||||
serializer: ActivityPub::EmojiSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
render_cached_json(['activitypub', 'emoji', @emoji.cache_key], content_type: 'application/activity+json') do
|
||||||
content_type: 'application/activity+json'
|
ActiveModelSerializers::SerializableResource.new(@emoji, serializer: ActivityPub::EmojiSerializer, adapter: ActivityPub::Adapter)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
|
|||||||
|
|
||||||
before_action :store_current_location
|
before_action :store_current_location
|
||||||
before_action :authenticate_resource_owner!
|
before_action :authenticate_resource_owner!
|
||||||
|
before_action :set_pack
|
||||||
|
|
||||||
include Localized
|
include Localized
|
||||||
|
|
||||||
@@ -13,4 +14,8 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
|
|||||||
def store_current_location
|
def store_current_location
|
||||||
store_location_for(:user, request.url)
|
store_location_for(:user, request.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_pack
|
||||||
|
use_pack 'auth'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
|
|||||||
|
|
||||||
before_action :store_current_location
|
before_action :store_current_location
|
||||||
before_action :authenticate_resource_owner!
|
before_action :authenticate_resource_owner!
|
||||||
|
before_action :set_pack
|
||||||
|
|
||||||
include Localized
|
include Localized
|
||||||
|
|
||||||
@@ -13,4 +14,8 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
|
|||||||
def store_current_location
|
def store_current_location
|
||||||
store_location_for(:user, request.url)
|
store_location_for(:user, request.url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_pack
|
||||||
|
use_pack 'settings'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,4 +43,8 @@ class RemoteFollowController < ApplicationController
|
|||||||
def suspended_account?
|
def suspended_account?
|
||||||
@account.suspended?
|
@account.suspended?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_body_classes
|
||||||
|
@body_classes = 'modal-layout'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
35
app/controllers/settings/flavours_controller.rb
Normal file
35
app/controllers/settings/flavours_controller.rb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Settings::FlavoursController < Settings::BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
redirect_to action: 'show', flavour: current_flavour
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
unless Themes.instance.flavours.include?(params[:flavour]) or params[:flavour] == current_flavour
|
||||||
|
redirect_to action: 'show', flavour: current_flavour
|
||||||
|
end
|
||||||
|
|
||||||
|
@listing = Themes.instance.flavours
|
||||||
|
@selected = params[:flavour]
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
user_settings.update(user_settings_params(params[:flavour]).to_h)
|
||||||
|
redirect_to action: 'show', flavour: params[:flavour]
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def user_settings
|
||||||
|
UserSettingsDecorator.new(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_settings_params(flavour)
|
||||||
|
params.require(:user).merge({ setting_flavour: flavour }).permit(
|
||||||
|
:setting_flavour,
|
||||||
|
:setting_skin
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -28,6 +28,7 @@ class Settings::MigrationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def migration_account_changed?
|
def migration_account_changed?
|
||||||
current_account.moved_to_account_id != @migration.account&.id
|
current_account.moved_to_account_id != @migration.account&.id &&
|
||||||
|
current_account.id != @migration.account&.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,13 +33,12 @@ class Settings::PreferencesController < Settings::BaseController
|
|||||||
:setting_default_sensitive,
|
:setting_default_sensitive,
|
||||||
:setting_unfollow_modal,
|
:setting_unfollow_modal,
|
||||||
:setting_boost_modal,
|
:setting_boost_modal,
|
||||||
|
:setting_favourite_modal,
|
||||||
:setting_delete_modal,
|
:setting_delete_modal,
|
||||||
:setting_auto_play_gif,
|
:setting_auto_play_gif,
|
||||||
:setting_reduce_motion,
|
:setting_reduce_motion,
|
||||||
:setting_system_font_ui,
|
:setting_system_font_ui,
|
||||||
:setting_noindex,
|
:setting_noindex,
|
||||||
:setting_flavour,
|
|
||||||
:setting_skin,
|
|
||||||
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)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
module Settings
|
module Settings
|
||||||
module TwoFactorAuthentication
|
module TwoFactorAuthentication
|
||||||
class ConfirmationsController < ApplicationController
|
class ConfirmationsController < BaseController
|
||||||
layout 'admin'
|
|
||||||
|
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
prepare_two_factor_form
|
prepare_two_factor_form
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
module Settings
|
module Settings
|
||||||
module TwoFactorAuthentication
|
module TwoFactorAuthentication
|
||||||
class RecoveryCodesController < ApplicationController
|
class RecoveryCodesController < BaseController
|
||||||
layout 'admin'
|
|
||||||
|
|
||||||
before_action :authenticate_user!
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@recovery_codes = current_user.generate_otp_backup_codes!
|
@recovery_codes = current_user.generate_otp_backup_codes!
|
||||||
current_user.save!
|
current_user.save!
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ class SharesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_body_classes
|
def set_body_classes
|
||||||
@body_classes = 'compose-standalone'
|
@body_classes = 'modal-layout compose-standalone'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class StatusesController < ApplicationController
|
|||||||
before_action :set_link_headers
|
before_action :set_link_headers
|
||||||
before_action :check_account_suspension
|
before_action :check_account_suspension
|
||||||
before_action :redirect_to_original, only: [:show]
|
before_action :redirect_to_original, only: [:show]
|
||||||
|
before_action :set_cache_headers
|
||||||
|
|
||||||
def show
|
def show
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -22,19 +23,21 @@ class StatusesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
render json: @status,
|
skip_session! unless @stream_entry.hidden?
|
||||||
serializer: ActivityPub::NoteSerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
render_cached_json(['activitypub', 'note', @status.cache_key], content_type: 'application/activity+json', public: !@stream_entry.hidden?) do
|
||||||
content_type: 'application/activity+json'
|
ActiveModelSerializers::SerializableResource.new(@status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def activity
|
def activity
|
||||||
render json: @status,
|
skip_session!
|
||||||
serializer: ActivityPub::ActivitySerializer,
|
|
||||||
adapter: ActivityPub::Adapter,
|
render_cached_json(['activitypub', 'activity', @status.cache_key], content_type: 'application/activity+json', public: !@stream_entry.hidden?) do
|
||||||
content_type: 'application/activity+json'
|
ActiveModelSerializers::SerializableResource.new(@status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def embed
|
def embed
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module WellKnown
|
module WellKnown
|
||||||
class HostMetaController < ApplicationController
|
class HostMetaController < ActionController::Base
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
|
before_action { response.headers['Vary'] = 'Accept' }
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@webfinger_template = "#{webfinger_url}?resource={uri}"
|
@webfinger_template = "#{webfinger_url}?resource={uri}"
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.xml { render content_type: 'application/xrd+xml' }
|
format.xml { render content_type: 'application/xrd+xml' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expires_in(3.days, public: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module WellKnown
|
module WellKnown
|
||||||
class WebfingerController < ApplicationController
|
class WebfingerController < ActionController::Base
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
|
before_action { response.headers['Vary'] = 'Accept' }
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@account = Account.find_local!(username_from_resource)
|
@account = Account.find_local!(username_from_resource)
|
||||||
|
|
||||||
@@ -16,6 +18,8 @@ module WellKnown
|
|||||||
render content_type: 'application/xrd+xml'
|
render content_type: 'application/xrd+xml'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expires_in(3.days, public: true)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
head 404
|
head 404
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ module Admin::ActionLogsHelper
|
|||||||
link_to attributes['domain'], "https://#{attributes['domain']}"
|
link_to attributes['domain'], "https://#{attributes['domain']}"
|
||||||
when 'Status'
|
when 'Status'
|
||||||
tmp_status = Status.new(attributes)
|
tmp_status = Status.new(attributes)
|
||||||
link_to tmp_status.account.acct, TagManager.instance.url_for(tmp_status)
|
link_to tmp_status.account&.acct || "##{tmp_status.account_id}", TagManager.instance.url_for(tmp_status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Admin::FilterHelper
|
module Admin::FilterHelper
|
||||||
ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip).freeze
|
ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip staff).freeze
|
||||||
REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
|
REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
|
||||||
INVITE_FILTER = %i(available expired).freeze
|
INVITE_FILTER = %i(available expired).freeze
|
||||||
|
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
|
||||||
|
|
||||||
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER
|
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS
|
||||||
|
|
||||||
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
def filter_link_to(text, link_to_params, link_class_params = link_to_params)
|
||||||
new_url = filtered_url_for(link_to_params)
|
new_url = filtered_url_for(link_to_params)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module RoutingHelper
|
|||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
include ActionView::Helpers::AssetTagHelper
|
include ActionView::Helpers::AssetTagHelper
|
||||||
|
include Webpacker::Helper
|
||||||
|
|
||||||
included do
|
included do
|
||||||
def default_url_options
|
def default_url_options
|
||||||
@@ -17,6 +18,10 @@ module RoutingHelper
|
|||||||
URI.join(root_url, source).to_s
|
URI.join(root_url, source).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def full_pack_url(source, **options)
|
||||||
|
full_asset_url(asset_pack_path(source, options))
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def use_storage?
|
def use_storage?
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module SettingsHelper
|
|||||||
eo: 'Esperanto',
|
eo: 'Esperanto',
|
||||||
es: 'Español',
|
es: 'Español',
|
||||||
fa: 'فارسی',
|
fa: 'فارسی',
|
||||||
|
gl: 'Galego',
|
||||||
fi: 'Suomi',
|
fi: 'Suomi',
|
||||||
fr: 'Français',
|
fr: 'Français',
|
||||||
he: 'עברית',
|
he: 'עברית',
|
||||||
@@ -27,6 +28,9 @@ module SettingsHelper
|
|||||||
pt: 'Português',
|
pt: 'Português',
|
||||||
'pt-BR': 'Português do Brasil',
|
'pt-BR': 'Português do Brasil',
|
||||||
ru: 'Русский',
|
ru: 'Русский',
|
||||||
|
sk: 'Slovensky',
|
||||||
|
sr: 'Српски',
|
||||||
|
'sr-Latn': 'Srpski (latinica)',
|
||||||
sv: 'Svenska',
|
sv: 'Svenska',
|
||||||
th: 'ภาษาไทย',
|
th: 'ภาษาไทย',
|
||||||
tr: 'Türkçe',
|
tr: 'Türkçe',
|
||||||
|
|||||||
@@ -37,7 +37,3 @@ delegate(document, '#account_header', 'change', ({ target }) => {
|
|||||||
|
|
||||||
header.style.backgroundImage = `url(${url})`;
|
header.style.backgroundImage = `url(${url})`;
|
||||||
});
|
});
|
||||||
|
|
||||||
delegate(document, '#user_setting_flavour, #user_setting_skin', 'change', ({ target }) => {
|
|
||||||
target.form.submit();
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
|
|||||||
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
||||||
export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE';
|
export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE';
|
||||||
export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE';
|
export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE';
|
||||||
export const COMPOSE_COMPOSING_CHANGE = 'COMPOSE_COMPOSING_CHANGE';
|
|
||||||
|
|
||||||
export const COMPOSE_EMOJI_INSERT = 'COMPOSE_EMOJI_INSERT';
|
export const COMPOSE_EMOJI_INSERT = 'COMPOSE_EMOJI_INSERT';
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ export function replyCompose(status, router) {
|
|||||||
status: status,
|
status: status,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!getState().getIn(['compose', 'mounted'])) {
|
if (router && !getState().getIn(['compose', 'mounted'])) {
|
||||||
router.push('/statuses/new');
|
router.push('/statuses/new');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -119,6 +118,11 @@ export function submitCompose() {
|
|||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
dispatch(submitComposeSuccess({ ...response.data }));
|
dispatch(submitComposeSuccess({ ...response.data }));
|
||||||
|
|
||||||
|
// If the response has no data then we can't do anything else.
|
||||||
|
if (!response.data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 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 insertOrRefresh = (timelineId, refreshAction) => {
|
||||||
@@ -316,21 +320,14 @@ export function readyComposeSuggestionsAccounts(token, accounts) {
|
|||||||
|
|
||||||
export function selectComposeSuggestion(position, token, suggestion) {
|
export function selectComposeSuggestion(position, token, suggestion) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
let completion, startPosition;
|
const completion = typeof suggestion === 'object' && suggestion.id ? (
|
||||||
|
dispatch(useEmoji(suggestion)),
|
||||||
if (typeof suggestion === 'object' && suggestion.id) {
|
suggestion.native || suggestion.colons
|
||||||
completion = suggestion.native || suggestion.colons;
|
) : '@' + getState().getIn(['accounts', suggestion, 'acct']);
|
||||||
startPosition = position - 1;
|
|
||||||
|
|
||||||
dispatch(useEmoji(suggestion));
|
|
||||||
} else {
|
|
||||||
completion = getState().getIn(['accounts', suggestion, 'acct']);
|
|
||||||
startPosition = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: COMPOSE_SUGGESTION_SELECT,
|
type: COMPOSE_SUGGESTION_SELECT,
|
||||||
position: startPosition,
|
position,
|
||||||
token,
|
token,
|
||||||
completion,
|
completion,
|
||||||
});
|
});
|
||||||
@@ -349,10 +346,11 @@ export function unmountCompose() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function toggleComposeAdvancedOption(option) {
|
export function changeComposeAdvancedOption(option, value) {
|
||||||
return {
|
return {
|
||||||
|
option,
|
||||||
type: COMPOSE_ADVANCED_OPTIONS_CHANGE,
|
type: COMPOSE_ADVANCED_OPTIONS_CHANGE,
|
||||||
option: option,
|
value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,10 +387,3 @@ export function insertEmojiCompose(position, emoji) {
|
|||||||
emoji,
|
emoji,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function changeComposing(value) {
|
|
||||||
return {
|
|
||||||
type: COMPOSE_COMPOSING_CHANGE,
|
|
||||||
value,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
313
app/javascript/flavours/glitch/actions/lists.js
Normal file
313
app/javascript/flavours/glitch/actions/lists.js
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
import api from 'flavours/glitch/util/api';
|
||||||
|
|
||||||
|
export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST';
|
||||||
|
export const LIST_FETCH_SUCCESS = 'LIST_FETCH_SUCCESS';
|
||||||
|
export const LIST_FETCH_FAIL = 'LIST_FETCH_FAIL';
|
||||||
|
|
||||||
|
export const LISTS_FETCH_REQUEST = 'LISTS_FETCH_REQUEST';
|
||||||
|
export const LISTS_FETCH_SUCCESS = 'LISTS_FETCH_SUCCESS';
|
||||||
|
export const LISTS_FETCH_FAIL = 'LISTS_FETCH_FAIL';
|
||||||
|
|
||||||
|
export const LIST_EDITOR_TITLE_CHANGE = 'LIST_EDITOR_TITLE_CHANGE';
|
||||||
|
export const LIST_EDITOR_RESET = 'LIST_EDITOR_RESET';
|
||||||
|
export const LIST_EDITOR_SETUP = 'LIST_EDITOR_SETUP';
|
||||||
|
|
||||||
|
export const LIST_CREATE_REQUEST = 'LIST_CREATE_REQUEST';
|
||||||
|
export const LIST_CREATE_SUCCESS = 'LIST_CREATE_SUCCESS';
|
||||||
|
export const LIST_CREATE_FAIL = 'LIST_CREATE_FAIL';
|
||||||
|
|
||||||
|
export const LIST_UPDATE_REQUEST = 'LIST_UPDATE_REQUEST';
|
||||||
|
export const LIST_UPDATE_SUCCESS = 'LIST_UPDATE_SUCCESS';
|
||||||
|
export const LIST_UPDATE_FAIL = 'LIST_UPDATE_FAIL';
|
||||||
|
|
||||||
|
export const LIST_DELETE_REQUEST = 'LIST_DELETE_REQUEST';
|
||||||
|
export const LIST_DELETE_SUCCESS = 'LIST_DELETE_SUCCESS';
|
||||||
|
export const LIST_DELETE_FAIL = 'LIST_DELETE_FAIL';
|
||||||
|
|
||||||
|
export const LIST_ACCOUNTS_FETCH_REQUEST = 'LIST_ACCOUNTS_FETCH_REQUEST';
|
||||||
|
export const LIST_ACCOUNTS_FETCH_SUCCESS = 'LIST_ACCOUNTS_FETCH_SUCCESS';
|
||||||
|
export const LIST_ACCOUNTS_FETCH_FAIL = 'LIST_ACCOUNTS_FETCH_FAIL';
|
||||||
|
|
||||||
|
export const LIST_EDITOR_SUGGESTIONS_CHANGE = 'LIST_EDITOR_SUGGESTIONS_CHANGE';
|
||||||
|
export const LIST_EDITOR_SUGGESTIONS_READY = 'LIST_EDITOR_SUGGESTIONS_READY';
|
||||||
|
export const LIST_EDITOR_SUGGESTIONS_CLEAR = 'LIST_EDITOR_SUGGESTIONS_CLEAR';
|
||||||
|
|
||||||
|
export const LIST_EDITOR_ADD_REQUEST = 'LIST_EDITOR_ADD_REQUEST';
|
||||||
|
export const LIST_EDITOR_ADD_SUCCESS = 'LIST_EDITOR_ADD_SUCCESS';
|
||||||
|
export const LIST_EDITOR_ADD_FAIL = 'LIST_EDITOR_ADD_FAIL';
|
||||||
|
|
||||||
|
export const LIST_EDITOR_REMOVE_REQUEST = 'LIST_EDITOR_REMOVE_REQUEST';
|
||||||
|
export const LIST_EDITOR_REMOVE_SUCCESS = 'LIST_EDITOR_REMOVE_SUCCESS';
|
||||||
|
export const LIST_EDITOR_REMOVE_FAIL = 'LIST_EDITOR_REMOVE_FAIL';
|
||||||
|
|
||||||
|
export const fetchList = id => (dispatch, getState) => {
|
||||||
|
if (getState().getIn(['lists', id])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(fetchListRequest(id));
|
||||||
|
|
||||||
|
api(getState).get(`/api/v1/lists/${id}`)
|
||||||
|
.then(({ data }) => dispatch(fetchListSuccess(data)))
|
||||||
|
.catch(err => dispatch(fetchListFail(id, err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchListRequest = id => ({
|
||||||
|
type: LIST_FETCH_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListSuccess = list => ({
|
||||||
|
type: LIST_FETCH_SUCCESS,
|
||||||
|
list,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListFail = (id, error) => ({
|
||||||
|
type: LIST_FETCH_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchLists = () => (dispatch, getState) => {
|
||||||
|
dispatch(fetchListsRequest());
|
||||||
|
|
||||||
|
api(getState).get('/api/v1/lists')
|
||||||
|
.then(({ data }) => dispatch(fetchListsSuccess(data)))
|
||||||
|
.catch(err => dispatch(fetchListsFail(err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchListsRequest = () => ({
|
||||||
|
type: LISTS_FETCH_REQUEST,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListsSuccess = lists => ({
|
||||||
|
type: LISTS_FETCH_SUCCESS,
|
||||||
|
lists,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListsFail = error => ({
|
||||||
|
type: LISTS_FETCH_FAIL,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const submitListEditor = shouldReset => (dispatch, getState) => {
|
||||||
|
const listId = getState().getIn(['listEditor', 'listId']);
|
||||||
|
const title = getState().getIn(['listEditor', 'title']);
|
||||||
|
|
||||||
|
if (listId === null) {
|
||||||
|
dispatch(createList(title, shouldReset));
|
||||||
|
} else {
|
||||||
|
dispatch(updateList(listId, title, shouldReset));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setupListEditor = listId => (dispatch, getState) => {
|
||||||
|
dispatch({
|
||||||
|
type: LIST_EDITOR_SETUP,
|
||||||
|
list: getState().getIn(['lists', listId]),
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(fetchListAccounts(listId));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const changeListEditorTitle = value => ({
|
||||||
|
type: LIST_EDITOR_TITLE_CHANGE,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const createList = (title, shouldReset) => (dispatch, getState) => {
|
||||||
|
dispatch(createListRequest());
|
||||||
|
|
||||||
|
api(getState).post('/api/v1/lists', { title }).then(({ data }) => {
|
||||||
|
dispatch(createListSuccess(data));
|
||||||
|
|
||||||
|
if (shouldReset) {
|
||||||
|
dispatch(resetListEditor());
|
||||||
|
}
|
||||||
|
}).catch(err => dispatch(createListFail(err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createListRequest = () => ({
|
||||||
|
type: LIST_CREATE_REQUEST,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const createListSuccess = list => ({
|
||||||
|
type: LIST_CREATE_SUCCESS,
|
||||||
|
list,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const createListFail = error => ({
|
||||||
|
type: LIST_CREATE_FAIL,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const updateList = (id, title, shouldReset) => (dispatch, getState) => {
|
||||||
|
dispatch(updateListRequest(id));
|
||||||
|
|
||||||
|
api(getState).put(`/api/v1/lists/${id}`, { title }).then(({ data }) => {
|
||||||
|
dispatch(updateListSuccess(data));
|
||||||
|
|
||||||
|
if (shouldReset) {
|
||||||
|
dispatch(resetListEditor());
|
||||||
|
}
|
||||||
|
}).catch(err => dispatch(updateListFail(id, err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateListRequest = id => ({
|
||||||
|
type: LIST_UPDATE_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const updateListSuccess = list => ({
|
||||||
|
type: LIST_UPDATE_SUCCESS,
|
||||||
|
list,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const updateListFail = (id, error) => ({
|
||||||
|
type: LIST_UPDATE_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const resetListEditor = () => ({
|
||||||
|
type: LIST_EDITOR_RESET,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const deleteList = id => (dispatch, getState) => {
|
||||||
|
dispatch(deleteListRequest(id));
|
||||||
|
|
||||||
|
api(getState).delete(`/api/v1/lists/${id}`)
|
||||||
|
.then(() => dispatch(deleteListSuccess(id)))
|
||||||
|
.catch(err => dispatch(deleteListFail(id, err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteListRequest = id => ({
|
||||||
|
type: LIST_DELETE_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const deleteListSuccess = id => ({
|
||||||
|
type: LIST_DELETE_SUCCESS,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const deleteListFail = (id, error) => ({
|
||||||
|
type: LIST_DELETE_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListAccounts = listId => (dispatch, getState) => {
|
||||||
|
dispatch(fetchListAccountsRequest(listId));
|
||||||
|
|
||||||
|
api(getState).get(`/api/v1/lists/${listId}/accounts`, { params: { limit: 0 } })
|
||||||
|
.then(({ data }) => dispatch(fetchListAccountsSuccess(listId, data)))
|
||||||
|
.catch(err => dispatch(fetchListAccountsFail(listId, err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchListAccountsRequest = id => ({
|
||||||
|
type: LIST_ACCOUNTS_FETCH_REQUEST,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListAccountsSuccess = (id, accounts, next) => ({
|
||||||
|
type: LIST_ACCOUNTS_FETCH_SUCCESS,
|
||||||
|
id,
|
||||||
|
accounts,
|
||||||
|
next,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListAccountsFail = (id, error) => ({
|
||||||
|
type: LIST_ACCOUNTS_FETCH_FAIL,
|
||||||
|
id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchListSuggestions = q => (dispatch, getState) => {
|
||||||
|
const params = {
|
||||||
|
q,
|
||||||
|
resolve: false,
|
||||||
|
limit: 4,
|
||||||
|
following: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
api(getState).get('/api/v1/accounts/search', { params })
|
||||||
|
.then(({ data }) => dispatch(fetchListSuggestionsReady(q, data)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchListSuggestionsReady = (query, accounts) => ({
|
||||||
|
type: LIST_EDITOR_SUGGESTIONS_READY,
|
||||||
|
query,
|
||||||
|
accounts,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const clearListSuggestions = () => ({
|
||||||
|
type: LIST_EDITOR_SUGGESTIONS_CLEAR,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const changeListSuggestions = value => ({
|
||||||
|
type: LIST_EDITOR_SUGGESTIONS_CHANGE,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const addToListEditor = accountId => (dispatch, getState) => {
|
||||||
|
dispatch(addToList(getState().getIn(['listEditor', 'listId']), accountId));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const addToList = (listId, accountId) => (dispatch, getState) => {
|
||||||
|
dispatch(addToListRequest(listId, accountId));
|
||||||
|
|
||||||
|
api(getState).post(`/api/v1/lists/${listId}/accounts`, { account_ids: [accountId] })
|
||||||
|
.then(() => dispatch(addToListSuccess(listId, accountId)))
|
||||||
|
.catch(err => dispatch(addToListFail(listId, accountId, err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const addToListRequest = (listId, accountId) => ({
|
||||||
|
type: LIST_EDITOR_ADD_REQUEST,
|
||||||
|
listId,
|
||||||
|
accountId,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const addToListSuccess = (listId, accountId) => ({
|
||||||
|
type: LIST_EDITOR_ADD_SUCCESS,
|
||||||
|
listId,
|
||||||
|
accountId,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const addToListFail = (listId, accountId, error) => ({
|
||||||
|
type: LIST_EDITOR_ADD_FAIL,
|
||||||
|
listId,
|
||||||
|
accountId,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const removeFromListEditor = accountId => (dispatch, getState) => {
|
||||||
|
dispatch(removeFromList(getState().getIn(['listEditor', 'listId']), accountId));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const removeFromList = (listId, accountId) => (dispatch, getState) => {
|
||||||
|
dispatch(removeFromListRequest(listId, accountId));
|
||||||
|
|
||||||
|
api(getState).delete(`/api/v1/lists/${listId}/accounts`, { params: { account_ids: [accountId] } })
|
||||||
|
.then(() => dispatch(removeFromListSuccess(listId, accountId)))
|
||||||
|
.catch(err => dispatch(removeFromListFail(listId, accountId, err)));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const removeFromListRequest = (listId, accountId) => ({
|
||||||
|
type: LIST_EDITOR_REMOVE_REQUEST,
|
||||||
|
listId,
|
||||||
|
accountId,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const removeFromListSuccess = (listId, accountId) => ({
|
||||||
|
type: LIST_EDITOR_REMOVE_SUCCESS,
|
||||||
|
listId,
|
||||||
|
accountId,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const removeFromListFail = (listId, accountId, error) => ({
|
||||||
|
type: LIST_EDITOR_REMOVE_FAIL,
|
||||||
|
listId,
|
||||||
|
accountId,
|
||||||
|
error,
|
||||||
|
});
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import {
|
||||||
|
SET_BROWSER_SUPPORT,
|
||||||
|
SET_SUBSCRIPTION,
|
||||||
|
CLEAR_SUBSCRIPTION,
|
||||||
|
SET_ALERTS,
|
||||||
|
setAlerts,
|
||||||
|
} from './setter';
|
||||||
|
import { register, saveSettings } from './registerer';
|
||||||
|
|
||||||
|
export {
|
||||||
|
SET_BROWSER_SUPPORT,
|
||||||
|
SET_SUBSCRIPTION,
|
||||||
|
CLEAR_SUBSCRIPTION,
|
||||||
|
SET_ALERTS,
|
||||||
|
register,
|
||||||
|
};
|
||||||
|
|
||||||
|
export function changeAlerts(key, value) {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch(setAlerts(key, value));
|
||||||
|
dispatch(saveSettings());
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import { pushNotificationsSetting } from 'flavours/glitch/util/settings';
|
||||||
|
import { setBrowserSupport, setSubscription, clearSubscription } from './setter';
|
||||||
|
|
||||||
|
// Taken from https://www.npmjs.com/package/web-push
|
||||||
|
const urlBase64ToUint8Array = (base64String) => {
|
||||||
|
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
||||||
|
const base64 = (base64String + padding)
|
||||||
|
.replace(/\-/g, '+')
|
||||||
|
.replace(/_/g, '/');
|
||||||
|
|
||||||
|
const rawData = window.atob(base64);
|
||||||
|
const outputArray = new Uint8Array(rawData.length);
|
||||||
|
|
||||||
|
for (let i = 0; i < rawData.length; ++i) {
|
||||||
|
outputArray[i] = rawData.charCodeAt(i);
|
||||||
|
}
|
||||||
|
return outputArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getApplicationServerKey = () => document.querySelector('[name="applicationServerKey"]').getAttribute('content');
|
||||||
|
|
||||||
|
const getRegistration = () => navigator.serviceWorker.ready;
|
||||||
|
|
||||||
|
const getPushSubscription = (registration) =>
|
||||||
|
registration.pushManager.getSubscription()
|
||||||
|
.then(subscription => ({ registration, subscription }));
|
||||||
|
|
||||||
|
const subscribe = (registration) =>
|
||||||
|
registration.pushManager.subscribe({
|
||||||
|
userVisibleOnly: true,
|
||||||
|
applicationServerKey: urlBase64ToUint8Array(getApplicationServerKey()),
|
||||||
|
});
|
||||||
|
|
||||||
|
const unsubscribe = ({ registration, subscription }) =>
|
||||||
|
subscription ? subscription.unsubscribe().then(() => registration) : registration;
|
||||||
|
|
||||||
|
const sendSubscriptionToBackend = (subscription, me) => {
|
||||||
|
const params = { subscription };
|
||||||
|
|
||||||
|
if (me) {
|
||||||
|
const data = pushNotificationsSetting.get(me);
|
||||||
|
if (data) {
|
||||||
|
params.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return axios.post('/api/web/push_subscriptions', params).then(response => response.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Last one checks for payload support: https://web-push-book.gauntface.com/chapter-06/01-non-standards-browsers/#no-payload
|
||||||
|
const supportsPushNotifications = ('serviceWorker' in navigator && 'PushManager' in window && 'getKey' in PushSubscription.prototype);
|
||||||
|
|
||||||
|
export function register () {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch(setBrowserSupport(supportsPushNotifications));
|
||||||
|
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 (!getApplicationServerKey()) {
|
||||||
|
console.error('The VAPID public key is not set. You will not be able to receive Web Push Notifications.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getRegistration()
|
||||||
|
.then(getPushSubscription)
|
||||||
|
.then(({ registration, subscription }) => {
|
||||||
|
if (subscription !== null) {
|
||||||
|
// We have a subscription, check if it is still valid
|
||||||
|
const currentServerKey = (new Uint8Array(subscription.options.applicationServerKey)).toString();
|
||||||
|
const subscriptionServerKey = urlBase64ToUint8Array(getApplicationServerKey()).toString();
|
||||||
|
const serverEndpoint = getState().getIn(['push_notifications', 'subscription', 'endpoint']);
|
||||||
|
|
||||||
|
// If the VAPID public key did not change and the endpoint corresponds
|
||||||
|
// to the endpoint saved in the backend, the subscription is valid
|
||||||
|
if (subscriptionServerKey === currentServerKey && subscription.endpoint === serverEndpoint) {
|
||||||
|
return subscription;
|
||||||
|
} else {
|
||||||
|
// Something went wrong, try to subscribe again
|
||||||
|
return unsubscribe({ registration, subscription }).then(subscribe).then(
|
||||||
|
subscription => sendSubscriptionToBackend(subscription, me));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No subscription, try to subscribe
|
||||||
|
return subscribe(registration).then(
|
||||||
|
subscription => sendSubscriptionToBackend(subscription, me));
|
||||||
|
})
|
||||||
|
.then(subscription => {
|
||||||
|
// If we got a PushSubscription (and not a subscription object from the backend)
|
||||||
|
// it means that the backend subscription is valid (and was set during hydration)
|
||||||
|
if (!(subscription instanceof PushSubscription)) {
|
||||||
|
dispatch(setSubscription(subscription));
|
||||||
|
if (me) {
|
||||||
|
pushNotificationsSetting.set(me, { alerts: subscription.alerts });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.code === 20 && error.name === 'AbortError') {
|
||||||
|
console.warn('Your browser supports Web Push Notifications, but does not seem to implement the VAPID protocol.');
|
||||||
|
} else if (error.code === 5 && error.name === 'InvalidCharacterError') {
|
||||||
|
console.error('The VAPID public key seems to be invalid:', getApplicationServerKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear alerts and hide UI settings
|
||||||
|
dispatch(clearSubscription());
|
||||||
|
if (me) {
|
||||||
|
pushNotificationsSetting.remove(me);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
getRegistration()
|
||||||
|
.then(getPushSubscription)
|
||||||
|
.then(unsubscribe);
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn('Your browser does not support Web Push Notifications.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveSettings() {
|
||||||
|
return (_, getState) => {
|
||||||
|
const state = getState().get('push_notifications');
|
||||||
|
const subscription = state.get('subscription');
|
||||||
|
const alerts = state.get('alerts');
|
||||||
|
const data = { alerts };
|
||||||
|
|
||||||
|
axios.put(`/api/web/push_subscriptions/${subscription.get('id')}`, {
|
||||||
|
data,
|
||||||
|
}).then(() => {
|
||||||
|
const me = getState().getIn(['meta', 'me']);
|
||||||
|
if (me) {
|
||||||
|
pushNotificationsSetting.set(me, data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
export const SET_BROWSER_SUPPORT = 'PUSH_NOTIFICATIONS_SET_BROWSER_SUPPORT';
|
export const SET_BROWSER_SUPPORT = 'PUSH_NOTIFICATIONS_SET_BROWSER_SUPPORT';
|
||||||
export const SET_SUBSCRIPTION = 'PUSH_NOTIFICATIONS_SET_SUBSCRIPTION';
|
export const SET_SUBSCRIPTION = 'PUSH_NOTIFICATIONS_SET_SUBSCRIPTION';
|
||||||
export const CLEAR_SUBSCRIPTION = 'PUSH_NOTIFICATIONS_CLEAR_SUBSCRIPTION';
|
export const CLEAR_SUBSCRIPTION = 'PUSH_NOTIFICATIONS_CLEAR_SUBSCRIPTION';
|
||||||
export const ALERTS_CHANGE = 'PUSH_NOTIFICATIONS_ALERTS_CHANGE';
|
export const SET_ALERTS = 'PUSH_NOTIFICATIONS_SET_ALERTS';
|
||||||
|
|
||||||
export function setBrowserSupport (value) {
|
export function setBrowserSupport (value) {
|
||||||
return {
|
return {
|
||||||
@@ -25,28 +23,12 @@ export function clearSubscription () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changeAlerts(key, value) {
|
export function setAlerts (key, value) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ALERTS_CHANGE,
|
type: SET_ALERTS,
|
||||||
key,
|
key,
|
||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatch(saveSettings());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function saveSettings() {
|
|
||||||
return (_, getState) => {
|
|
||||||
const state = getState().get('push_notifications');
|
|
||||||
const subscription = state.get('subscription');
|
|
||||||
const alerts = state.get('alerts');
|
|
||||||
|
|
||||||
axios.put(`/api/web/push_subscriptions/${subscription.get('id')}`, {
|
|
||||||
data: {
|
|
||||||
alerts,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -52,3 +52,4 @@ export const connectMediaStream = () => connectTimelineStream('community', 'publ
|
|||||||
export const connectPublicStream = () => connectTimelineStream('public', 'public');
|
export const connectPublicStream = () => connectTimelineStream('public', 'public');
|
||||||
export const connectHashtagStream = (tag) => connectTimelineStream(`hashtag:${tag}`, `hashtag&tag=${tag}`);
|
export const connectHashtagStream = (tag) => connectTimelineStream(`hashtag:${tag}`, `hashtag&tag=${tag}`);
|
||||||
export const connectDirectStream = () => connectTimelineStream('direct', 'direct');
|
export const connectDirectStream = () => connectTimelineStream('direct', 'direct');
|
||||||
|
export const connectListStream = (id) => connectTimelineStream(`list:${id}`, `list&list=${id}`);
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ export const refreshDirectTimeline = () => refreshTimeline('direct', '/api
|
|||||||
export const refreshAccountTimeline = accountId => refreshTimeline(`account:${accountId}`, `/api/v1/accounts/${accountId}/statuses`);
|
export const refreshAccountTimeline = accountId => refreshTimeline(`account:${accountId}`, `/api/v1/accounts/${accountId}/statuses`);
|
||||||
export const refreshAccountMediaTimeline = accountId => refreshTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { only_media: 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 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) {
|
export function refreshTimelineFail(timeline, error, skipLoading) {
|
||||||
return {
|
return {
|
||||||
@@ -160,6 +161,7 @@ export const expandDirectTimeline = () => expandTimeline('direct', '/api/v
|
|||||||
export const expandAccountTimeline = accountId => expandTimeline(`account:${accountId}`, `/api/v1/accounts/${accountId}/statuses`);
|
export const expandAccountTimeline = accountId => expandTimeline(`account:${accountId}`, `/api/v1/accounts/${accountId}/statuses`);
|
||||||
export const expandAccountMediaTimeline = accountId => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { only_media: true });
|
export const expandAccountMediaTimeline = accountId => expandTimeline(`account:${accountId}:media`, `/api/v1/accounts/${accountId}/statuses`, { only_media: true });
|
||||||
export const expandHashtagTimeline = hashtag => expandTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`);
|
export const expandHashtagTimeline = hashtag => expandTimeline(`hashtag:${hashtag}`, `/api/v1/timelines/tag/${hashtag}`);
|
||||||
|
export const expandListTimeline = id => expandTimeline(`list:${id}`, `/api/v1/timelines/list/${id}`);
|
||||||
|
|
||||||
export function expandTimelineRequest(timeline) {
|
export function expandTimelineRequest(timeline) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ export default class Account extends ImmutablePureComponent {
|
|||||||
onFollow: PropTypes.func.isRequired,
|
onFollow: PropTypes.func.isRequired,
|
||||||
onBlock: PropTypes.func.isRequired,
|
onBlock: PropTypes.func.isRequired,
|
||||||
onMute: PropTypes.func.isRequired,
|
onMute: PropTypes.func.isRequired,
|
||||||
|
onMuteNotifications: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
hidden: PropTypes.bool,
|
hidden: PropTypes.bool,
|
||||||
|
small: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleFollow = () => {
|
handleFollow = () => {
|
||||||
@@ -52,7 +54,12 @@ export default class Account extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { account, intl, hidden } = this.props;
|
const {
|
||||||
|
account,
|
||||||
|
hidden,
|
||||||
|
intl,
|
||||||
|
small,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return <div />;
|
return <div />;
|
||||||
@@ -69,7 +76,7 @@ export default class Account extends ImmutablePureComponent {
|
|||||||
|
|
||||||
let buttons;
|
let buttons;
|
||||||
|
|
||||||
if (account.get('id') !== me && account.get('relationship', null) !== null) {
|
if (account.get('id') !== me && !small && account.get('relationship', null) !== null) {
|
||||||
const following = account.getIn(['relationship', 'following']);
|
const following = account.getIn(['relationship', 'following']);
|
||||||
const requested = account.getIn(['relationship', 'requested']);
|
const requested = account.getIn(['relationship', 'requested']);
|
||||||
const blocking = account.getIn(['relationship', 'blocking']);
|
const blocking = account.getIn(['relationship', 'blocking']);
|
||||||
@@ -81,7 +88,7 @@ export default class Account extends ImmutablePureComponent {
|
|||||||
buttons = <IconButton active icon='unlock-alt' title={intl.formatMessage(messages.unblock, { name: account.get('username') })} onClick={this.handleBlock} />;
|
buttons = <IconButton active icon='unlock-alt' title={intl.formatMessage(messages.unblock, { name: account.get('username') })} onClick={this.handleBlock} />;
|
||||||
} else if (muting) {
|
} else if (muting) {
|
||||||
let hidingNotificationsButton;
|
let hidingNotificationsButton;
|
||||||
if (muting.get('notifications')) {
|
if (account.getIn(['relationship', 'muting_notifications'])) {
|
||||||
hidingNotificationsButton = <IconButton active icon='bell' title={intl.formatMessage(messages.unmute_notifications, { name: account.get('username') })} onClick={this.handleUnmuteNotifications} />;
|
hidingNotificationsButton = <IconButton active icon='bell' title={intl.formatMessage(messages.unmute_notifications, { name: account.get('username') })} onClick={this.handleUnmuteNotifications} />;
|
||||||
} else {
|
} else {
|
||||||
hidingNotificationsButton = <IconButton active icon='bell-slash' title={intl.formatMessage(messages.mute_notifications, { name: account.get('username') })} onClick={this.handleMuteNotifications} />;
|
hidingNotificationsButton = <IconButton active icon='bell-slash' title={intl.formatMessage(messages.mute_notifications, { name: account.get('username') })} onClick={this.handleMuteNotifications} />;
|
||||||
@@ -93,21 +100,39 @@ export default class Account extends ImmutablePureComponent {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
buttons = <IconButton icon={following ? 'user-times' : 'user-plus'} title={intl.formatMessage(following ? messages.unfollow : messages.follow)} onClick={this.handleFollow} active={following ? true : false} />;
|
buttons = <IconButton icon={following ? 'user-times' : 'user-plus'} title={intl.formatMessage(following ? messages.unfollow : messages.follow)} onClick={this.handleFollow} active={following} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return small ? (
|
||||||
|
<Permalink
|
||||||
|
className='account small'
|
||||||
|
href={account.get('url')}
|
||||||
|
to={`/accounts/${account.get('id')}`}
|
||||||
|
>
|
||||||
|
<div className='account__avatar-wrapper'>
|
||||||
|
<Avatar
|
||||||
|
account={account}
|
||||||
|
size={24}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<DisplayName
|
||||||
|
account={account}
|
||||||
|
inline
|
||||||
|
/>
|
||||||
|
</Permalink>
|
||||||
|
) : (
|
||||||
<div className='account'>
|
<div className='account'>
|
||||||
<div className='account__wrapper'>
|
<div className='account__wrapper'>
|
||||||
<Permalink key={account.get('id')} className='account__display-name' href={account.get('url')} to={`/accounts/${account.get('id')}`}>
|
<Permalink key={account.get('id')} className='account__display-name' href={account.get('url')} to={`/accounts/${account.get('id')}`}>
|
||||||
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
|
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
|
||||||
<DisplayName account={account} />
|
<DisplayName account={account} />
|
||||||
</Permalink>
|
</Permalink>
|
||||||
|
{buttons ?
|
||||||
<div className='account__relationship'>
|
<div className='account__relationship'>
|
||||||
{buttons}
|
{buttons}
|
||||||
</div>
|
</div>
|
||||||
|
: null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import unicodeMapping from 'flavours/glitch/util/emoji/emoji_unicode_mapping_light';
|
|
||||||
|
|
||||||
const assetHost = process.env.CDN_HOST || '';
|
|
||||||
|
|
||||||
export default class AutosuggestEmoji extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
emoji: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { emoji } = this.props;
|
|
||||||
let url;
|
|
||||||
|
|
||||||
if (emoji.custom) {
|
|
||||||
url = emoji.imageUrl;
|
|
||||||
} else {
|
|
||||||
const mapping = unicodeMapping[emoji.native] || unicodeMapping[emoji.native.replace(/\uFE0F$/, '')];
|
|
||||||
|
|
||||||
if (!mapping) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
url = `${assetHost}/emoji/${mapping.filename}.svg`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='autosuggest-emoji'>
|
|
||||||
<img
|
|
||||||
className='emojione'
|
|
||||||
src={url}
|
|
||||||
alt={emoji.native || emoji.colons}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{emoji.colons}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,222 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import AutosuggestAccountContainer from 'flavours/glitch/features/compose/containers/autosuggest_account_container';
|
|
||||||
import AutosuggestEmoji from './autosuggest_emoji';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { isRtl } from 'flavours/glitch/util/rtl';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import Textarea from 'react-textarea-autosize';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
const textAtCursorMatchesToken = (str, caretPosition) => {
|
|
||||||
let word;
|
|
||||||
|
|
||||||
let left = str.slice(0, caretPosition).search(/[^\s\u200B]+$/);
|
|
||||||
let right = str.slice(caretPosition).search(/[\s\u200B]/);
|
|
||||||
|
|
||||||
if (right < 0) {
|
|
||||||
word = str.slice(left);
|
|
||||||
} else {
|
|
||||||
word = str.slice(left, right + caretPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!word || word.trim().length < 3 || ['@', ':'].indexOf(word[0]) === -1) {
|
|
||||||
return [null, null];
|
|
||||||
}
|
|
||||||
|
|
||||||
word = word.trim().toLowerCase();
|
|
||||||
|
|
||||||
if (word.length > 0) {
|
|
||||||
return [left + 1, word];
|
|
||||||
} else {
|
|
||||||
return [null, null];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class AutosuggestTextarea extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
value: PropTypes.string,
|
|
||||||
suggestions: ImmutablePropTypes.list,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
placeholder: PropTypes.string,
|
|
||||||
onSuggestionSelected: PropTypes.func.isRequired,
|
|
||||||
onSuggestionsClearRequested: PropTypes.func.isRequired,
|
|
||||||
onSuggestionsFetchRequested: PropTypes.func.isRequired,
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
onKeyUp: PropTypes.func,
|
|
||||||
onKeyDown: PropTypes.func,
|
|
||||||
onPaste: PropTypes.func.isRequired,
|
|
||||||
autoFocus: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
autoFocus: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
suggestionsHidden: false,
|
|
||||||
selectedSuggestion: 0,
|
|
||||||
lastToken: null,
|
|
||||||
tokenStart: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
onChange = (e) => {
|
|
||||||
const [ tokenStart, token ] = textAtCursorMatchesToken(e.target.value, e.target.selectionStart);
|
|
||||||
|
|
||||||
if (token !== null && this.state.lastToken !== token) {
|
|
||||||
this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart });
|
|
||||||
this.props.onSuggestionsFetchRequested(token);
|
|
||||||
} else if (token === null) {
|
|
||||||
this.setState({ lastToken: null });
|
|
||||||
this.props.onSuggestionsClearRequested();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.props.onChange(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
onKeyDown = (e) => {
|
|
||||||
const { suggestions, disabled } = this.props;
|
|
||||||
const { selectedSuggestion, suggestionsHidden } = this.state;
|
|
||||||
|
|
||||||
if (disabled) {
|
|
||||||
e.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(e.key) {
|
|
||||||
case 'Escape':
|
|
||||||
if (!suggestionsHidden) {
|
|
||||||
e.preventDefault();
|
|
||||||
this.setState({ suggestionsHidden: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'ArrowDown':
|
|
||||||
if (suggestions.size > 0 && !suggestionsHidden) {
|
|
||||||
e.preventDefault();
|
|
||||||
this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, suggestions.size - 1) });
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'ArrowUp':
|
|
||||||
if (suggestions.size > 0 && !suggestionsHidden) {
|
|
||||||
e.preventDefault();
|
|
||||||
this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, 0) });
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'Enter':
|
|
||||||
case 'Tab':
|
|
||||||
// Select suggestion
|
|
||||||
if (this.state.lastToken !== null && suggestions.size > 0 && !suggestionsHidden) {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.defaultPrevented || !this.props.onKeyDown) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.props.onKeyDown(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
onKeyUp = e => {
|
|
||||||
if (e.key === 'Escape' && this.state.suggestionsHidden) {
|
|
||||||
document.querySelector('.ui').parentElement.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.props.onKeyUp) {
|
|
||||||
this.props.onKeyUp(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onBlur = () => {
|
|
||||||
this.setState({ suggestionsHidden: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
onSuggestionClick = (e) => {
|
|
||||||
const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index'));
|
|
||||||
e.preventDefault();
|
|
||||||
this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion);
|
|
||||||
this.textarea.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
|
||||||
if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden) {
|
|
||||||
this.setState({ suggestionsHidden: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setTextarea = (c) => {
|
|
||||||
this.textarea = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPaste = (e) => {
|
|
||||||
if (e.clipboardData && e.clipboardData.files.length === 1) {
|
|
||||||
this.props.onPaste(e.clipboardData.files);
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
renderSuggestion = (suggestion, i) => {
|
|
||||||
const { selectedSuggestion } = this.state;
|
|
||||||
let inner, key;
|
|
||||||
|
|
||||||
if (typeof suggestion === 'object') {
|
|
||||||
inner = <AutosuggestEmoji emoji={suggestion} />;
|
|
||||||
key = suggestion.id;
|
|
||||||
} else {
|
|
||||||
inner = <AutosuggestAccountContainer id={suggestion} />;
|
|
||||||
key = suggestion;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div role='button' tabIndex='0' key={key} data-index={i} className={classNames('autosuggest-textarea__suggestions__item', { selected: i === selectedSuggestion })} onMouseDown={this.onSuggestionClick}>
|
|
||||||
{inner}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { value, suggestions, disabled, placeholder, autoFocus } = this.props;
|
|
||||||
const { suggestionsHidden } = this.state;
|
|
||||||
const style = { direction: 'ltr' };
|
|
||||||
|
|
||||||
if (isRtl(value)) {
|
|
||||||
style.direction = 'rtl';
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='autosuggest-textarea'>
|
|
||||||
<label>
|
|
||||||
<span style={{ display: 'none' }}>{placeholder}</span>
|
|
||||||
|
|
||||||
<Textarea
|
|
||||||
inputRef={this.setTextarea}
|
|
||||||
className='autosuggest-textarea__textarea'
|
|
||||||
disabled={disabled}
|
|
||||||
placeholder={placeholder}
|
|
||||||
autoFocus={autoFocus}
|
|
||||||
value={value}
|
|
||||||
onChange={this.onChange}
|
|
||||||
onKeyDown={this.onKeyDown}
|
|
||||||
onKeyUp={this.onKeyUp}
|
|
||||||
onBlur={this.onBlur}
|
|
||||||
onPaste={this.onPaste}
|
|
||||||
style={style}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div className={`autosuggest-textarea__suggestions ${suggestionsHidden || suggestions.isEmpty() ? '' : 'autosuggest-textarea__suggestions--visible'}`}>
|
|
||||||
{suggestions.map(this.renderSuggestion)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
|
import classNames from 'classnames';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { autoPlayGif } from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
export default class Avatar extends React.PureComponent {
|
export default class Avatar extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
|
className: PropTypes.string,
|
||||||
size: PropTypes.number.isRequired,
|
size: PropTypes.number.isRequired,
|
||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
animate: PropTypes.bool,
|
|
||||||
inline: PropTypes.bool,
|
inline: PropTypes.bool,
|
||||||
|
animate: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
animate: false,
|
animate: autoPlayGif,
|
||||||
size: 20,
|
size: 20,
|
||||||
inline: false,
|
inline: false,
|
||||||
};
|
};
|
||||||
@@ -33,17 +36,19 @@ export default class Avatar extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { account, size, animate, inline } = this.props;
|
const {
|
||||||
|
account,
|
||||||
|
animate,
|
||||||
|
className,
|
||||||
|
inline,
|
||||||
|
size,
|
||||||
|
} = this.props;
|
||||||
const { hovering } = this.state;
|
const { hovering } = this.state;
|
||||||
|
|
||||||
const src = account.get('avatar');
|
const src = account.get('avatar');
|
||||||
const staticSrc = account.get('avatar_static');
|
const staticSrc = account.get('avatar_static');
|
||||||
|
|
||||||
let className = 'account__avatar';
|
const computedClass = classNames('account__avatar', { 'account__avatar-inline': inline }, className);
|
||||||
|
|
||||||
if (inline) {
|
|
||||||
className = className + ' account__avatar-inline';
|
|
||||||
}
|
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
...this.props.style,
|
...this.props.style,
|
||||||
@@ -60,7 +65,7 @@ export default class Avatar extends React.PureComponent {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={className}
|
className={computedClass}
|
||||||
onMouseEnter={this.handleMouseEnter}
|
onMouseEnter={this.handleMouseEnter}
|
||||||
onMouseLeave={this.handleMouseLeave}
|
onMouseLeave={this.handleMouseLeave}
|
||||||
style={style}
|
style={style}
|
||||||
|
|||||||
@@ -1,22 +1,29 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { autoPlayGif } from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
export default class AvatarOverlay extends React.PureComponent {
|
export default class AvatarOverlay extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
account: ImmutablePropTypes.map.isRequired,
|
||||||
friend: ImmutablePropTypes.map.isRequired,
|
friend: ImmutablePropTypes.map.isRequired,
|
||||||
|
animate: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
animate: autoPlayGif,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, friend } = this.props;
|
const { account, friend, animate } = this.props;
|
||||||
|
|
||||||
const baseStyle = {
|
const baseStyle = {
|
||||||
backgroundImage: `url(${account.get('avatar_static')})`,
|
backgroundImage: `url(${account.get(animate ? 'avatar' : 'avatar_static')})`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const overlayStyle = {
|
const overlayStyle = {
|
||||||
backgroundImage: `url(${friend.get('avatar_static')})`,
|
backgroundImage: `url(${friend.get(animate ? 'avatar' : 'avatar_static')})`,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,20 +1,30 @@
|
|||||||
|
// Package imports.
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
export default class DisplayName extends React.PureComponent {
|
// The component.
|
||||||
|
export default function DisplayName ({
|
||||||
static propTypes = {
|
account,
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
className,
|
||||||
};
|
inline,
|
||||||
|
}) {
|
||||||
render () {
|
const computedClass = classNames('display-name', { inline }, className);
|
||||||
const displayNameHtml = { __html: this.props.account.get('display_name_html') };
|
|
||||||
|
|
||||||
return (
|
|
||||||
<span className='display-name'>
|
|
||||||
<strong className='display-name__html' dangerouslySetInnerHTML={displayNameHtml} /> <span className='display-name__account'>@{this.props.account.get('acct')}</span>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// The result.
|
||||||
|
return account ? (
|
||||||
|
<span className={computedClass}>
|
||||||
|
<strong className='display-name__html' dangerouslySetInnerHTML={{ __html: account.get('display_name_html') }} />
|
||||||
|
{inline ? ' ' : null}
|
||||||
|
<span className='display-name__account'>@{account.get('acct')}</span>
|
||||||
|
</span>
|
||||||
|
) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Props.
|
||||||
|
DisplayName.propTypes = {
|
||||||
|
account: ImmutablePropTypes.map,
|
||||||
|
className: PropTypes.string,
|
||||||
|
inline: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|||||||
@@ -133,8 +133,13 @@ export default class Dropdown extends React.PureComponent {
|
|||||||
|
|
||||||
this.props.onModalOpen({
|
this.props.onModalOpen({
|
||||||
status,
|
status,
|
||||||
actions: items,
|
actions: items.map(
|
||||||
onClick: this.handleItemClick,
|
(item, i) => item ? {
|
||||||
|
...item,
|
||||||
|
name: `${item.text}-${i}`,
|
||||||
|
onClick: this.handleItemClick.bind(this, i),
|
||||||
|
} : null
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -162,8 +167,7 @@ export default class Dropdown extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleItemClick = e => {
|
handleItemClick = (i, e) => {
|
||||||
const i = Number(e.currentTarget.getAttribute('data-index'));
|
|
||||||
const { action, to } = this.props.items[i];
|
const { action, to } = this.props.items[i];
|
||||||
|
|
||||||
this.handleClose();
|
this.handleClose();
|
||||||
|
|||||||
26
app/javascript/flavours/glitch/components/icon.js
Normal file
26
app/javascript/flavours/glitch/components/icon.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Package imports.
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
// This just renders a FontAwesome icon.
|
||||||
|
export default function Icon ({
|
||||||
|
className,
|
||||||
|
fullwidth,
|
||||||
|
icon,
|
||||||
|
}) {
|
||||||
|
const computedClass = classNames('icon', 'fa', { 'fa-fw': fullwidth }, `fa-${icon}`, className);
|
||||||
|
return icon ? (
|
||||||
|
<span
|
||||||
|
aria-hidden='true'
|
||||||
|
className={computedClass}
|
||||||
|
/>
|
||||||
|
) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Props.
|
||||||
|
Icon.propTypes = {
|
||||||
|
className: PropTypes.string,
|
||||||
|
fullwidth: PropTypes.bool,
|
||||||
|
icon: PropTypes.string,
|
||||||
|
};
|
||||||
97
app/javascript/flavours/glitch/components/link.js
Normal file
97
app/javascript/flavours/glitch/components/link.js
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
// Inspired by <CommonLink> from Mastodon GO!
|
||||||
|
// ~ 😘 kibi!
|
||||||
|
|
||||||
|
// Package imports.
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
// Utils.
|
||||||
|
import { assignHandlers } from 'flavours/glitch/util/react_helpers';
|
||||||
|
|
||||||
|
// Handlers.
|
||||||
|
const handlers = {
|
||||||
|
|
||||||
|
// We don't handle clicks that are made with modifiers, since these
|
||||||
|
// often have special browser meanings (eg, "open in new tab").
|
||||||
|
click (e) {
|
||||||
|
const { onClick } = this.props;
|
||||||
|
if (!onClick || e.button || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onClick(e);
|
||||||
|
e.preventDefault(); // Prevents following of the link
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// The component.
|
||||||
|
export default class Link extends React.PureComponent {
|
||||||
|
|
||||||
|
// Constructor.
|
||||||
|
constructor (props) {
|
||||||
|
super(props);
|
||||||
|
assignHandlers(this, handlers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering.
|
||||||
|
render () {
|
||||||
|
const { click } = this.handlers;
|
||||||
|
const {
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
href,
|
||||||
|
onClick,
|
||||||
|
role,
|
||||||
|
title,
|
||||||
|
...rest
|
||||||
|
} = this.props;
|
||||||
|
const computedClass = classNames('link', className, `role-${role}`);
|
||||||
|
|
||||||
|
// We assume that our `onClick` is a routing function and give it
|
||||||
|
// the qualities of a link even if no `href` is provided. However,
|
||||||
|
// if we have neither an `onClick` or an `href`, our link is
|
||||||
|
// purely presentational.
|
||||||
|
const conditionalProps = {};
|
||||||
|
if (href) {
|
||||||
|
conditionalProps.href = href;
|
||||||
|
conditionalProps.onClick = click;
|
||||||
|
} else if (onClick) {
|
||||||
|
conditionalProps.onClick = click;
|
||||||
|
conditionalProps.role = 'link';
|
||||||
|
conditionalProps.tabIndex = 0;
|
||||||
|
} else {
|
||||||
|
conditionalProps.role = 'presentation';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we were provided a `role` it overwrites any that we may have
|
||||||
|
// set above. This can be used for "links" which are actually
|
||||||
|
// buttons.
|
||||||
|
if (role) {
|
||||||
|
conditionalProps.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering. We set `rel='noopener'` for user privacy, and our
|
||||||
|
// `target` as `'_blank'`.
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
className={computedClass}
|
||||||
|
{...conditionalProps}
|
||||||
|
rel='noopener'
|
||||||
|
target='_blank'
|
||||||
|
title={title}
|
||||||
|
{...rest}
|
||||||
|
>{children}</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Props.
|
||||||
|
Link.propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
className: PropTypes.string,
|
||||||
|
href: PropTypes.string, // The link destination
|
||||||
|
onClick: PropTypes.func, // A function to call instead of opening the link
|
||||||
|
role: PropTypes.string, // An ARIA role for the link
|
||||||
|
title: PropTypes.string, // A title for the link
|
||||||
|
};
|
||||||
@@ -22,7 +22,13 @@ export default class Permalink extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { href, children, className, ...other } = this.props;
|
const {
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
href,
|
||||||
|
to,
|
||||||
|
...other
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a target='_blank' href={href} onClick={this.handleClick} {...other} className={`permalink${className ? ' ' + className : ''}`}>
|
<a target='_blank' href={href} onClick={this.handleClick} {...other} className={`permalink${className ? ' ' + className : ''}`}>
|
||||||
|
|||||||
@@ -6,24 +6,24 @@ export default class SettingText extends React.PureComponent {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
settings: ImmutablePropTypes.map.isRequired,
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
settingKey: PropTypes.array.isRequired,
|
settingPath: PropTypes.array.isRequired,
|
||||||
label: PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleChange = (e) => {
|
handleChange = (e) => {
|
||||||
this.props.onChange(this.props.settingKey, e.target.value);
|
this.props.onChange(this.props.settingPath, e.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { settings, settingKey, label } = this.props;
|
const { settings, settingPath, label } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label>
|
<label>
|
||||||
<span style={{ display: 'none' }}>{label}</span>
|
<span style={{ display: 'none' }}>{label}</span>
|
||||||
<input
|
<input
|
||||||
className='setting-text'
|
className='setting-text'
|
||||||
value={settings.getIn(settingKey)}
|
value={settings.getIn(settingPath)}
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
placeholder={label}
|
placeholder={label}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export default class Status extends ImmutablePureComponent {
|
|||||||
'settings',
|
'settings',
|
||||||
'prepend',
|
'prepend',
|
||||||
'boostModal',
|
'boostModal',
|
||||||
|
'favouriteModal',
|
||||||
'muted',
|
'muted',
|
||||||
'collapse',
|
'collapse',
|
||||||
'notification',
|
'notification',
|
||||||
@@ -204,8 +205,8 @@ export default class Status extends ImmutablePureComponent {
|
|||||||
this.props.onReply(this.props.status, this.context.router.history);
|
this.props.onReply(this.props.status, this.context.router.history);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyFavourite = () => {
|
handleHotkeyFavourite = (e) => {
|
||||||
this.props.onFavourite(this.props.status);
|
this.props.onFavourite(this.props.status, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyBoost = e => {
|
handleHotkeyBoost = e => {
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ export default class StatusActionBar extends ImmutablePureComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFavouriteClick = () => {
|
handleFavouriteClick = (e) => {
|
||||||
this.props.onFavourite(this.props.status);
|
this.props.onFavourite(this.props.status, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleReblogClick = (e) => {
|
handleReblogClick = (e) => {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ 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';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
import { boostModal, deleteModal } from 'flavours/glitch/util/initial_state';
|
import { boostModal, favouriteModal, deleteModal } from 'flavours/glitch/util/initial_state';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||||
@@ -78,11 +78,19 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFavourite (status) {
|
onModalFavourite (status) {
|
||||||
|
dispatch(favourite(status));
|
||||||
|
},
|
||||||
|
|
||||||
|
onFavourite (status, e) {
|
||||||
if (status.get('favourited')) {
|
if (status.get('favourited')) {
|
||||||
dispatch(unfavourite(status));
|
dispatch(unfavourite(status));
|
||||||
} else {
|
} else {
|
||||||
dispatch(favourite(status));
|
if (e.shiftKey || !favouriteModal) {
|
||||||
|
this.onModalFavourite(status);
|
||||||
|
} else {
|
||||||
|
dispatch(openModal('FAVOURITE', { status, onFavourite: this.onModalFavourite }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,8 @@ export default class ActionBar extends React.PureComponent {
|
|||||||
if (account.get('id') === me) {
|
if (account.get('id') === me) {
|
||||||
menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' });
|
menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' });
|
||||||
} else {
|
} else {
|
||||||
const following = account.getIn(['relationship', 'following']);
|
if (account.getIn(['relationship', 'following'])) {
|
||||||
if (following) {
|
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
||||||
if (following.get('reblogs')) {
|
|
||||||
menu.push({ text: intl.formatMessage(messages.hideReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
|
menu.push({ text: intl.formatMessage(messages.hideReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
|
||||||
} else {
|
} else {
|
||||||
menu.push({ text: intl.formatMessage(messages.showReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
|
menu.push({ text: intl.formatMessage(messages.showReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
|
||||||
|
|||||||
@@ -63,7 +63,15 @@ export default class Header extends ImmutablePureComponent {
|
|||||||
<div className='account__header__wrapper'>
|
<div className='account__header__wrapper'>
|
||||||
<div className='account__header' style={{ backgroundImage: `url(${account.get('header')})` }}>
|
<div className='account__header' style={{ backgroundImage: `url(${account.get('header')})` }}>
|
||||||
<div>
|
<div>
|
||||||
<Avatar account={account} size={90} />
|
<a
|
||||||
|
href={account.get('url')}
|
||||||
|
className='account__header__avatar'
|
||||||
|
role='presentation'
|
||||||
|
target='_blank'
|
||||||
|
rel='noopener'
|
||||||
|
>
|
||||||
|
<Avatar account={account} size={90} />
|
||||||
|
</a>
|
||||||
|
|
||||||
<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>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onReblogToggle (account) {
|
onReblogToggle (account) {
|
||||||
if (account.getIn(['relationship', 'following', 'reblogs'])) {
|
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
||||||
dispatch(followAccount(account.get('id'), false));
|
dispatch(followAccount(account.get('id'), false));
|
||||||
} else {
|
} else {
|
||||||
dispatch(followAccount(account.get('id'), true));
|
dispatch(followAccount(account.get('id'), true));
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default class ColumnSettings extends React.PureComponent {
|
|||||||
<span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span>
|
<span className='column-settings__section'><FormattedMessage id='home.column_settings.advanced' defaultMessage='Advanced' /></span>
|
||||||
|
|
||||||
<div className='column-settings__row'>
|
<div className='column-settings__row'>
|
||||||
<SettingText settings={settings} settingKey={['regex', 'body']} onChange={onChange} label={intl.formatMessage(messages.filter_regex)} />
|
<SettingText settings={settings} settingPath={['regex', 'body']} onChange={onChange} label={intl.formatMessage(messages.filter_regex)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
// Package imports.
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
// Our imports.
|
|
||||||
import ComposeAdvancedOptionsToggle from './advanced_options_toggle';
|
|
||||||
import ComposeDropdown from './dropdown';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
local_only_short :
|
|
||||||
{ id: 'advanced-options.local-only.short', defaultMessage: 'Local-only' },
|
|
||||||
local_only_long :
|
|
||||||
{ id: 'advanced-options.local-only.long', defaultMessage: 'Do not post to other instances' },
|
|
||||||
advanced_options_icon_title :
|
|
||||||
{ id: 'advanced_options.icon_title', defaultMessage: 'Advanced options' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class ComposeAdvancedOptions extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
values : ImmutablePropTypes.contains({
|
|
||||||
do_not_federate : PropTypes.bool.isRequired,
|
|
||||||
}).isRequired,
|
|
||||||
onChange : PropTypes.func.isRequired,
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, values } = this.props;
|
|
||||||
const options = [
|
|
||||||
{ icon: 'wifi', shortText: messages.local_only_short, longText: messages.local_only_long, name: 'do_not_federate' },
|
|
||||||
];
|
|
||||||
const anyEnabled = values.some((enabled) => enabled);
|
|
||||||
|
|
||||||
const optionElems = options.map((option) => {
|
|
||||||
return (
|
|
||||||
<ComposeAdvancedOptionsToggle
|
|
||||||
onChange={this.props.onChange}
|
|
||||||
active={values.get(option.name)}
|
|
||||||
key={option.name}
|
|
||||||
name={option.name}
|
|
||||||
shortText={intl.formatMessage(option.shortText)}
|
|
||||||
longText={intl.formatMessage(option.longText)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ComposeDropdown
|
|
||||||
title={intl.formatMessage(messages.advanced_options_icon_title)}
|
|
||||||
icon='home'
|
|
||||||
highlight={anyEnabled}
|
|
||||||
>
|
|
||||||
{optionElems}
|
|
||||||
</ComposeDropdown>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
// Package imports.
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Toggle from 'react-toggle';
|
|
||||||
|
|
||||||
export default class ComposeAdvancedOptionsToggle extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
active: PropTypes.bool.isRequired,
|
|
||||||
name: PropTypes.string.isRequired,
|
|
||||||
shortText: PropTypes.string.isRequired,
|
|
||||||
longText: PropTypes.string.isRequired,
|
|
||||||
}
|
|
||||||
|
|
||||||
onToggle = () => {
|
|
||||||
this.props.onChange(this.props.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { active, shortText, longText } = this.props;
|
|
||||||
return (
|
|
||||||
<div role='button' tabIndex='0' className='advanced-options-dropdown__option' onClick={this.onToggle}>
|
|
||||||
<div className='advanced-options-dropdown__option__toggle'>
|
|
||||||
<Toggle checked={active} onChange={this.onToggle} />
|
|
||||||
</div>
|
|
||||||
<div className='advanced-options-dropdown__option__content'>
|
|
||||||
<strong>{shortText}</strong>
|
|
||||||
{longText}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
// Package imports //
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
// Our imports //
|
|
||||||
import ComposeDropdown from './dropdown';
|
|
||||||
import { uploadCompose } from 'flavours/glitch/actions/compose';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import { openModal } from 'flavours/glitch/actions/modal';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
upload :
|
|
||||||
{ id: 'compose.attach.upload', defaultMessage: 'Upload a file' },
|
|
||||||
doodle :
|
|
||||||
{ id: 'compose.attach.doodle', defaultMessage: 'Draw something' },
|
|
||||||
attach :
|
|
||||||
{ id: 'compose.attach', defaultMessage: 'Attach...' },
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
// This horrible expression is copied from vanilla upload_button_container
|
|
||||||
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 3 || state.getIn(['compose', 'media_attachments']).some(m => m.get('type') === 'video')),
|
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
|
||||||
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
onSelectFile (files) {
|
|
||||||
dispatch(uploadCompose(files));
|
|
||||||
},
|
|
||||||
onOpenDoodle () {
|
|
||||||
dispatch(openModal('DOODLE', { noEsc: true }));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
@connect(mapStateToProps, mapDispatchToProps)
|
|
||||||
export default class ComposeAttachOptions extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
intl : PropTypes.object.isRequired,
|
|
||||||
resetFileKey: PropTypes.number,
|
|
||||||
acceptContentTypes: ImmutablePropTypes.listOf(PropTypes.string).isRequired,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
onSelectFile: PropTypes.func.isRequired,
|
|
||||||
onOpenDoodle: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleItemClick = bt => {
|
|
||||||
if (bt === 'upload') {
|
|
||||||
this.fileElement.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bt === 'doodle') {
|
|
||||||
this.props.onOpenDoodle();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dropdown.setState({ open: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
handleFileChange = (e) => {
|
|
||||||
if (e.target.files.length > 0) {
|
|
||||||
this.props.onSelectFile(e.target.files);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setFileRef = (c) => {
|
|
||||||
this.fileElement = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
setDropdownRef = (c) => {
|
|
||||||
this.dropdown = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, resetFileKey, disabled, acceptContentTypes } = this.props;
|
|
||||||
|
|
||||||
const options = [
|
|
||||||
{ icon: 'cloud-upload', text: messages.upload, name: 'upload' },
|
|
||||||
{ icon: 'paint-brush', text: messages.doodle, name: 'doodle' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const optionElems = options.map((item) => {
|
|
||||||
const hdl = () => this.handleItemClick(item.name);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
role='button'
|
|
||||||
tabIndex='0'
|
|
||||||
key={item.name}
|
|
||||||
onClick={hdl}
|
|
||||||
className='privacy-dropdown__option'
|
|
||||||
>
|
|
||||||
<div className='privacy-dropdown__option__icon'>
|
|
||||||
<i className={`fa fa-fw fa-${item.icon}`} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='privacy-dropdown__option__content'>
|
|
||||||
<strong>{intl.formatMessage(item.text)}</strong>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<ComposeDropdown
|
|
||||||
title={intl.formatMessage(messages.attach)}
|
|
||||||
icon='paperclip'
|
|
||||||
disabled={disabled}
|
|
||||||
ref={this.setDropdownRef}
|
|
||||||
>
|
|
||||||
{optionElems}
|
|
||||||
</ComposeDropdown>
|
|
||||||
<input
|
|
||||||
key={resetFileKey}
|
|
||||||
ref={this.setFileRef}
|
|
||||||
type='file'
|
|
||||||
multiple={false}
|
|
||||||
accept={acceptContentTypes.toArray().join(',')}
|
|
||||||
onChange={this.handleFileChange}
|
|
||||||
disabled={disabled}
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import Avatar from 'flavours/glitch/components/avatar';
|
|
||||||
import DisplayName from 'flavours/glitch/components/display_name';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
export default class AutosuggestAccount extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { account } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='autosuggest-account'>
|
|
||||||
<div className='autosuggest-account-icon'><Avatar account={account} size={18} /></div>
|
|
||||||
<DisplayName account={account} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { length } from 'stringz';
|
|
||||||
|
|
||||||
export default class CharacterCounter extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
text: PropTypes.string.isRequired,
|
|
||||||
max: PropTypes.number.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
checkRemainingText (diff) {
|
|
||||||
if (diff < 0) {
|
|
||||||
return <span className='character-counter character-counter--over'>{diff}</span>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <span className='character-counter'>{diff}</span>;
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const diff = this.props.max - length(this.props.text);
|
|
||||||
return this.checkRemainingText(diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,286 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import CharacterCounter from './character_counter';
|
|
||||||
import Button from 'flavours/glitch/components/button';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ReplyIndicatorContainer from '../containers/reply_indicator_container';
|
|
||||||
import AutosuggestTextarea from 'flavours/glitch/components/autosuggest_textarea';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
import Collapsable from 'flavours/glitch/components/collapsable';
|
|
||||||
import SpoilerButtonContainer from '../containers/spoiler_button_container';
|
|
||||||
import PrivacyDropdownContainer from '../containers/privacy_dropdown_container';
|
|
||||||
import ComposeAdvancedOptionsContainer from '../containers/advanced_options_container';
|
|
||||||
import SensitiveButtonContainer from '../containers/sensitive_button_container';
|
|
||||||
import EmojiPickerDropdown from '../containers/emoji_picker_dropdown_container';
|
|
||||||
import UploadFormContainer from '../containers/upload_form_container';
|
|
||||||
import WarningContainer from '../containers/warning_container';
|
|
||||||
import { isMobile } from 'flavours/glitch/util/is_mobile';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import { length } from 'stringz';
|
|
||||||
import { countableText } from 'flavours/glitch/util/counter';
|
|
||||||
import ComposeAttachOptions from './attach_options';
|
|
||||||
import initialState from 'flavours/glitch/util/initial_state';
|
|
||||||
|
|
||||||
const maxChars = initialState.max_toot_chars;
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' },
|
|
||||||
spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: 'Write your warning here' },
|
|
||||||
publish: { id: 'compose_form.publish', defaultMessage: 'Toot' },
|
|
||||||
publishLoud: { id: 'compose_form.publish_loud', defaultMessage: '{publish}!' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class ComposeForm extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
text: PropTypes.string.isRequired,
|
|
||||||
suggestion_token: PropTypes.string,
|
|
||||||
suggestions: ImmutablePropTypes.list,
|
|
||||||
spoiler: PropTypes.bool,
|
|
||||||
privacy: PropTypes.string,
|
|
||||||
advanced_options: ImmutablePropTypes.contains({
|
|
||||||
do_not_federate: PropTypes.bool,
|
|
||||||
}),
|
|
||||||
spoiler_text: PropTypes.string,
|
|
||||||
focusDate: PropTypes.instanceOf(Date),
|
|
||||||
preselectDate: PropTypes.instanceOf(Date),
|
|
||||||
is_submitting: PropTypes.bool,
|
|
||||||
is_uploading: PropTypes.bool,
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
onSubmit: PropTypes.func.isRequired,
|
|
||||||
onClearSuggestions: PropTypes.func.isRequired,
|
|
||||||
onFetchSuggestions: PropTypes.func.isRequired,
|
|
||||||
onPrivacyChange: PropTypes.func.isRequired,
|
|
||||||
onSuggestionSelected: PropTypes.func.isRequired,
|
|
||||||
onChangeSpoilerText: PropTypes.func.isRequired,
|
|
||||||
onPaste: PropTypes.func.isRequired,
|
|
||||||
onPickEmoji: PropTypes.func.isRequired,
|
|
||||||
showSearch: PropTypes.bool,
|
|
||||||
settings : ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
showSearch: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleChange = (e) => {
|
|
||||||
this.props.onChange(e.target.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleKeyDown = (e) => {
|
|
||||||
if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) {
|
|
||||||
this.handleSubmit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit2 = () => {
|
|
||||||
this.props.onPrivacyChange(this.props.settings.get('side_arm'));
|
|
||||||
this.handleSubmit();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit = () => {
|
|
||||||
if (this.props.text !== this.autosuggestTextarea.textarea.value) {
|
|
||||||
// Something changed the text inside the textarea (e.g. browser extensions like Grammarly)
|
|
||||||
// Update the state to match the current text
|
|
||||||
this.props.onChange(this.autosuggestTextarea.textarea.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.props.onSubmit();
|
|
||||||
}
|
|
||||||
|
|
||||||
onSuggestionsClearRequested = () => {
|
|
||||||
this.props.onClearSuggestions();
|
|
||||||
}
|
|
||||||
|
|
||||||
onSuggestionsFetchRequested = (token) => {
|
|
||||||
this.props.onFetchSuggestions(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
onSuggestionSelected = (tokenStart, token, value) => {
|
|
||||||
this._restoreCaret = null;
|
|
||||||
this.props.onSuggestionSelected(tokenStart, token, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleChangeSpoilerText = (e) => {
|
|
||||||
this.props.onChangeSpoilerText(e.target.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
|
||||||
// If this is the update where we've finished uploading,
|
|
||||||
// save the last caret position so we can restore it below!
|
|
||||||
if (!nextProps.is_uploading && this.props.is_uploading) {
|
|
||||||
this._restoreCaret = this.autosuggestTextarea.textarea.selectionStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate (prevProps) {
|
|
||||||
// This statement does several things:
|
|
||||||
// - If we're beginning a reply, and,
|
|
||||||
// - Replying to zero or one users, places the cursor at the end of the textbox.
|
|
||||||
// - Replying to more than one user, selects any usernames past the first;
|
|
||||||
// this provides a convenient shortcut to drop 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!
|
|
||||||
if (this.props.focusDate !== prevProps.focusDate || (prevProps.is_uploading && !this.props.is_uploading && typeof this._restoreCaret === 'number')) {
|
|
||||||
let selectionEnd, selectionStart;
|
|
||||||
|
|
||||||
if (this.props.preselectDate !== prevProps.preselectDate) {
|
|
||||||
selectionEnd = this.props.text.length;
|
|
||||||
selectionStart = this.props.text.search(/\s/) + 1;
|
|
||||||
} else if (typeof this._restoreCaret === 'number') {
|
|
||||||
selectionStart = this._restoreCaret;
|
|
||||||
selectionEnd = this._restoreCaret;
|
|
||||||
} else {
|
|
||||||
selectionEnd = this.props.text.length;
|
|
||||||
selectionStart = selectionEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.autosuggestTextarea.textarea.setSelectionRange(selectionStart, selectionEnd);
|
|
||||||
this.autosuggestTextarea.textarea.focus();
|
|
||||||
} else if(prevProps.is_submitting && !this.props.is_submitting) {
|
|
||||||
this.autosuggestTextarea.textarea.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setAutosuggestTextarea = (c) => {
|
|
||||||
this.autosuggestTextarea = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
handleEmojiPick = (data) => {
|
|
||||||
const position = this.autosuggestTextarea.textarea.selectionStart;
|
|
||||||
const emojiChar = data.native;
|
|
||||||
this._restoreCaret = position + emojiChar.length + 1;
|
|
||||||
this.props.onPickEmoji(position, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, onPaste, showSearch } = this.props;
|
|
||||||
const disabled = this.props.is_submitting;
|
|
||||||
const maybeEye = (this.props.advanced_options && this.props.advanced_options.do_not_federate) ? ' 👁️' : '';
|
|
||||||
const text = [this.props.spoiler_text, countableText(this.props.text), maybeEye].join('');
|
|
||||||
|
|
||||||
const secondaryVisibility = this.props.settings.get('side_arm');
|
|
||||||
let showSideArm = secondaryVisibility !== 'none';
|
|
||||||
|
|
||||||
let publishText = '';
|
|
||||||
let publishText2 = '';
|
|
||||||
let title = '';
|
|
||||||
let title2 = '';
|
|
||||||
|
|
||||||
const privacyIcons = {
|
|
||||||
none: '',
|
|
||||||
public: 'globe',
|
|
||||||
unlisted: 'unlock-alt',
|
|
||||||
private: 'lock',
|
|
||||||
direct: 'envelope',
|
|
||||||
};
|
|
||||||
|
|
||||||
title = `${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${this.props.privacy}.short` })}`;
|
|
||||||
|
|
||||||
if (showSideArm) {
|
|
||||||
// Enhanced behavior with dual toot buttons
|
|
||||||
publishText = (
|
|
||||||
<span>
|
|
||||||
{
|
|
||||||
<i
|
|
||||||
className={`fa fa-${privacyIcons[this.props.privacy]}`}
|
|
||||||
style={{ paddingRight: '5px' }}
|
|
||||||
/>
|
|
||||||
}{intl.formatMessage(messages.publish)}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
|
|
||||||
title2 = `${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${secondaryVisibility}.short` })}`;
|
|
||||||
publishText2 = (
|
|
||||||
<i
|
|
||||||
className={`fa fa-${privacyIcons[secondaryVisibility]}`}
|
|
||||||
aria-label={title2}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Original vanilla behavior - no icon if public or unlisted
|
|
||||||
if (this.props.privacy === 'private' || this.props.privacy === 'direct') {
|
|
||||||
publishText = <span className='compose-form__publish-private'><i className='fa fa-lock' /> {intl.formatMessage(messages.publish)}</span>;
|
|
||||||
} else {
|
|
||||||
publishText = this.props.privacy !== 'unlisted' ? intl.formatMessage(messages.publishLoud, { publish: intl.formatMessage(messages.publish) }) : intl.formatMessage(messages.publish);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const submitDisabled = disabled || this.props.is_uploading || length(text) > maxChars || (text.length !== 0 && text.trim().length === 0);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='compose-form'>
|
|
||||||
<Collapsable isVisible={this.props.spoiler} fullHeight={50}>
|
|
||||||
<div className='spoiler-input'>
|
|
||||||
<label>
|
|
||||||
<span style={{ display: 'none' }}>{intl.formatMessage(messages.spoiler_placeholder)}</span>
|
|
||||||
<input placeholder={intl.formatMessage(messages.spoiler_placeholder)} value={this.props.spoiler_text} onChange={this.handleChangeSpoilerText} onKeyDown={this.handleKeyDown} type='text' className='spoiler-input__input' id='cw-spoiler-input' />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</Collapsable>
|
|
||||||
|
|
||||||
<WarningContainer />
|
|
||||||
|
|
||||||
<ReplyIndicatorContainer />
|
|
||||||
|
|
||||||
<div className='compose-form__autosuggest-wrapper'>
|
|
||||||
<AutosuggestTextarea
|
|
||||||
ref={this.setAutosuggestTextarea}
|
|
||||||
placeholder={intl.formatMessage(messages.placeholder)}
|
|
||||||
disabled={disabled}
|
|
||||||
value={this.props.text}
|
|
||||||
onChange={this.handleChange}
|
|
||||||
suggestions={this.props.suggestions}
|
|
||||||
onKeyDown={this.handleKeyDown}
|
|
||||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
|
||||||
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
|
||||||
onSuggestionSelected={this.onSuggestionSelected}
|
|
||||||
onPaste={onPaste}
|
|
||||||
autoFocus={!showSearch && !isMobile(window.innerWidth)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='compose-form__modifiers'>
|
|
||||||
<UploadFormContainer />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='compose-form__buttons'>
|
|
||||||
<ComposeAttachOptions />
|
|
||||||
<SensitiveButtonContainer />
|
|
||||||
<div className='compose-form__buttons-separator' />
|
|
||||||
<PrivacyDropdownContainer />
|
|
||||||
<SpoilerButtonContainer />
|
|
||||||
<ComposeAdvancedOptionsContainer />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='compose-form__publish'>
|
|
||||||
<div className='character-counter__wrapper'><CharacterCounter max={maxChars} text={text} /></div>
|
|
||||||
<div className='compose-form__publish-button-wrapper'>
|
|
||||||
{
|
|
||||||
showSideArm ?
|
|
||||||
<Button
|
|
||||||
className='compose-form__publish__side-arm'
|
|
||||||
text={publishText2}
|
|
||||||
title={title2}
|
|
||||||
onClick={this.handleSubmit2}
|
|
||||||
disabled={submitDisabled}
|
|
||||||
/> : ''
|
|
||||||
}
|
|
||||||
<Button
|
|
||||||
className='compose-form__publish__primary'
|
|
||||||
text={publishText}
|
|
||||||
title={title}
|
|
||||||
onClick={this.handleSubmit}
|
|
||||||
disabled={submitDisabled}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
// Package imports.
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
// Our imports.
|
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
|
||||||
|
|
||||||
const iconStyle = {
|
|
||||||
height : null,
|
|
||||||
lineHeight : '27px',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class ComposeDropdown extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
title: PropTypes.string.isRequired,
|
|
||||||
icon: PropTypes.string,
|
|
||||||
highlight: PropTypes.bool,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
children: PropTypes.arrayOf(PropTypes.node).isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
open: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
onGlobalClick = (e) => {
|
|
||||||
if (e.target !== this.node && !this.node.contains(e.target) && this.state.open) {
|
|
||||||
this.setState({ open: false });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount () {
|
|
||||||
window.addEventListener('click', this.onGlobalClick);
|
|
||||||
window.addEventListener('touchstart', this.onGlobalClick);
|
|
||||||
}
|
|
||||||
componentWillUnmount () {
|
|
||||||
window.removeEventListener('click', this.onGlobalClick);
|
|
||||||
window.removeEventListener('touchstart', this.onGlobalClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
onToggleDropdown = () => {
|
|
||||||
if (this.props.disabled) return;
|
|
||||||
this.setState({ open: !this.state.open });
|
|
||||||
};
|
|
||||||
|
|
||||||
setRef = (c) => {
|
|
||||||
this.node = c;
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { open } = this.state;
|
|
||||||
let { highlight, title, icon, disabled } = this.props;
|
|
||||||
|
|
||||||
if (!icon) icon = 'ellipsis-h';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div ref={this.setRef} className={`advanced-options-dropdown ${open ? 'open' : ''} ${highlight ? 'active' : ''} `}>
|
|
||||||
<div className='advanced-options-dropdown__value'>
|
|
||||||
<IconButton
|
|
||||||
className={'inverted'}
|
|
||||||
title={title}
|
|
||||||
icon={icon} active={open || highlight}
|
|
||||||
size={18}
|
|
||||||
style={iconStyle}
|
|
||||||
disabled={disabled}
|
|
||||||
onClick={this.onToggleDropdown}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className='advanced-options-dropdown__dropdown'>
|
|
||||||
{this.props.children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import Avatar from 'flavours/glitch/components/avatar';
|
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
|
||||||
import Permalink from 'flavours/glitch/components/permalink';
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
export default class NavigationBar extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
account: ImmutablePropTypes.map.isRequired,
|
|
||||||
onClose: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
return (
|
|
||||||
<div className='navigation-bar'>
|
|
||||||
<Permalink href={this.props.account.get('url')} to={`/accounts/${this.props.account.get('id')}`}>
|
|
||||||
<span style={{ display: 'none' }}>{this.props.account.get('acct')}</span>
|
|
||||||
<Avatar account={this.props.account} size={40} />
|
|
||||||
</Permalink>
|
|
||||||
|
|
||||||
<div className='navigation-bar__profile'>
|
|
||||||
<Permalink href={this.props.account.get('url')} to={`/accounts/${this.props.account.get('id')}`}>
|
|
||||||
<strong className='navigation-bar__profile-account'>@{this.props.account.get('acct')}</strong>
|
|
||||||
</Permalink>
|
|
||||||
|
|
||||||
<a href='/settings/profile' className='navigation-bar__profile-edit'><FormattedMessage id='navigation_bar.edit_profile' defaultMessage='Edit profile' /></a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<IconButton title='' icon='close' onClick={this.props.onClose} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,200 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
|
||||||
import Overlay from 'react-overlays/lib/Overlay';
|
|
||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
import detectPassiveEvents from 'detect-passive-events';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
public_short: { id: 'privacy.public.short', defaultMessage: 'Public' },
|
|
||||||
public_long: { id: 'privacy.public.long', defaultMessage: 'Post to public timelines' },
|
|
||||||
unlisted_short: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
|
|
||||||
unlisted_long: { id: 'privacy.unlisted.long', defaultMessage: 'Do not show in public timelines' },
|
|
||||||
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
|
|
||||||
private_long: { id: 'privacy.private.long', defaultMessage: 'Post to followers only' },
|
|
||||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
|
|
||||||
direct_long: { id: 'privacy.direct.long', defaultMessage: 'Post to mentioned users only' },
|
|
||||||
change_privacy: { id: 'privacy.change', defaultMessage: 'Adjust status privacy' },
|
|
||||||
});
|
|
||||||
|
|
||||||
const listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
|
|
||||||
|
|
||||||
class PrivacyDropdownMenu extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
style: PropTypes.object,
|
|
||||||
items: PropTypes.array.isRequired,
|
|
||||||
value: PropTypes.string.isRequired,
|
|
||||||
onClose: PropTypes.func.isRequired,
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleDocumentClick = e => {
|
|
||||||
if (this.node && !this.node.contains(e.target)) {
|
|
||||||
this.props.onClose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClick = e => {
|
|
||||||
if (e.key === 'Escape') {
|
|
||||||
this.props.onClose();
|
|
||||||
} else if (!e.key || e.key === 'Enter') {
|
|
||||||
const value = e.currentTarget.getAttribute('data-index');
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
this.props.onClose();
|
|
||||||
this.props.onChange(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount () {
|
|
||||||
document.addEventListener('click', this.handleDocumentClick, false);
|
|
||||||
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount () {
|
|
||||||
document.removeEventListener('click', this.handleDocumentClick, false);
|
|
||||||
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
setRef = c => {
|
|
||||||
this.node = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { style, items, value } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}>
|
|
||||||
{({ opacity, scaleX, scaleY }) => (
|
|
||||||
<div className='privacy-dropdown__dropdown' style={{ ...style, opacity: opacity, transform: `scale(${scaleX}, ${scaleY})` }} ref={this.setRef}>
|
|
||||||
{items.map(item =>
|
|
||||||
<div role='button' tabIndex='0' key={item.value} data-index={item.value} onKeyDown={this.handleClick} onClick={this.handleClick} className={classNames('privacy-dropdown__option', { active: item.value === value })}>
|
|
||||||
<div className='privacy-dropdown__option__icon'>
|
|
||||||
<i className={`fa fa-fw fa-${item.icon}`} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='privacy-dropdown__option__content'>
|
|
||||||
<strong>{item.text}</strong>
|
|
||||||
{item.meta}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Motion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class PrivacyDropdown extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
isUserTouching: PropTypes.func,
|
|
||||||
isModalOpen: PropTypes.bool.isRequired,
|
|
||||||
onModalOpen: PropTypes.func,
|
|
||||||
onModalClose: PropTypes.func,
|
|
||||||
value: PropTypes.string.isRequired,
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
open: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleToggle = () => {
|
|
||||||
if (this.props.isUserTouching()) {
|
|
||||||
if (this.state.open) {
|
|
||||||
this.props.onModalClose();
|
|
||||||
} else {
|
|
||||||
this.props.onModalOpen({
|
|
||||||
actions: this.options.map(option => ({ ...option, active: option.value === this.props.value })),
|
|
||||||
onClick: this.handleModalActionClick,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.setState({ open: !this.state.open });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleModalActionClick = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const { value } = this.options[e.currentTarget.getAttribute('data-index')];
|
|
||||||
|
|
||||||
this.props.onModalClose();
|
|
||||||
this.props.onChange(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleKeyDown = e => {
|
|
||||||
switch(e.key) {
|
|
||||||
case 'Enter':
|
|
||||||
this.handleToggle();
|
|
||||||
break;
|
|
||||||
case 'Escape':
|
|
||||||
this.handleClose();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClose = () => {
|
|
||||||
this.setState({ open: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleChange = value => {
|
|
||||||
this.props.onChange(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillMount () {
|
|
||||||
const { intl: { formatMessage } } = this.props;
|
|
||||||
|
|
||||||
this.options = [
|
|
||||||
{ icon: 'globe', value: 'public', text: formatMessage(messages.public_short), meta: formatMessage(messages.public_long) },
|
|
||||||
{ icon: 'unlock-alt', value: 'unlisted', text: formatMessage(messages.unlisted_short), meta: formatMessage(messages.unlisted_long) },
|
|
||||||
{ icon: 'lock', value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) },
|
|
||||||
{ icon: 'envelope', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { value, intl } = this.props;
|
|
||||||
const { open } = this.state;
|
|
||||||
|
|
||||||
const valueOption = this.options.find(item => item.value === value);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={classNames('privacy-dropdown', { active: open })} onKeyDown={this.handleKeyDown}>
|
|
||||||
<div className={classNames('privacy-dropdown__value', { active: this.options.indexOf(valueOption) === 0 })}>
|
|
||||||
<IconButton
|
|
||||||
className='privacy-dropdown__value-icon'
|
|
||||||
icon={valueOption.icon}
|
|
||||||
title={intl.formatMessage(messages.change_privacy)}
|
|
||||||
size={18}
|
|
||||||
expanded={open}
|
|
||||||
active={open}
|
|
||||||
inverted
|
|
||||||
onClick={this.handleToggle}
|
|
||||||
style={{ height: null, lineHeight: '27px' }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Overlay show={open} placement='bottom' target={this}>
|
|
||||||
<PrivacyDropdownMenu
|
|
||||||
items={this.options}
|
|
||||||
value={value}
|
|
||||||
onClose={this.handleClose}
|
|
||||||
onChange={this.handleChange}
|
|
||||||
/>
|
|
||||||
</Overlay>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Avatar from 'flavours/glitch/components/avatar';
|
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
|
||||||
import DisplayName from 'flavours/glitch/components/display_name';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class ReplyIndicator extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static contextTypes = {
|
|
||||||
router: PropTypes.object,
|
|
||||||
};
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
status: ImmutablePropTypes.map,
|
|
||||||
onCancel: PropTypes.func.isRequired,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleClick = () => {
|
|
||||||
this.props.onCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleAccountClick = (e) => {
|
|
||||||
if (e.button === 0) {
|
|
||||||
e.preventDefault();
|
|
||||||
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { status, intl } = this.props;
|
|
||||||
|
|
||||||
if (!status) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = { __html: status.get('contentHtml') };
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='reply-indicator'>
|
|
||||||
<div className='reply-indicator__header'>
|
|
||||||
<div className='reply-indicator__cancel'><IconButton title={intl.formatMessage(messages.cancel)} icon='times' onClick={this.handleClick} /></div>
|
|
||||||
|
|
||||||
<a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='reply-indicator__display-name'>
|
|
||||||
<div className='reply-indicator__display-avatar'><Avatar account={status.get('account')} size={24} /></div>
|
|
||||||
<DisplayName account={status.get('account')} />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='reply-indicator__content' dangerouslySetInnerHTML={content} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
||||||
import Overlay from 'react-overlays/lib/Overlay';
|
|
||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
placeholder: { id: 'search.placeholder', defaultMessage: 'Search' },
|
|
||||||
});
|
|
||||||
|
|
||||||
class SearchPopout extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
style: PropTypes.object,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { style } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ ...style, position: 'absolute', width: 285 }}>
|
|
||||||
<Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}>
|
|
||||||
{({ opacity, scaleX, scaleY }) => (
|
|
||||||
<div className='search-popout' style={{ opacity: opacity, transform: `scale(${scaleX}, ${scaleY})` }}>
|
|
||||||
<h4><FormattedMessage id='search_popout.search_format' defaultMessage='Advanced search format' /></h4>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><em>#example</em> <FormattedMessage id='search_popout.tips.hashtag' defaultMessage='hashtag' /></li>
|
|
||||||
<li><em>@username@domain</em> <FormattedMessage id='search_popout.tips.user' defaultMessage='user' /></li>
|
|
||||||
<li><em>URL</em> <FormattedMessage id='search_popout.tips.user' defaultMessage='user' /></li>
|
|
||||||
<li><em>URL</em> <FormattedMessage id='search_popout.tips.status' defaultMessage='status' /></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<FormattedMessage id='search_popout.tips.text' defaultMessage='Simple text returns matching display names, usernames and hashtags' />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Motion>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class Search extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
value: PropTypes.string.isRequired,
|
|
||||||
submitted: PropTypes.bool,
|
|
||||||
onChange: PropTypes.func.isRequired,
|
|
||||||
onSubmit: PropTypes.func.isRequired,
|
|
||||||
onClear: PropTypes.func.isRequired,
|
|
||||||
onShow: PropTypes.func.isRequired,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
expanded: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleChange = (e) => {
|
|
||||||
this.props.onChange(e.target.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClear = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (this.props.value.length > 0 || this.props.submitted) {
|
|
||||||
this.props.onClear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleKeyDown = (e) => {
|
|
||||||
if (e.key === 'Enter') {
|
|
||||||
e.preventDefault();
|
|
||||||
this.props.onSubmit();
|
|
||||||
} else if (e.key === 'Escape') {
|
|
||||||
document.querySelector('.ui').parentElement.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
noop () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
handleFocus = () => {
|
|
||||||
this.setState({ expanded: true });
|
|
||||||
this.props.onShow();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleBlur = () => {
|
|
||||||
this.setState({ expanded: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, value, submitted } = this.props;
|
|
||||||
const { expanded } = this.state;
|
|
||||||
const hasValue = value.length > 0 || submitted;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='search'>
|
|
||||||
<label>
|
|
||||||
<span style={{ display: 'none' }}>{intl.formatMessage(messages.placeholder)}</span>
|
|
||||||
<input
|
|
||||||
className='search__input'
|
|
||||||
type='text'
|
|
||||||
placeholder={intl.formatMessage(messages.placeholder)}
|
|
||||||
value={value}
|
|
||||||
onChange={this.handleChange}
|
|
||||||
onKeyUp={this.handleKeyDown}
|
|
||||||
onFocus={this.handleFocus}
|
|
||||||
onBlur={this.handleBlur}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div role='button' tabIndex='0' className='search__icon' onClick={this.handleClear}>
|
|
||||||
<i className={`fa fa-search ${hasValue ? '' : 'active'}`} />
|
|
||||||
<i aria-label={intl.formatMessage(messages.placeholder)} className={`fa fa-times-circle ${hasValue ? 'active' : ''}`} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Overlay show={expanded && !hasValue} placement='bottom' target={this}>
|
|
||||||
<SearchPopout />
|
|
||||||
</Overlay>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
import AccountContainer from 'flavours/glitch/containers/account_container';
|
|
||||||
import StatusContainer from 'flavours/glitch/containers/status_container';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
|
|
||||||
export default class SearchResults extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
results: ImmutablePropTypes.map.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { results } = this.props;
|
|
||||||
|
|
||||||
let accounts, statuses, hashtags;
|
|
||||||
let count = 0;
|
|
||||||
|
|
||||||
if (results.get('accounts') && results.get('accounts').size > 0) {
|
|
||||||
count += results.get('accounts').size;
|
|
||||||
accounts = (
|
|
||||||
<div className='search-results__section'>
|
|
||||||
{results.get('accounts').map(accountId => <AccountContainer key={accountId} id={accountId} />)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.get('statuses') && results.get('statuses').size > 0) {
|
|
||||||
count += results.get('statuses').size;
|
|
||||||
statuses = (
|
|
||||||
<div className='search-results__section'>
|
|
||||||
{results.get('statuses').map(statusId => <StatusContainer key={statusId} id={statusId} />)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.get('hashtags') && results.get('hashtags').size > 0) {
|
|
||||||
count += results.get('hashtags').size;
|
|
||||||
hashtags = (
|
|
||||||
<div className='search-results__section'>
|
|
||||||
{results.get('hashtags').map(hashtag =>
|
|
||||||
<Link key={hashtag} className='search-results__hashtag' to={`/timelines/tag/${hashtag}`}>
|
|
||||||
#{hashtag}
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='search-results'>
|
|
||||||
<div className='search-results__header'>
|
|
||||||
<FormattedMessage id='search_results.total' defaultMessage='{count, number} {count, plural, one {result} other {results}}' values={{ count }} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{accounts}
|
|
||||||
{statuses}
|
|
||||||
{hashtags}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
|
||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
undo: { id: 'upload_form.undo', defaultMessage: 'Undo' },
|
|
||||||
description: { id: 'upload_form.description', defaultMessage: 'Describe for the visually impaired' },
|
|
||||||
});
|
|
||||||
|
|
||||||
@injectIntl
|
|
||||||
export default class Upload extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
media: ImmutablePropTypes.map.isRequired,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
onUndo: PropTypes.func.isRequired,
|
|
||||||
onDescriptionChange: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
state = {
|
|
||||||
hovered: false,
|
|
||||||
focused: false,
|
|
||||||
dirtyDescription: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleUndoClick = () => {
|
|
||||||
this.props.onUndo(this.props.media.get('id'));
|
|
||||||
}
|
|
||||||
|
|
||||||
handleInputChange = e => {
|
|
||||||
this.setState({ dirtyDescription: e.target.value });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleMouseEnter = () => {
|
|
||||||
this.setState({ hovered: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleMouseLeave = () => {
|
|
||||||
this.setState({ hovered: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleInputFocus = () => {
|
|
||||||
this.setState({ focused: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleInputBlur = () => {
|
|
||||||
const { dirtyDescription } = this.state;
|
|
||||||
|
|
||||||
this.setState({ focused: false, dirtyDescription: null });
|
|
||||||
|
|
||||||
if (dirtyDescription !== null) {
|
|
||||||
this.props.onDescriptionChange(this.props.media.get('id'), dirtyDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { intl, media } = this.props;
|
|
||||||
const active = this.state.hovered || this.state.focused;
|
|
||||||
const description = this.state.dirtyDescription || media.get('description') || '';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='compose-form__upload' onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
|
|
||||||
<Motion defaultStyle={{ scale: 0.8 }} style={{ scale: spring(1, { stiffness: 180, damping: 12 }) }}>
|
|
||||||
{({ scale }) => (
|
|
||||||
<div className='compose-form__upload-thumbnail' style={{ transform: `scale(${scale})`, backgroundImage: `url(${media.get('preview_url')})` }}>
|
|
||||||
<IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.handleUndoClick} />
|
|
||||||
|
|
||||||
<div className={classNames('compose-form__upload-description', { active })}>
|
|
||||||
<label>
|
|
||||||
<span style={{ display: 'none' }}>{intl.formatMessage(messages.description)}</span>
|
|
||||||
|
|
||||||
<input
|
|
||||||
placeholder={intl.formatMessage(messages.description)}
|
|
||||||
type='text'
|
|
||||||
value={description}
|
|
||||||
maxLength={420}
|
|
||||||
onFocus={this.handleInputFocus}
|
|
||||||
onChange={this.handleInputChange}
|
|
||||||
onBlur={this.handleInputBlur}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Motion>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
upload: { id: 'upload_button.label', defaultMessage: 'Add media' },
|
|
||||||
});
|
|
||||||
|
|
||||||
const makeMapStateToProps = () => {
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']),
|
|
||||||
});
|
|
||||||
|
|
||||||
return mapStateToProps;
|
|
||||||
};
|
|
||||||
|
|
||||||
const iconStyle = {
|
|
||||||
height: null,
|
|
||||||
lineHeight: '27px',
|
|
||||||
};
|
|
||||||
|
|
||||||
@connect(makeMapStateToProps)
|
|
||||||
@injectIntl
|
|
||||||
export default class UploadButton extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
onSelectFile: PropTypes.func.isRequired,
|
|
||||||
style: PropTypes.object,
|
|
||||||
resetFileKey: PropTypes.number,
|
|
||||||
acceptContentTypes: ImmutablePropTypes.listOf(PropTypes.string).isRequired,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleChange = (e) => {
|
|
||||||
if (e.target.files.length > 0) {
|
|
||||||
this.props.onSelectFile(e.target.files);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClick = () => {
|
|
||||||
this.fileElement.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
setRef = (c) => {
|
|
||||||
this.fileElement = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
|
|
||||||
const { intl, resetFileKey, disabled, acceptContentTypes } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='compose-form__upload-button'>
|
|
||||||
<IconButton icon='camera' title={intl.formatMessage(messages.upload)} disabled={disabled} onClick={this.handleClick} className='compose-form__upload-button-icon' size={18} inverted style={iconStyle} />
|
|
||||||
<label>
|
|
||||||
<span style={{ display: 'none' }}>{intl.formatMessage(messages.upload)}</span>
|
|
||||||
<input
|
|
||||||
key={resetFileKey}
|
|
||||||
ref={this.setRef}
|
|
||||||
type='file'
|
|
||||||
multiple={false}
|
|
||||||
accept={acceptContentTypes.toArray().join(',')}
|
|
||||||
onChange={this.handleChange}
|
|
||||||
disabled={disabled}
|
|
||||||
style={{ display: 'none' }}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
||||||
import UploadProgressContainer from '../containers/upload_progress_container';
|
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
||||||
import UploadContainer from '../containers/upload_container';
|
|
||||||
|
|
||||||
export default class UploadForm extends ImmutablePureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
mediaIds: ImmutablePropTypes.list.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { mediaIds } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='compose-form__upload-wrapper'>
|
|
||||||
<UploadProgressContainer />
|
|
||||||
|
|
||||||
<div className='compose-form__uploads-wrapper'>
|
|
||||||
{mediaIds.map(id => (
|
|
||||||
<UploadContainer id={id} key={id} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
|
|
||||||
export default class UploadProgress extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
active: PropTypes.bool,
|
|
||||||
progress: PropTypes.number,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { active, progress } = this.props;
|
|
||||||
|
|
||||||
if (!active) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='upload-progress'>
|
|
||||||
<div className='upload-progress__icon'>
|
|
||||||
<i className='fa fa-upload' />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='upload-progress__message'>
|
|
||||||
<FormattedMessage id='upload_progress.label' defaultMessage='Uploading...' />
|
|
||||||
|
|
||||||
<div className='upload-progress__backdrop'>
|
|
||||||
<Motion defaultStyle={{ width: 0 }} style={{ width: spring(progress) }}>
|
|
||||||
{({ width }) =>
|
|
||||||
<div className='upload-progress__tracker' style={{ width: `${width}%` }} />
|
|
||||||
}
|
|
||||||
</Motion>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
|
|
||||||
export default class Warning extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
message: PropTypes.node.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { message } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}>
|
|
||||||
{({ opacity, scaleX, scaleY }) => (
|
|
||||||
<div className='compose-form__warning' style={{ opacity: opacity, transform: `scale(${scaleX}, ${scaleY})` }}>
|
|
||||||
{message}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Motion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
// Package imports.
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// Our imports.
|
|
||||||
import { toggleComposeAdvancedOption } from 'flavours/glitch/actions/compose';
|
|
||||||
import ComposeAdvancedOptions from '../components/advanced_options';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
values: state.getIn(['compose', 'advanced_options']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onChange (option) {
|
|
||||||
dispatch(toggleComposeAdvancedOption(option));
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(ComposeAdvancedOptions);
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import AutosuggestAccount from '../components/autosuggest_account';
|
|
||||||
import { makeGetAccount } from 'flavours/glitch/selectors';
|
|
||||||
|
|
||||||
const makeMapStateToProps = () => {
|
|
||||||
const getAccount = makeGetAccount();
|
|
||||||
|
|
||||||
const mapStateToProps = (state, { id }) => ({
|
|
||||||
account: getAccount(state, id),
|
|
||||||
});
|
|
||||||
|
|
||||||
return mapStateToProps;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(makeMapStateToProps)(AutosuggestAccount);
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import ComposeForm from '../components/compose_form';
|
|
||||||
import { changeComposeVisibility, uploadCompose } from 'flavours/glitch/actions/compose';
|
|
||||||
import {
|
|
||||||
changeCompose,
|
|
||||||
submitCompose,
|
|
||||||
clearComposeSuggestions,
|
|
||||||
fetchComposeSuggestions,
|
|
||||||
selectComposeSuggestion,
|
|
||||||
changeComposeSpoilerText,
|
|
||||||
insertEmojiCompose,
|
|
||||||
} from 'flavours/glitch/actions/compose';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
text: state.getIn(['compose', 'text']),
|
|
||||||
suggestion_token: state.getIn(['compose', 'suggestion_token']),
|
|
||||||
suggestions: state.getIn(['compose', 'suggestions']),
|
|
||||||
advanced_options: state.getIn(['compose', 'advanced_options']),
|
|
||||||
spoiler: state.getIn(['compose', 'spoiler']),
|
|
||||||
spoiler_text: state.getIn(['compose', 'spoiler_text']),
|
|
||||||
privacy: state.getIn(['compose', 'privacy']),
|
|
||||||
focusDate: state.getIn(['compose', 'focusDate']),
|
|
||||||
preselectDate: state.getIn(['compose', 'preselectDate']),
|
|
||||||
is_submitting: state.getIn(['compose', 'is_submitting']),
|
|
||||||
is_uploading: state.getIn(['compose', 'is_uploading']),
|
|
||||||
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
|
|
||||||
settings: state.get('local_settings'),
|
|
||||||
filesAttached: state.getIn(['compose', 'media_attachments']).size > 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
|
||||||
|
|
||||||
onChange (text) {
|
|
||||||
dispatch(changeCompose(text));
|
|
||||||
},
|
|
||||||
|
|
||||||
onPrivacyChange (value) {
|
|
||||||
dispatch(changeComposeVisibility(value));
|
|
||||||
},
|
|
||||||
|
|
||||||
onSubmit () {
|
|
||||||
dispatch(submitCompose());
|
|
||||||
},
|
|
||||||
|
|
||||||
onClearSuggestions () {
|
|
||||||
dispatch(clearComposeSuggestions());
|
|
||||||
},
|
|
||||||
|
|
||||||
onFetchSuggestions (token) {
|
|
||||||
dispatch(fetchComposeSuggestions(token));
|
|
||||||
},
|
|
||||||
|
|
||||||
onSuggestionSelected (position, token, accountId) {
|
|
||||||
dispatch(selectComposeSuggestion(position, token, accountId));
|
|
||||||
},
|
|
||||||
|
|
||||||
onChangeSpoilerText (checked) {
|
|
||||||
dispatch(changeComposeSpoilerText(checked));
|
|
||||||
},
|
|
||||||
|
|
||||||
onPaste (files) {
|
|
||||||
dispatch(uploadCompose(files));
|
|
||||||
},
|
|
||||||
|
|
||||||
onPickEmoji (position, data) {
|
|
||||||
dispatch(insertEmojiCompose(position, data));
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import EmojiPickerDropdown from '../components/emoji_picker_dropdown';
|
|
||||||
import { changeSetting } from 'flavours/glitch/actions/settings';
|
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import { Map as ImmutableMap } from 'immutable';
|
|
||||||
import { useEmoji } from 'flavours/glitch/actions/emojis';
|
|
||||||
|
|
||||||
const perLine = 8;
|
|
||||||
const lines = 2;
|
|
||||||
|
|
||||||
const DEFAULTS = [
|
|
||||||
'+1',
|
|
||||||
'grinning',
|
|
||||||
'kissing_heart',
|
|
||||||
'heart_eyes',
|
|
||||||
'laughing',
|
|
||||||
'stuck_out_tongue_winking_eye',
|
|
||||||
'sweat_smile',
|
|
||||||
'joy',
|
|
||||||
'yum',
|
|
||||||
'disappointed',
|
|
||||||
'thinking_face',
|
|
||||||
'weary',
|
|
||||||
'sob',
|
|
||||||
'sunglasses',
|
|
||||||
'heart',
|
|
||||||
'ok_hand',
|
|
||||||
];
|
|
||||||
|
|
||||||
const getFrequentlyUsedEmojis = createSelector([
|
|
||||||
state => state.getIn(['settings', 'frequentlyUsedEmojis'], ImmutableMap()),
|
|
||||||
], emojiCounters => {
|
|
||||||
let emojis = emojiCounters
|
|
||||||
.keySeq()
|
|
||||||
.sort((a, b) => emojiCounters.get(a) - emojiCounters.get(b))
|
|
||||||
.reverse()
|
|
||||||
.slice(0, perLine * lines)
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
if (emojis.length < DEFAULTS.length) {
|
|
||||||
emojis = emojis.concat(DEFAULTS.slice(0, DEFAULTS.length - emojis.length));
|
|
||||||
}
|
|
||||||
|
|
||||||
return emojis;
|
|
||||||
});
|
|
||||||
|
|
||||||
const getCustomEmojis = createSelector([
|
|
||||||
state => state.get('custom_emojis'),
|
|
||||||
], emojis => emojis.filter(e => e.get('visible_in_picker')).sort((a, b) => {
|
|
||||||
const aShort = a.get('shortcode').toLowerCase();
|
|
||||||
const bShort = b.get('shortcode').toLowerCase();
|
|
||||||
|
|
||||||
if (aShort < bShort) {
|
|
||||||
return -1;
|
|
||||||
} else if (aShort > bShort ) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
custom_emojis: getCustomEmojis(state),
|
|
||||||
skinTone: state.getIn(['settings', 'skinTone']),
|
|
||||||
frequentlyUsedEmojis: getFrequentlyUsedEmojis(state),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch, { onPickEmoji }) => ({
|
|
||||||
onSkinTone: skinTone => {
|
|
||||||
dispatch(changeSetting(['skinTone'], skinTone));
|
|
||||||
},
|
|
||||||
|
|
||||||
onPickEmoji: emoji => {
|
|
||||||
dispatch(useEmoji(emoji));
|
|
||||||
|
|
||||||
if (onPickEmoji) {
|
|
||||||
onPickEmoji(emoji);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(EmojiPickerDropdown);
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import NavigationBar from '../components/navigation_bar';
|
|
||||||
import { me } from 'flavours/glitch/util/initial_state';
|
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
|
||||||
return {
|
|
||||||
account: state.getIn(['accounts', me]),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(NavigationBar);
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import PrivacyDropdown from '../components/privacy_dropdown';
|
|
||||||
import { changeComposeVisibility } from 'flavours/glitch/actions/compose';
|
|
||||||
import { openModal, closeModal } from 'flavours/glitch/actions/modal';
|
|
||||||
import { isUserTouching } from 'flavours/glitch/util/is_mobile';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
isModalOpen: state.get('modal').modalType === 'ACTIONS',
|
|
||||||
value: state.getIn(['compose', 'privacy']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onChange (value) {
|
|
||||||
dispatch(changeComposeVisibility(value));
|
|
||||||
},
|
|
||||||
|
|
||||||
isUserTouching,
|
|
||||||
onModalOpen: props => dispatch(openModal('ACTIONS', props)),
|
|
||||||
onModalClose: () => dispatch(closeModal()),
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(PrivacyDropdown);
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import { cancelReplyCompose } from 'flavours/glitch/actions/compose';
|
|
||||||
import { makeGetStatus } from 'flavours/glitch/selectors';
|
|
||||||
import ReplyIndicator from '../components/reply_indicator';
|
|
||||||
|
|
||||||
const makeMapStateToProps = () => {
|
|
||||||
const getStatus = makeGetStatus();
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
status: getStatus(state, state.getIn(['compose', 'in_reply_to'])),
|
|
||||||
});
|
|
||||||
|
|
||||||
return mapStateToProps;
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onCancel () {
|
|
||||||
dispatch(cancelReplyCompose());
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(makeMapStateToProps, mapDispatchToProps)(ReplyIndicator);
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import {
|
|
||||||
changeSearch,
|
|
||||||
clearSearch,
|
|
||||||
submitSearch,
|
|
||||||
showSearch,
|
|
||||||
} from 'flavours/glitch/actions/search';
|
|
||||||
import Search from '../components/search';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
value: state.getIn(['search', 'value']),
|
|
||||||
submitted: state.getIn(['search', 'submitted']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onChange (value) {
|
|
||||||
dispatch(changeSearch(value));
|
|
||||||
},
|
|
||||||
|
|
||||||
onClear () {
|
|
||||||
dispatch(clearSearch());
|
|
||||||
},
|
|
||||||
|
|
||||||
onSubmit () {
|
|
||||||
dispatch(submitSearch());
|
|
||||||
},
|
|
||||||
|
|
||||||
onShow () {
|
|
||||||
dispatch(showSearch());
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(Search);
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import SearchResults from '../components/search_results';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
results: state.getIn(['search', 'results']),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(SearchResults);
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import classNames from 'classnames';
|
|
||||||
import IconButton from 'flavours/glitch/components/icon_button';
|
|
||||||
import { changeComposeSensitivity } from 'flavours/glitch/actions/compose';
|
|
||||||
import Motion from 'flavours/glitch/util/optional_motion';
|
|
||||||
import spring from 'react-motion/lib/spring';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
title: { id: 'compose_form.sensitive', defaultMessage: 'Mark media as sensitive' },
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
visible: state.getIn(['compose', 'media_attachments']).size > 0,
|
|
||||||
active: state.getIn(['compose', 'sensitive']),
|
|
||||||
disabled: state.getIn(['compose', 'spoiler']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onClick () {
|
|
||||||
dispatch(changeComposeSensitivity());
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
class SensitiveButton extends React.PureComponent {
|
|
||||||
|
|
||||||
static propTypes = {
|
|
||||||
visible: PropTypes.bool,
|
|
||||||
active: PropTypes.bool,
|
|
||||||
disabled: PropTypes.bool,
|
|
||||||
onClick: PropTypes.func.isRequired,
|
|
||||||
intl: PropTypes.object.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
render () {
|
|
||||||
const { visible, active, disabled, onClick, intl } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Motion defaultStyle={{ scale: 0.87 }} style={{ scale: spring(visible ? 1 : 0.87, { stiffness: 200, damping: 3 }) }}>
|
|
||||||
{({ scale }) => {
|
|
||||||
const icon = active ? 'eye-slash' : 'eye';
|
|
||||||
const className = classNames('compose-form__sensitive-button', {
|
|
||||||
'compose-form__sensitive-button--visible': visible,
|
|
||||||
});
|
|
||||||
return (
|
|
||||||
<div className={className} style={{ transform: `scale(${scale})` }}>
|
|
||||||
<IconButton
|
|
||||||
className='compose-form__sensitive-button__icon'
|
|
||||||
title={intl.formatMessage(messages.title)}
|
|
||||||
icon={icon}
|
|
||||||
onClick={onClick}
|
|
||||||
size={18}
|
|
||||||
active={active}
|
|
||||||
disabled={disabled}
|
|
||||||
style={{ lineHeight: null, height: null }}
|
|
||||||
inverted
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
</Motion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(SensitiveButton));
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import TextIconButton from '../components/text_icon_button';
|
|
||||||
import { changeComposeSpoilerness } from 'flavours/glitch/actions/compose';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
title: { id: 'compose_form.spoiler', defaultMessage: 'Hide text behind warning' },
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapStateToProps = (state, { intl }) => ({
|
|
||||||
label: 'CW',
|
|
||||||
title: intl.formatMessage(messages.title),
|
|
||||||
active: state.getIn(['compose', 'spoiler']),
|
|
||||||
ariaControls: 'cw-spoiler-input',
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onClick () {
|
|
||||||
dispatch(changeComposeSpoilerness());
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import UploadButton from '../components/upload_button';
|
|
||||||
import { uploadCompose } from 'flavours/glitch/actions/compose';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 3 || state.getIn(['compose', 'media_attachments']).some(m => m.get('type') === 'video')),
|
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onSelectFile (files) {
|
|
||||||
dispatch(uploadCompose(files));
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(UploadButton);
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import Upload from '../components/upload';
|
|
||||||
import { undoUploadCompose, changeUploadCompose } from 'flavours/glitch/actions/compose';
|
|
||||||
|
|
||||||
const mapStateToProps = (state, { id }) => ({
|
|
||||||
media: state.getIn(['compose', 'media_attachments']).find(item => item.get('id') === id),
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
|
||||||
|
|
||||||
onUndo: id => {
|
|
||||||
dispatch(undoUploadCompose(id));
|
|
||||||
},
|
|
||||||
|
|
||||||
onDescriptionChange: (id, description) => {
|
|
||||||
dispatch(changeUploadCompose(id, description));
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(Upload);
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import UploadForm from '../components/upload_form';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
mediaIds: state.getIn(['compose', 'media_attachments']).map(item => item.get('id')),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(UploadForm);
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { connect } from 'react-redux';
|
|
||||||
import UploadProgress from '../components/upload_progress';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
active: state.getIn(['compose', 'is_uploading']),
|
|
||||||
progress: state.getIn(['compose', 'progress']),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(UploadProgress);
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import Warning from '../components/warning';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
import { me } from 'flavours/glitch/util/initial_state';
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']),
|
|
||||||
});
|
|
||||||
|
|
||||||
const WarningWrapper = ({ needsLockWarning }) => {
|
|
||||||
if (needsLockWarning) {
|
|
||||||
return <Warning message={<FormattedMessage id='compose_form.lock_disclaimer' defaultMessage='Your account is not {locked}. Anyone can follow you to view your follower-only posts.' values={{ locked: <a href='/settings/profile'><FormattedMessage id='compose_form.lock_disclaimer.lock' defaultMessage='locked' /></a> }} />} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
WarningWrapper.propTypes = {
|
|
||||||
needsLockWarning: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(WarningWrapper);
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user