kopia lustrzana https://github.com/cheeaun/phanpy
Porównaj commity
885 Commity
2023.10.06
...
main
Autor | SHA1 | Data |
---|---|---|
![]() |
febd04dd54 | |
![]() |
983dd6623f | |
![]() |
a79d0613ec | |
![]() |
c0c7fdd6e1 | |
![]() |
17a3939061 | |
![]() |
8a10a81fec | |
![]() |
17230fc690 | |
![]() |
88e36183c6 | |
![]() |
d0bb0c04db | |
![]() |
42d761e747 | |
![]() |
901725793b | |
![]() |
3fbecb2f0d | |
![]() |
ef1abbc25c | |
![]() |
2f75dfd9e4 | |
![]() |
8d91bfb0a3 | |
![]() |
04e1d60e54 | |
![]() |
1c01e1b0f4 | |
![]() |
dea3507053 | |
![]() |
9b35119f99 | |
![]() |
6d7eddc568 | |
![]() |
dac2af4334 | |
![]() |
2099953b68 | |
![]() |
5931ebb8fc | |
![]() |
adcb87679b | |
![]() |
5ead17a093 | |
![]() |
224cad4d7f | |
![]() |
e08817d611 | |
![]() |
1ffc1c257a | |
![]() |
098014a109 | |
![]() |
7546b42c7c | |
![]() |
f9a73777e7 | |
![]() |
d5584f8dd4 | |
![]() |
563b06e680 | |
![]() |
b6a64b66c7 | |
![]() |
0a4aae51b7 | |
![]() |
d16221e296 | |
![]() |
ed712d15f1 | |
![]() |
bd8817e61b | |
![]() |
ef712c62a9 | |
![]() |
9aa2bac685 | |
![]() |
34077e8467 | |
![]() |
b473061845 | |
![]() |
64c7b5b4f0 | |
![]() |
c11bbbb2b3 | |
![]() |
2c1a6c8cb5 | |
![]() |
67a85e1eef | |
![]() |
2e0ef6494b | |
![]() |
012b86d7ce | |
![]() |
0c45f515f0 | |
![]() |
9cc590be1b | |
![]() |
7589ec8803 | |
![]() |
cd17ca0b42 | |
![]() |
8aab997900 | |
![]() |
96c44ed485 | |
![]() |
7053fcc96a | |
![]() |
ad7cb46547 | |
![]() |
1b1af67064 | |
![]() |
bdd238de0e | |
![]() |
ced4dc86aa | |
![]() |
7be1e589ab | |
![]() |
7da1745cca | |
![]() |
025a5429cc | |
![]() |
62f843b4dc | |
![]() |
b0a53b7fa1 | |
![]() |
9934daeb4d | |
![]() |
d4a0a080b5 | |
![]() |
bc4e3b0f72 | |
![]() |
ac760265da | |
![]() |
98b0ccf032 | |
![]() |
90f06c511a | |
![]() |
e7aad03279 | |
![]() |
1c6b0aa0d7 | |
![]() |
3e1b9ff53d | |
![]() |
5c9a47c31e | |
![]() |
65a4c3441c | |
![]() |
77bc06545c | |
![]() |
11e64a2cc4 | |
![]() |
5433e4e119 | |
![]() |
c8dc32b884 | |
![]() |
1f29aee26e | |
![]() |
daae055f4d | |
![]() |
044f754d7e | |
![]() |
5ae2058c07 | |
![]() |
7376cb1e99 | |
![]() |
ffbae70178 | |
![]() |
9235d2c800 | |
![]() |
6ccefaebe1 | |
![]() |
5a448c8049 | |
![]() |
9bf77fa97a | |
![]() |
b9058c6e3d | |
![]() |
55ad6500bc | |
![]() |
f4b95d254c | |
![]() |
effbe189e1 | |
![]() |
44e910b8c9 | |
![]() |
a68dccd7cf | |
![]() |
9a6364a674 | |
![]() |
e2f39596f0 | |
![]() |
701b9e99b3 | |
![]() |
294ab2bf00 | |
![]() |
304ce5a3e8 | |
![]() |
57390a291b | |
![]() |
cd5920114f | |
![]() |
06c6360cae | |
![]() |
afdfdb86da | |
![]() |
6f8f3e4fd0 | |
![]() |
342ff20986 | |
![]() |
94996d098e | |
![]() |
c286562ee8 | |
![]() |
5babdc9d63 | |
![]() |
260bb8746d | |
![]() |
7be620808f | |
![]() |
df3aca70fa | |
![]() |
ec65163c89 | |
![]() |
6f22ec3842 | |
![]() |
2faf9b4c20 | |
![]() |
501e43207b | |
![]() |
e782cc0dde | |
![]() |
aefda31c2a | |
![]() |
9285a0ba9a | |
![]() |
7fb56d9f6c | |
![]() |
f7c69e56e9 | |
![]() |
c3bcf3d595 | |
![]() |
0efa39b825 | |
![]() |
a0d2037007 | |
![]() |
6e73728e2b | |
![]() |
60920966d6 | |
![]() |
5083463942 | |
![]() |
8b5fee3dfd | |
![]() |
c9124bf150 | |
![]() |
b85174155c | |
![]() |
5c9f6bae3c | |
![]() |
4e5940900e | |
![]() |
7fa0b4f076 | |
![]() |
ecfcc68f15 | |
![]() |
015ed5e7eb | |
![]() |
2ad9706304 | |
![]() |
30382d088b | |
![]() |
80196f83ca | |
![]() |
419ad34250 | |
![]() |
ed0d714cf2 | |
![]() |
708976a9e9 | |
![]() |
d77ba19308 | |
![]() |
b10e22a9a2 | |
![]() |
36d8b62e1e | |
![]() |
989e788d8e | |
![]() |
ebd9f05f69 | |
![]() |
5246af4ae9 | |
![]() |
e6ba72f4c8 | |
![]() |
960dff8b9e | |
![]() |
e3c25d25ee | |
![]() |
090320150a | |
![]() |
7100937e79 | |
![]() |
c18efef7b6 | |
![]() |
ff336628f8 | |
![]() |
28882d98d9 | |
![]() |
f6ad22e58f | |
![]() |
aa664e15f6 | |
![]() |
f2f203c9d8 | |
![]() |
ae0e4a0792 | |
![]() |
4def6eef5a | |
![]() |
1004a5f176 | |
![]() |
2b6beee875 | |
![]() |
e35e02593a | |
![]() |
5e56ba9fb9 | |
![]() |
a7cc0785f9 | |
![]() |
bb5d34c94c | |
![]() |
671d2c9bb1 | |
![]() |
49fa48bd28 | |
![]() |
32fb406629 | |
![]() |
6950698935 | |
![]() |
fd9d8059bc | |
![]() |
3b975e899b | |
![]() |
b1950046d4 | |
![]() |
d2af509eaf | |
![]() |
311160983f | |
![]() |
9d7d5df7f2 | |
![]() |
927430853a | |
![]() |
1692637e22 | |
![]() |
2bc24cc495 | |
![]() |
66e58c74ef | |
![]() |
e3591514a1 | |
![]() |
4abb1aeaed | |
![]() |
7cac17a043 | |
![]() |
7049166b40 | |
![]() |
0a695410d9 | |
![]() |
d671178c02 | |
![]() |
67a05450cf | |
![]() |
438b520970 | |
![]() |
c8c96f08ac | |
![]() |
c9bbca9e11 | |
![]() |
39800e771c | |
![]() |
b1c81f7d71 | |
![]() |
53e9aac14f | |
![]() |
cc268019a0 | |
![]() |
9d16c6c12a | |
![]() |
27a7bc7627 | |
![]() |
1a2914362f | |
![]() |
9c8aff6d32 | |
![]() |
6816a4b64a | |
![]() |
13f5621488 | |
![]() |
fd59a39021 | |
![]() |
c19096ab1b | |
![]() |
0fbc566454 | |
![]() |
f6a9f7807e | |
![]() |
8378d6fc1d | |
![]() |
5ccf8b6842 | |
![]() |
d6b65d0413 | |
![]() |
8eb67f469c | |
![]() |
717633e422 | |
![]() |
f6c2097a89 | |
![]() |
5695b3ca1e | |
![]() |
15c113ecb1 | |
![]() |
4a75d6f172 | |
![]() |
8f43099840 | |
![]() |
a2743f9940 | |
![]() |
4c2210c68b | |
![]() |
da909e4084 | |
![]() |
552ad249e5 | |
![]() |
9a5704ee95 | |
![]() |
c7f68c8971 | |
![]() |
e8219e458d | |
![]() |
6157ee105c | |
![]() |
4718ef36b0 | |
![]() |
2723ef4593 | |
![]() |
d1965a84b5 | |
![]() |
c7762cc56f | |
![]() |
cf05568e0c | |
![]() |
69c47489e3 | |
![]() |
861ad83423 | |
![]() |
cd3ed64e48 | |
![]() |
2e28c147b9 | |
![]() |
fef033b282 | |
![]() |
3dbbba0be2 | |
![]() |
0b8cbbef51 | |
![]() |
f72ec0aba5 | |
![]() |
d63e6c87c4 | |
![]() |
f5ea96a093 | |
![]() |
0e1be5dbdc | |
![]() |
4843970e1b | |
![]() |
a0367f4860 | |
![]() |
687a08b2a4 | |
![]() |
ac07479edd | |
![]() |
306a96eec3 | |
![]() |
061d769901 | |
![]() |
cf1c10b338 | |
![]() |
7f6ef4ff96 | |
![]() |
ce190cbc50 | |
![]() |
e7e4f15234 | |
![]() |
c005745ad0 | |
![]() |
0b81b5bfd2 | |
![]() |
b48d32e503 | |
![]() |
ed309b289f | |
![]() |
ecc5fc5bbe | |
![]() |
7eb77f5d1b | |
![]() |
3f4832965d | |
![]() |
b7ed27ef70 | |
![]() |
c9a48cf482 | |
![]() |
c0ad216227 | |
![]() |
8a9f1a3c25 | |
![]() |
375c4b5d00 | |
![]() |
f522d8e932 | |
![]() |
bd46af6166 | |
![]() |
29e9e15d3f | |
![]() |
42dac0720f | |
![]() |
d348c458b3 | |
![]() |
427207ae5a | |
![]() |
531147cbc3 | |
![]() |
e0c2570875 | |
![]() |
2b2f6c28a9 | |
![]() |
4a9cae9cb6 | |
![]() |
c578b41105 | |
![]() |
cfdbecc608 | |
![]() |
7c81548320 | |
![]() |
8cab77415e | |
![]() |
8b36cef510 | |
![]() |
4e67edac5e | |
![]() |
0bf5ef52ac | |
![]() |
7a7d51f56e | |
![]() |
48e1a0753a | |
![]() |
195c2e2960 | |
![]() |
60c0d1cca0 | |
![]() |
6292557bc9 | |
![]() |
b79ce92aef | |
![]() |
6bb6b9c350 | |
![]() |
0b4c720153 | |
![]() |
02d1339b29 | |
![]() |
93c871353a | |
![]() |
641d22a7cc | |
![]() |
0fd378811f | |
![]() |
afb1f6d520 | |
![]() |
fcb0074f49 | |
![]() |
8108151fb6 | |
![]() |
d8b0adfe97 | |
![]() |
cef4e6373e | |
![]() |
4d138f5773 | |
![]() |
0db10bf7d0 | |
![]() |
7ab6da5e9b | |
![]() |
beed3ca18c | |
![]() |
abd5031602 | |
![]() |
346dba9ed7 | |
![]() |
0ceb6ffd06 | |
![]() |
488aece050 | |
![]() |
ecde88d6a1 | |
![]() |
94dcd1606a | |
![]() |
b479fa1f35 | |
![]() |
ab0472de02 | |
![]() |
1bf8616957 | |
![]() |
631333ba9e | |
![]() |
69d77c368e | |
![]() |
bb3621e424 | |
![]() |
e1447053b3 | |
![]() |
aaf64bbc34 | |
![]() |
52b60fa38b | |
![]() |
3acfc00ec0 | |
![]() |
f8b5e9563c | |
![]() |
6f3f83a620 | |
![]() |
315ce98511 | |
![]() |
3cfc35898b | |
![]() |
ffc216cfed | |
![]() |
35e34c0bc6 | |
![]() |
b023a43fee | |
![]() |
44f6d9cda0 | |
![]() |
c466e0c279 | |
![]() |
fa99debabd | |
![]() |
58778aba45 | |
![]() |
b913c8817d | |
![]() |
ffb7ce1c63 | |
![]() |
707b51a1a0 | |
![]() |
201ca6ce4a | |
![]() |
a419bb9b61 | |
![]() |
a8b5c8cd64 | |
![]() |
a3236ea0f0 | |
![]() |
c595b0ee31 | |
![]() |
89f34d7942 | |
![]() |
f23e4b0dd9 | |
![]() |
e7d2d088ba | |
![]() |
bf609b979e | |
![]() |
6a6162ec6e | |
![]() |
03e5c3ff54 | |
![]() |
d8e824b548 | |
![]() |
e5d36b82bb | |
![]() |
b6721fc58f | |
![]() |
246862e0a4 | |
![]() |
65e048be17 | |
![]() |
cd96ba0c59 | |
![]() |
9803d18185 | |
![]() |
fefc121b11 | |
![]() |
3d08349851 | |
![]() |
1478aca7a5 | |
![]() |
dab0d61ac8 | |
![]() |
14b92f3f98 | |
![]() |
49cdba2652 | |
![]() |
2f94cb34f6 | |
![]() |
b7a79c8fdd | |
![]() |
2f0d04eca4 | |
![]() |
daabd85273 | |
![]() |
c84ad73d0d | |
![]() |
3295b1ab96 | |
![]() |
5d7b67a410 | |
![]() |
4e85f92f4b | |
![]() |
9d80647b11 | |
![]() |
24a481b782 | |
![]() |
97cce8a828 | |
![]() |
3c31c56306 | |
![]() |
92f4371041 | |
![]() |
a9d0100087 | |
![]() |
3fbe11295f | |
![]() |
98f018913d | |
![]() |
60ca577f9b | |
![]() |
1d0d02f39b | |
![]() |
fbd448c152 | |
![]() |
038b2b2e6b | |
![]() |
169aa2d3d3 | |
![]() |
9a9667d824 | |
![]() |
afd9d2cf97 | |
![]() |
b9c287b29e | |
![]() |
436277c6b4 | |
![]() |
4f28d3cc6d | |
![]() |
46415b87a6 | |
![]() |
913d923877 | |
![]() |
36f38230c4 | |
![]() |
a66a4e238e | |
![]() |
aa7fb4441f | |
![]() |
f1dbb9ec42 | |
![]() |
a59668ea9a | |
![]() |
6581bc2881 | |
![]() |
28bb66f185 | |
![]() |
46d7cba1ea | |
![]() |
ff35c458c3 | |
![]() |
26d445af7d | |
![]() |
3470b9adec | |
![]() |
f3d77dd04e | |
![]() |
14f5c37721 | |
![]() |
94c59c47d1 | |
![]() |
a66307b757 | |
![]() |
9792700f30 | |
![]() |
36e852bebb | |
![]() |
6075542071 | |
![]() |
0386357688 | |
![]() |
9cac63c37d | |
![]() |
5cfcfdc98b | |
![]() |
a2d995ec07 | |
![]() |
4ca9a802e3 | |
![]() |
990f2b2e29 | |
![]() |
725da37063 | |
![]() |
1b41d39032 | |
![]() |
23dd7f5a7a | |
![]() |
7d95c50c7a | |
![]() |
a352f94c2c | |
![]() |
38e2b176bc | |
![]() |
6b4c1c8505 | |
![]() |
46dfd9aab0 | |
![]() |
59d0138ca8 | |
![]() |
3fbd5b8622 | |
![]() |
b6c4045cb4 | |
![]() |
37c784dad2 | |
![]() |
04d431cf71 | |
![]() |
97458b66eb | |
![]() |
fadfc6052d | |
![]() |
0ca92e7509 | |
![]() |
b8484eff79 | |
![]() |
1017d1d270 | |
![]() |
04179340f6 | |
![]() |
9b0889fe23 | |
![]() |
79e87b7d89 | |
![]() |
0ebc0fa64c | |
![]() |
35974cc89c | |
![]() |
00675c827f | |
![]() |
2b3f65f28c | |
![]() |
500f877d4b | |
![]() |
4b9ff0ca5b | |
![]() |
07f927d4ff | |
![]() |
8c6563a671 | |
![]() |
ffabd6188d | |
![]() |
d71b1a7e36 | |
![]() |
c47687e2e4 | |
![]() |
5b0d6dd58b | |
![]() |
ecd5c7b91e | |
![]() |
96387c8abb | |
![]() |
35958d429d | |
![]() |
99b0b7c096 | |
![]() |
e44ac16396 | |
![]() |
147a12cbcb | |
![]() |
16e2ac9bce | |
![]() |
1574be2b35 | |
![]() |
7223baaaad | |
![]() |
9cffd429b0 | |
![]() |
9a5d749b8d | |
![]() |
e43f2283dd | |
![]() |
be5fcc35ac | |
![]() |
54314de976 | |
![]() |
bc2886f7e2 | |
![]() |
2bc1b8387e | |
![]() |
3989b218d0 | |
![]() |
a8331375ba | |
![]() |
6919975c6d | |
![]() |
c0987209a8 | |
![]() |
d25c2df392 | |
![]() |
848433365d | |
![]() |
3d4ebb8abe | |
![]() |
72dc4cc81b | |
![]() |
92c0a8b4f0 | |
![]() |
1adcca5666 | |
![]() |
b4d4c61128 | |
![]() |
764125e6b9 | |
![]() |
098df0ad2c | |
![]() |
e41e49884f | |
![]() |
852f7090f6 | |
![]() |
d54511aa10 | |
![]() |
d8ceb03d74 | |
![]() |
df393ae959 | |
![]() |
0ebbc5b34e | |
![]() |
cf52e0776e | |
![]() |
b168707c14 | |
![]() |
d2fb86036c | |
![]() |
62c8a51307 | |
![]() |
f056d7407a | |
![]() |
c3e40297e0 | |
![]() |
d6099df51b | |
![]() |
096bc69584 | |
![]() |
32d32b72f4 | |
![]() |
796b365fd8 | |
![]() |
bd38122f1b | |
![]() |
d7d838ebf8 | |
![]() |
de3787209e | |
![]() |
6500be2782 | |
![]() |
2240380f68 | |
![]() |
f21a65da9a | |
![]() |
a97478097b | |
![]() |
71d2db31e0 | |
![]() |
88547fa403 | |
![]() |
1765defa56 | |
![]() |
437d721c26 | |
![]() |
e13a2feec8 | |
![]() |
39bcb01894 | |
![]() |
7fb0044471 | |
![]() |
f645815b84 | |
![]() |
f5b1b924a5 | |
![]() |
fe54eb11a7 | |
![]() |
cfe41cb802 | |
![]() |
53b1755e51 | |
![]() |
ef8dda2dbb | |
![]() |
66a519f4dc | |
![]() |
ce6d14fa04 | |
![]() |
bc5a4eaf3c | |
![]() |
b89463d412 | |
![]() |
72c5411347 | |
![]() |
d59ee9169f | |
![]() |
3a3858bd72 | |
![]() |
69571bf817 | |
![]() |
a539cfea0a | |
![]() |
976f0a5592 | |
![]() |
f520e30858 | |
![]() |
563a7bf03b | |
![]() |
ae57d95045 | |
![]() |
2923c23672 | |
![]() |
7cfa839e1c | |
![]() |
94075086ce | |
![]() |
60fdd3f522 | |
![]() |
6dd54633e0 | |
![]() |
088d795595 | |
![]() |
c54a15de11 | |
![]() |
8ca768b957 | |
![]() |
6703b27bfb | |
![]() |
3cab36f24c | |
![]() |
30403f835c | |
![]() |
486a707f49 | |
![]() |
5d95d602a7 | |
![]() |
b00033129f | |
![]() |
768477ea6c | |
![]() |
da58336285 | |
![]() |
6bcee318e4 | |
![]() |
49fd8a5dc9 | |
![]() |
5f48f92c11 | |
![]() |
3e4e4d179b | |
![]() |
92d6fe7ebe | |
![]() |
33b55c937b | |
![]() |
cdc19f83b0 | |
![]() |
22b9a33d64 | |
![]() |
c1fe8c2b0e | |
![]() |
a2189bf44b | |
![]() |
ccecc16a2c | |
![]() |
7b246fc660 | |
![]() |
dfe727b702 | |
![]() |
bee32cc781 | |
![]() |
9983c8086c | |
![]() |
8ce720f305 | |
![]() |
c16532d4c2 | |
![]() |
ac60890c9a | |
![]() |
ec4320d53e | |
![]() |
4c7c518d4d | |
![]() |
86a362c619 | |
![]() |
4344a4fa82 | |
![]() |
2921d098b3 | |
![]() |
fede3b5f0c | |
![]() |
e0c2e41755 | |
![]() |
df16cabec5 | |
![]() |
60e86c1eaf | |
![]() |
2eea5ae053 | |
![]() |
aa8cbe046c | |
![]() |
b34ef09411 | |
![]() |
9985ffa5b2 | |
![]() |
5ac0d413cb | |
![]() |
aefbfd59e5 | |
![]() |
5fef0b3fb5 | |
![]() |
f213a8e094 | |
![]() |
82195a8db0 | |
![]() |
a9c624dc59 | |
![]() |
71454d40a9 | |
![]() |
433d8b3bcc | |
![]() |
7dd0b0a4fb | |
![]() |
a039f84c9d | |
![]() |
ceb92a4bfc | |
![]() |
8009a8d743 | |
![]() |
5be3e22467 | |
![]() |
94c2f43c38 | |
![]() |
92a109d25e | |
![]() |
66746eb579 | |
![]() |
222786f202 | |
![]() |
99b4842586 | |
![]() |
2563b23a31 | |
![]() |
ac05fabf05 | |
![]() |
902149e9a7 | |
![]() |
f7e755d0f0 | |
![]() |
cbb7378601 | |
![]() |
012e944a53 | |
![]() |
f98306ed18 | |
![]() |
810596b7cf | |
![]() |
2ad72a667d | |
![]() |
bfcb314324 | |
![]() |
d1bfbf1ef2 | |
![]() |
34e2fe320d | |
![]() |
af503ac865 | |
![]() |
89fb1bbc07 | |
![]() |
d27de2337a | |
![]() |
910b72ba8c | |
![]() |
cbf4ea5060 | |
![]() |
a579f27d55 | |
![]() |
4f41646000 | |
![]() |
7019c09e5b | |
![]() |
1422c5da33 | |
![]() |
25e13144a3 | |
![]() |
b7a0d4fe28 | |
![]() |
7967194b89 | |
![]() |
4b617b7b9a | |
![]() |
b74f6b3168 | |
![]() |
6553ae0b6e | |
![]() |
b22e7c06a7 | |
![]() |
fecebc24a8 | |
![]() |
b269d9d660 | |
![]() |
1383296861 | |
![]() |
eb203a0498 | |
![]() |
85bdaace58 | |
![]() |
d0e0248dd6 | |
![]() |
d87f60665a | |
![]() |
19ed85f298 | |
![]() |
d6afb473ee | |
![]() |
fc842e776e | |
![]() |
7248095a92 | |
![]() |
e049539b91 | |
![]() |
770f4d9205 | |
![]() |
3a326194ad | |
![]() |
911ee288df | |
![]() |
91f6efe736 | |
![]() |
b40357c54e | |
![]() |
97188391df | |
![]() |
82a9a7212d | |
![]() |
dc2eb1163f | |
![]() |
469ce0df6b | |
![]() |
1dc397c066 | |
![]() |
1882338078 | |
![]() |
51ddf9b030 | |
![]() |
98d1f44244 | |
![]() |
d16cd501d4 | |
![]() |
6d5b2ef9a6 | |
![]() |
a1b0d6e3bd | |
![]() |
a8cf7879a2 | |
![]() |
b027967168 | |
![]() |
bca205182e | |
![]() |
ea660f9146 | |
![]() |
8f34d98f47 | |
![]() |
180466160b | |
![]() |
90df455d6e | |
![]() |
6e3494488a | |
![]() |
f73a942b61 | |
![]() |
8d41ff6884 | |
![]() |
540b9a15a4 | |
![]() |
678fc100c8 | |
![]() |
305710fa8c | |
![]() |
83bdc82049 | |
![]() |
7c8d310ed9 | |
![]() |
5a4f1fb686 | |
![]() |
b461823d60 | |
![]() |
986187141e | |
![]() |
d0890e3633 | |
![]() |
42df8e62c5 | |
![]() |
87d0b86ecb | |
![]() |
e5d5025299 | |
![]() |
2c6d18bcfc | |
![]() |
9f31cc8e07 | |
![]() |
660cbebbc4 | |
![]() |
f8674963b3 | |
![]() |
fbfb5e5441 | |
![]() |
5038e1988d | |
![]() |
5f50df1721 | |
![]() |
7ad6151637 | |
![]() |
8c8ff72e53 | |
![]() |
e42d660756 | |
![]() |
674e1fd1ff | |
![]() |
44ffd69941 | |
![]() |
21007e0a4d | |
![]() |
a53be08b3a | |
![]() |
8e341ff7ed | |
![]() |
e0cf2e22fd | |
![]() |
f726f47fcb | |
![]() |
dc1452ab30 | |
![]() |
1f039a4d73 | |
![]() |
0bc1b598c3 | |
![]() |
1cdc4ebbe8 | |
![]() |
e1434e15d9 | |
![]() |
bd798865d8 | |
![]() |
fa9e0059c0 | |
![]() |
89f82707d6 | |
![]() |
7f327e5980 | |
![]() |
05ab42684b | |
![]() |
131b91e2c1 | |
![]() |
490d776a70 | |
![]() |
6b3602c6ae | |
![]() |
ab5a115084 | |
![]() |
fd7caca039 | |
![]() |
48b505b382 | |
![]() |
0c2d79c159 | |
![]() |
93e19f549d | |
![]() |
38ee094405 | |
![]() |
a9c3c6fdb4 | |
![]() |
bf7acb6eab | |
![]() |
030728bc93 | |
![]() |
706f3f0cc8 | |
![]() |
d9dab6b5ee | |
![]() |
d35d0cbe18 | |
![]() |
ff7db6212d | |
![]() |
0c3449aba4 | |
![]() |
3361ffc366 | |
![]() |
616b9fcf02 | |
![]() |
7119a78711 | |
![]() |
33f807de73 | |
![]() |
caeeffaa72 | |
![]() |
ecb1be5776 | |
![]() |
0cc956b8c0 | |
![]() |
e6ef2f9064 | |
![]() |
478271348e | |
![]() |
6ec7073151 | |
![]() |
22abc2fb31 | |
![]() |
bc0197a5f1 | |
![]() |
f3dcd9f4ee | |
![]() |
f5808b6f3b | |
![]() |
5cb0621f34 | |
![]() |
3f6402349c | |
![]() |
b17977a5c7 | |
![]() |
afb80d3dc6 | |
![]() |
1f78bb9c09 | |
![]() |
c67192bb81 | |
![]() |
33b989fffc | |
![]() |
39d97a51c5 | |
![]() |
d5b257b130 | |
![]() |
3c790ebff4 | |
![]() |
99f81c49c4 | |
![]() |
5f64553d17 | |
![]() |
75bca8ed3a | |
![]() |
290243df0a | |
![]() |
5fae5d8cf5 | |
![]() |
85f966bfc9 | |
![]() |
3760b52860 | |
![]() |
3092a8bba1 | |
![]() |
146e5d1a7e | |
![]() |
b28d2d590f | |
![]() |
ab29c8c89e | |
![]() |
77312f3fb2 | |
![]() |
b40bbb32c2 | |
![]() |
35f7cae01f | |
![]() |
8180cc357e | |
![]() |
25ff0d7835 | |
![]() |
173728536a | |
![]() |
0599c0d2c9 | |
![]() |
a1021e1aee | |
![]() |
087e282677 | |
![]() |
4efc922b7b | |
![]() |
372e86415b | |
![]() |
6dd6e0e77c | |
![]() |
c022e2fd00 | |
![]() |
713865a094 | |
![]() |
0678366566 | |
![]() |
b6d8c46e2c | |
![]() |
065add5575 | |
![]() |
35dced8eaf | |
![]() |
2310664065 | |
![]() |
8858ce3e89 | |
![]() |
1c87dd6e41 | |
![]() |
0038c2225b | |
![]() |
c35f4bb161 | |
![]() |
8426a011b0 | |
![]() |
81644e67bb | |
![]() |
c03f39b10c | |
![]() |
a1b81562db | |
![]() |
c82ccf5957 | |
![]() |
8ee1c3a2e3 | |
![]() |
5d5ab906ba | |
![]() |
3a32cbf974 | |
![]() |
b9afe4fb66 | |
![]() |
a192554b8b | |
![]() |
c2ba149563 | |
![]() |
44a20b42a7 | |
![]() |
163ef4ce91 | |
![]() |
beff01c976 | |
![]() |
f19326528b | |
![]() |
05ee27e045 | |
![]() |
576dcf7701 | |
![]() |
0247c041f2 | |
![]() |
7555bda8e9 | |
![]() |
61756fac1d | |
![]() |
4897847601 | |
![]() |
8bf3f31056 | |
![]() |
f2c2983663 | |
![]() |
2c4dd0cdb7 | |
![]() |
58d36d2403 | |
![]() |
72842c663a | |
![]() |
8d694ecf1b | |
![]() |
cafadd0980 | |
![]() |
3a1341fb17 | |
![]() |
ced30a9602 | |
![]() |
4e53b1e17f | |
![]() |
1c5453cfb6 | |
![]() |
e7ef20f265 | |
![]() |
9c4252315a | |
![]() |
2149c4c35a | |
![]() |
18b00f7b28 | |
![]() |
a6cdd0a01a | |
![]() |
ddc8c1e9d9 | |
![]() |
0d4303861a | |
![]() |
a222828306 | |
![]() |
5850485207 | |
![]() |
839647bee7 | |
![]() |
749d6880b8 | |
![]() |
5a616633c6 | |
![]() |
47c2efacfb | |
![]() |
4c4e89ac9d | |
![]() |
4da968df2e | |
![]() |
c6f368ac0b | |
![]() |
87e243ea58 | |
![]() |
66f9c3b918 | |
![]() |
137ad7f4dd | |
![]() |
8ddc44fba6 | |
![]() |
3721acf3d3 | |
![]() |
ab7df0f66c | |
![]() |
d1aedcaef2 | |
![]() |
691aea3389 | |
![]() |
72f204771f | |
![]() |
dba921a3fd | |
![]() |
4646859177 | |
![]() |
66fa6fbe52 | |
![]() |
861619ce57 | |
![]() |
71bf8608e6 | |
![]() |
2916d1146b | |
![]() |
d62712d587 | |
![]() |
a37c3d6081 | |
![]() |
73e995f494 | |
![]() |
1dc0069cdc | |
![]() |
a5532488aa | |
![]() |
c9545cdc34 | |
![]() |
e9075906f8 | |
![]() |
3339c5c1d6 | |
![]() |
965f948899 | |
![]() |
c0c2bb45fe | |
![]() |
106cd16e41 | |
![]() |
7145c20136 | |
![]() |
e4b6637680 | |
![]() |
cd57e97e2b | |
![]() |
c1588322aa | |
![]() |
3eda1e2267 | |
![]() |
3617bdc9cb | |
![]() |
26cf40dcea | |
![]() |
8ae9131543 | |
![]() |
1b0a77dfae | |
![]() |
e3f58442aa | |
![]() |
119dae29ca | |
![]() |
c538cfeaaa | |
![]() |
e153f9f541 | |
![]() |
42db913b22 | |
![]() |
834b1fe1e1 | |
![]() |
809b7cc2d2 | |
![]() |
673001e4e0 | |
![]() |
54e69ed23b | |
![]() |
7e1bb08b1b | |
![]() |
32b72f9297 | |
![]() |
57dead7960 | |
![]() |
9786752a4f | |
![]() |
ed8c9e994b | |
![]() |
8cf30773ce | |
![]() |
6540dd5642 | |
![]() |
c80c8b3294 | |
![]() |
e1ae89b00e | |
![]() |
f9299ac15c | |
![]() |
df9eeeb0b3 | |
![]() |
32bf258bbf | |
![]() |
f56a44ac97 | |
![]() |
0a7f158b70 | |
![]() |
ab1b34d4d2 | |
![]() |
f2f7b7fe1f | |
![]() |
7264f543bd | |
![]() |
66e4ba4991 | |
![]() |
f6864f96bd | |
![]() |
f67d4fd916 | |
![]() |
cd403fe605 | |
![]() |
5481aa12be | |
![]() |
806ad2c6a2 | |
![]() |
d1b8d737cc | |
![]() |
a095a30500 | |
![]() |
5de7eec2ca | |
![]() |
b8767f3618 | |
![]() |
68759e64d1 | |
![]() |
78a6f13380 | |
![]() |
a697fb04df | |
![]() |
39f7d4e00d | |
![]() |
12d0e6aed8 | |
![]() |
769a5cb099 |
7
.env
7
.env
|
@ -1,3 +1,4 @@
|
|||
VITE_CLIENT_NAME=Phanpy
|
||||
VITE_CLIENT_ID=social.phanpy
|
||||
VITE_WEBSITE=https://phanpy.social
|
||||
PHANPY_CLIENT_NAME=Phanpy
|
||||
PHANPY_WEBSITE=https://phanpy.social
|
||||
PHANPY_LINGVA_INSTANCES="lingva.phanpy.social lingva.lunar.icu lingva.garudalinux.org translate.plausibility.cloud"
|
||||
PHANPY_PRIVACY_POLICY_URL="https://github.com/cheeaun/phanpy/blob/main/PRIVACY.MD"
|
|
@ -10,6 +10,7 @@ assignees: ''
|
|||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
- Which site: [e.g. dev.phanpy.social OR phanpy.social]
|
||||
- Which site version: [On Phanpy, go to Settings -> About]
|
||||
- Which instance: [e.g. mastodon.social]
|
||||
|
||||
**To Reproduce**
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: 'enhancement'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
|
@ -1,4 +1,4 @@
|
|||
name: Auto-create tag on every push to `production`
|
||||
name: Auto-create tag/release on every push to `production`
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -8,9 +8,25 @@ on:
|
|||
jobs:
|
||||
tag:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: production
|
||||
- run: git tag "`date +%Y.%m.%d`.`git rev-parse --short HEAD`" $(git rev-parse HEAD)
|
||||
- run: git push --tags
|
||||
# - run: git tag "`date +%Y.%m.%d`.`git rev-parse --short HEAD`" $(git rev-parse HEAD)
|
||||
# - run: git push --tags
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- run: npm ci && npm run build
|
||||
- run: cd dist && zip -r ../phanpy-dist.zip . && tar -czf ../phanpy-dist.tar.gz . && cd ..
|
||||
- id: tag_name
|
||||
run: echo ::set-output name=tag_name::$(date +%Y.%m.%d).$(git rev-parse --short HEAD)
|
||||
- uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ steps.tag_name.outputs.tag_name }}
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
phanpy-dist.zip
|
||||
phanpy-dist.tar.gz
|
||||
|
|
|
@ -25,4 +25,5 @@ dist-ssr
|
|||
|
||||
# Custom
|
||||
.env.dev
|
||||
src/data/instances-full.json
|
||||
phanpy-dist.zip
|
||||
phanpy-dist.tar.gz
|
|
@ -6,9 +6,9 @@ Phanpy does not collect or process any personal information from its users. The
|
|||
|
||||
Phanpy is hosted on [Cloudflare Pages](https://pages.cloudflare.com/) as a static website. Read more about [Cloudflare's privacy policy](https://www.cloudflare.com/privacypolicy/).
|
||||
|
||||
## Post translations
|
||||
## Translations
|
||||
|
||||
Phanpy uses [Lingva Translate](https://github.com/thedaviddelta/lingva-translate) to translate posts.
|
||||
Phanpy uses [Lingva API](https://github.com/cheeaun/lingva-api) and [Lingva Translate](https://github.com/thedaviddelta/lingva-translate) as fallbacks for translating post content, profile bio and media description.
|
||||
|
||||
## Error logging
|
||||
|
||||
|
|
115
README.md
115
README.md
|
@ -103,16 +103,9 @@ Prerequisites: Node.js 18+
|
|||
- `npm run dev` - Start development server
|
||||
- `npm run build` - Build for production
|
||||
- `npm run preview` - Preview the production build
|
||||
- `npm run fetch-instances` - Fetch instances list from [instances.social](https://instances.social/), save it to `src/data/instances.json`
|
||||
- requires `.env.dev` file with `INSTANCES_SOCIAL_SECRET_TOKEN` variable set
|
||||
- `npm run fetch-instances` - Fetch instances list from [joinmastodon.org/servers](https://joinmastodon.org/servers), save it to `src/data/instances.json`
|
||||
- `npm run sourcemap` - Run `source-map-explorer` on the production build
|
||||
|
||||
## Self-hosting
|
||||
|
||||
This is a **pure static web app**. You can host it anywhere you want. Build it by running `npm run build` (after `npm install`) and serve the `dist` folder.
|
||||
|
||||
Try search for "how to self-host static sites" as there are many ways to do it.
|
||||
|
||||
## Tech stack
|
||||
|
||||
- [Vite](https://vitejs.dev/) - Build tool
|
||||
|
@ -122,10 +115,105 @@ Try search for "how to self-host static sites" as there are many ways to do it.
|
|||
- [masto.js](https://github.com/neet/masto.js/) - Mastodon API client
|
||||
- [Iconify](https://iconify.design/) - Icon library
|
||||
- [MingCute icons](https://www.mingcute.com/)
|
||||
- Vanilla CSS - *Yes, I'm old school.*
|
||||
- Vanilla CSS - _Yes, I'm old school._
|
||||
|
||||
Some of these may change in the future. The front-end world is ever-changing.
|
||||
|
||||
## Self-hosting
|
||||
|
||||
This is a **pure static web app**. You can host it anywhere you want.
|
||||
|
||||
Two ways (choose one):
|
||||
|
||||
### Easy way
|
||||
|
||||
Go to [Releases](https://github.com/cheeaun/phanpy/releases) and download the latest `phanpy-dist.zip` or `phanpy-dist.tar.gz`. It's pre-built so don't need to run any install/build commands. Extract it. Serve the folder of extracted files.
|
||||
|
||||
### Custom-build way
|
||||
|
||||
Requires [Node.js](https://nodejs.org/).
|
||||
|
||||
Download or `git clone` this repository. Use `production` branch for *stable* releases, `main` for *latest*. Build it by running `npm run build` (after `npm install`). Serve the `dist` folder.
|
||||
|
||||
Customization can be done by passing environment variables to the build command. Examples:
|
||||
|
||||
```bash
|
||||
PHANPY_CLIENT_NAME="Phanpy Dev" \
|
||||
PHANPY_WEBSITE="https://dev.phanpy.social" \
|
||||
npm run build
|
||||
```
|
||||
|
||||
```bash
|
||||
PHANPY_DEFAULT_INSTANCE=hachyderm.io \
|
||||
PHANPY_DEFAULT_INSTANCE_REGISTRATION_URL=https://hachyderm.io/auth/sign_up \
|
||||
PHANPY_PRIVACY_POLICY_URL=https://hachyderm.io/privacy-policy \
|
||||
npm run build
|
||||
```
|
||||
|
||||
It's also possible to set them in the `.env` file.
|
||||
|
||||
Available variables:
|
||||
|
||||
- `PHANPY_CLIENT_NAME` (optional, default: `Phanpy`) affects:
|
||||
- Web page title, shown in the browser window or tab title
|
||||
- App title, when installed as PWA, shown in the Home screen, macOS dock, Windows taskbar, etc
|
||||
- OpenGraph card title, when shared on social networks
|
||||
- Client name, when [registering the app for authentication](https://docs.joinmastodon.org/client/token/#app) and shown as client used on posts in some apps/clients
|
||||
- `PHANPY_WEBSITE` (optional but recommended, default: `https://phanpy.social`) affects:
|
||||
- Canonical URL of the website
|
||||
- OpenGraph card URL, when shared on social networks
|
||||
- Root path for the OpenGraph card image
|
||||
- Client URL, when [registering the app for authentication](https://docs.joinmastodon.org/client/token/#app) and shown as client used on posts in some apps/clients
|
||||
- `PHANPY_DEFAULT_INSTANCE` (optional, no defaults):
|
||||
- e.g. 'mastodon.social', without `https://`
|
||||
- Default instance for log-in
|
||||
- When logging in, the user will be redirected instantly to the instance's authentication page instead of having to manually type the instance URL and submit
|
||||
- `PHANPY_DEFAULT_INSTANCE_REGISTRATION_URL` (optional, no defaults):
|
||||
- URL of the instance registration page
|
||||
- E.g. `https://mastodon.social/auth/sign_up`
|
||||
- `PHANPY_PRIVACY_POLICY_URL` (optional, default to official instance's privacy policy):
|
||||
- URL of the privacy policy page
|
||||
- May specify the instance's own privacy policy
|
||||
- `PHANPY_LINGVA_INSTANCES` (optional, space-separated list, default: `lingva.phanpy.social [...hard-coded list of fallback instances]`):
|
||||
- Specify a space-separated list of instances. First will be used as default before falling back to the subsequent instances. If there's only 1 instance, means no fallback.
|
||||
- May specify a self-hosted Lingva instance, powered by either [lingva-translate](https://github.com/thedaviddelta/lingva-translate) or [lingva-api](https://github.com/cheeaun/lingva-api)
|
||||
- List of fallback instances hard-coded in `/.env`
|
||||
- [↗️ List of lingva-translate instances](https://github.com/thedaviddelta/lingva-translate?tab=readme-ov-file#instances)
|
||||
- `PHANPY_IMG_ALT_API_URL` (optional, no defaults):
|
||||
- API endpoint for self-hosted instance of [img-alt-api](https://github.com/cheeaun/img-alt-api).
|
||||
- If provided, a setting will appear for users to enable the image description generator in the composer. Disabled by default.
|
||||
- `PHANPY_GIPHY_API_KEY` (optional, no defaults):
|
||||
- API key for [GIPHY](https://developers.giphy.com/). See [API docs](https://developers.giphy.com/docs/api/).
|
||||
- If provided, a setting will appear for users to enable the GIF picker in the composer. Disabled by default.
|
||||
- This is not self-hosted.
|
||||
|
||||
### Static site hosting
|
||||
|
||||
Try online search for "how to self-host static sites" as there are many ways to do it.
|
||||
|
||||
#### Lingva-translate or lingva-api hosting
|
||||
|
||||
See documentation for [lingva-translate](https://github.com/thedaviddelta/lingva-translate) or [lingva-api](https://github.com/cheeaun/lingva-api).
|
||||
|
||||
## Community deployments
|
||||
|
||||
These are self-hosted by other wonderful folks.
|
||||
|
||||
- [ferengi.one](https://m.ferengi.one/) by [@david@collantes.social](https://collantes.social/@david)
|
||||
- [phanpy.blaede.family](https://phanpy.blaede.family/) by [@cassidy@blaede.family](https://mastodon.blaede.family/@cassidy)
|
||||
- [phanpy.mstdn.mx](https://phanpy.mstdn.mx/) by [@maop@mstdn.mx](https://mstdn.mx/@maop)
|
||||
- [phanpy.vmst.io](https://phanpy.vmst.io/) by [@vmstan@vmst.io](https://vmst.io/@vmstan)
|
||||
- [phanpy.gotosocial.social](https://phanpy.gotosocial.social/) by [@admin@gotosocial.social](https://gotosocial.social/@admin)
|
||||
- [phanpy.bauxite.tech](https://phanpy.bauxite.tech) by [@b4ux1t3@hachyderm.io](https://hachyderm.io/@b4ux1t3)
|
||||
- [phanpy.hear-me.social](https://phanpy.hear-me.social) by [@admin@hear-me.social](https://hear-me.social/@admin)
|
||||
- [phanpy.fulda.social](https://phanpy.fulda.social) by [@Ganneff@fulda.social](https://fulda.social/@Ganneff)
|
||||
- [phanpy.crmbl.uk](https://phanpy.crmbl.uk) by [@snail@crmbl.uk](https://mstdn.crmbl.uk/@snail)
|
||||
- [halo.mookiesplace.com](https://halo.mookiesplace.com) by [@mookie@mookiesplace.com](https://mookiesplace.com/@mookie)
|
||||
- [social.qrk.one](https://social.qrk.one) by [@kev@fosstodon.org](https://fosstodon.org/@kev)
|
||||
- [phanpy.cz](https://phanpy.cz) by [@zdendys@mamutovo.cz](https://mamutovo.cz/@zdendys)
|
||||
|
||||
> Note: Add yours by creating a pull request.
|
||||
|
||||
## Costs
|
||||
|
||||
Costs involved in running and developing this web app:
|
||||
|
@ -138,10 +226,12 @@ Costs involved in running and developing this web app:
|
|||
|
||||
[Phanpy](https://bulbapedia.bulbagarden.net/wiki/Phanpy_(Pok%C3%A9mon)) is a Ground-type Pokémon.
|
||||
|
||||
## Maintainers
|
||||
## Maintainers + contributors
|
||||
|
||||
- [Chee Aun](https://github.com/cheeaun) ([Mastodon](https://mastodon.social/@cheeaun)) ([Twitter](https://twitter.com/cheeaun))
|
||||
|
||||
[![Contributors](https://contrib.rocks/image?repo=cheeaun/phanpy)](https://github.com/cheeaun/phanpy/graphs/contributors)
|
||||
|
||||
## Backstory
|
||||
|
||||
I am one of the earliest users of Twitter. Twitter was launched on [15 July 2006](https://en.wikipedia.org/wiki/Twitter). I joined on December 2006 and my [first tweet](https://twitter.com/cheeaun/status/1298723) was posted on 18 December 2006.
|
||||
|
@ -156,6 +246,8 @@ And here I am. Building a Mastodon web client.
|
|||
|
||||
## Alternative web clients
|
||||
|
||||
- Phanpy forks ↓
|
||||
- [Agora](https://agorasocial.app/)
|
||||
- [Pinafore](https://pinafore.social/) ([retired](https://nolanlawson.com/2023/01/09/retiring-pinafore/)) - forks ↓
|
||||
- [Semaphore](https://semaphore.social/)
|
||||
- [Enafore](https://enafore.social/)
|
||||
|
@ -170,6 +262,9 @@ And here I am. Building a Mastodon web client.
|
|||
- [Litterbox](https://litterbox.koyu.space/)
|
||||
- [Statuzer](https://statuzer.com/)
|
||||
- [Tusked](https://tusked.app/)
|
||||
- [Mastodon Glitch Edition (standalone frontend)](https://iceshrimp.dev/iceshrimp/masto-fe-standalone)
|
||||
- [Mangane](https://github.com/BDX-town/Mangane)
|
||||
- [TheDesk](https://github.com/cutls/TheDesk)
|
||||
- [More...](https://github.com/hueyy/awesome-mastodon/#clients)
|
||||
|
||||
## 💁♂️ Notice to all other social media client developers
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Compose / %VITE_CLIENT_NAME%</title>
|
||||
<title>Compose / %PHANPY_CLIENT_NAME%</title>
|
||||
<meta name="color-scheme" content="dark light" />
|
||||
<meta name="google" content="notranslate" />
|
||||
</head>
|
||||
|
|
27
index.html
27
index.html
|
@ -6,7 +6,7 @@
|
|||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, viewport-fit=cover"
|
||||
/>
|
||||
<title>%VITE_CLIENT_NAME%</title>
|
||||
<title>%PHANPY_CLIENT_NAME%</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="Minimalistic opinionated Mastodon web client"
|
||||
|
@ -14,18 +14,33 @@
|
|||
<meta name="color-scheme" content="dark light" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<meta name="apple-mobile-web-app-title" content="%VITE_CLIENT_NAME%" />
|
||||
<meta name="apple-mobile-web-app-title" content="%PHANPY_CLIENT_NAME%" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<link rel="canonical" href="%VITE_WEBSITE%" />
|
||||
<link rel="canonical" href="%PHANPY_WEBSITE%" />
|
||||
<meta
|
||||
name=""
|
||||
data-theme-setting="manual"
|
||||
content="#242526"
|
||||
data-theme-light-color="#fff"
|
||||
data-theme-light-color-temp="#ffff"
|
||||
data-theme-dark-color="#242526"
|
||||
data-theme-dark-color-temp="#242526ff"
|
||||
/>
|
||||
<meta
|
||||
name="theme-color"
|
||||
data-theme-setting="auto"
|
||||
content="#fff"
|
||||
data-content="#fff"
|
||||
data-content-temp="#fffa"
|
||||
media="(prefers-color-scheme: light)"
|
||||
/>
|
||||
<meta
|
||||
name="theme-color"
|
||||
data-theme-setting="auto"
|
||||
content="#242526"
|
||||
data-content="#242526"
|
||||
data-content-temp="#242526aa"
|
||||
media="(prefers-color-scheme: dark)"
|
||||
/>
|
||||
<meta name="google" content="notranslate" />
|
||||
|
@ -33,13 +48,13 @@
|
|||
|
||||
<!-- Metacrap https://broken-links.com/2015/12/01/little-less-metacrap/ -->
|
||||
<meta property="twitter:card" content="summary_large_image" />
|
||||
<meta property="og:url" content="%VITE_WEBSITE%" />
|
||||
<meta property="og:title" content="%VITE_CLIENT_NAME%" />
|
||||
<meta property="og:url" content="%PHANPY_WEBSITE%" />
|
||||
<meta property="og:title" content="%PHANPY_CLIENT_NAME%" />
|
||||
<meta
|
||||
property="og:description"
|
||||
content="Minimalistic opinionated Mastodon web client"
|
||||
/>
|
||||
<meta property="og:image" content="%VITE_WEBSITE%/og-image-2.jpg" />
|
||||
<meta property="og:image" content="%PHANPY_WEBSITE%/og-image-2.jpg" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
|
Plik diff jest za duży
Load Diff
78
package.json
78
package.json
|
@ -6,57 +6,64 @@
|
|||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"fetch-instances": "env $(cat .env.dev | grep -v \"#\" | xargs) node scripts/fetch-instances-list.js",
|
||||
"fetch-instances": "env $(cat .env.local | grep -v \"#\" | xargs) node scripts/fetch-instances-list.js",
|
||||
"sourcemap": "npx source-map-explorer dist/assets/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@formatjs/intl-localematcher": "~0.4.2",
|
||||
"@github/text-expander-element": "~2.5.0",
|
||||
"@iconify-icons/mingcute": "~1.2.8",
|
||||
"@formatjs/intl-localematcher": "~0.5.4",
|
||||
"@formatjs/intl-segmenter": "~11.5.7",
|
||||
"@formkit/auto-animate": "~0.8.2",
|
||||
"@github/text-expander-element": "~2.7.1",
|
||||
"@iconify-icons/mingcute": "~1.2.9",
|
||||
"@justinribeiro/lite-youtube": "~1.5.0",
|
||||
"@szhsin/react-menu": "~4.0.3",
|
||||
"@uidotdev/usehooks": "~2.3.1",
|
||||
"dayjs": "~1.11.10",
|
||||
"@szhsin/react-menu": "~4.1.0",
|
||||
"@uidotdev/usehooks": "~2.4.1",
|
||||
"compare-versions": "~6.1.0",
|
||||
"dayjs": "~1.11.11",
|
||||
"dayjs-twitter": "~0.5.0",
|
||||
"fast-blurhash": "~1.1.2",
|
||||
"fast-deep-equal": "~3.1.3",
|
||||
"fast-equals": "~5.0.1",
|
||||
"fuse.js": "~7.0.0",
|
||||
"html-prettify": "^1.0.7",
|
||||
"idb-keyval": "~6.2.1",
|
||||
"just-debounce-it": "~3.2.0",
|
||||
"lz-string": "~1.5.0",
|
||||
"masto": "~5.11.4",
|
||||
"mem": "~9.0.2",
|
||||
"p-retry": "~6.1.0",
|
||||
"p-throttle": "~5.1.0",
|
||||
"preact": "~10.18.1",
|
||||
"react-hotkeys-hook": "~4.4.1",
|
||||
"react-intersection-observer": "~9.5.2",
|
||||
"react-quick-pinch-zoom": "~5.0.0",
|
||||
"masto": "~6.7.7",
|
||||
"moize": "~6.1.6",
|
||||
"p-retry": "~6.2.0",
|
||||
"p-throttle": "~6.1.0",
|
||||
"preact": "~10.22.0",
|
||||
"punycode": "~2.3.1",
|
||||
"react-hotkeys-hook": "~4.5.0",
|
||||
"react-intersection-observer": "~9.10.2",
|
||||
"react-quick-pinch-zoom": "~5.1.0",
|
||||
"react-router-dom": "6.6.2",
|
||||
"string-length": "5.0.1",
|
||||
"swiped-events": "~1.1.7",
|
||||
"string-length": "6.0.0",
|
||||
"swiped-events": "~1.2.0",
|
||||
"tinyld": "~1.3.4",
|
||||
"toastify-js": "~1.12.0",
|
||||
"uid": "~2.0.2",
|
||||
"use-debounce": "~9.0.4",
|
||||
"use-debounce": "~10.0.1",
|
||||
"use-long-press": "~3.2.0",
|
||||
"use-resize-observer": "~9.1.0",
|
||||
"valtio": "1.9.0"
|
||||
"valtio": "1.13.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@preact/preset-vite": "~2.5.0",
|
||||
"@trivago/prettier-plugin-sort-imports": "~4.2.0",
|
||||
"postcss": "~8.4.31",
|
||||
"postcss-dark-theme-class": "~1.0.0",
|
||||
"postcss-preset-env": "~9.1.4",
|
||||
"@preact/preset-vite": "~2.8.2",
|
||||
"@trivago/prettier-plugin-sort-imports": "~4.3.0",
|
||||
"postcss": "~8.4.38",
|
||||
"postcss-dark-theme-class": "~1.3.0",
|
||||
"postcss-preset-env": "~9.5.14",
|
||||
"twitter-text": "~3.1.0",
|
||||
"vite": "~4.4.11",
|
||||
"vite-plugin-generate-file": "~0.0.4",
|
||||
"vite": "~5.2.12",
|
||||
"vite-plugin-generate-file": "~0.1.1",
|
||||
"vite-plugin-html-config": "~1.0.11",
|
||||
"vite-plugin-pwa": "~0.16.5",
|
||||
"vite-plugin-remove-console": "~2.1.1",
|
||||
"workbox-cacheable-response": "~7.0.0",
|
||||
"workbox-expiration": "~7.0.0",
|
||||
"workbox-routing": "~7.0.0",
|
||||
"workbox-strategies": "~7.0.0"
|
||||
"vite-plugin-pwa": "~0.20.0",
|
||||
"vite-plugin-remove-console": "~2.2.0",
|
||||
"workbox-cacheable-response": "~7.1.0",
|
||||
"workbox-expiration": "~7.1.0",
|
||||
"workbox-routing": "~7.1.0",
|
||||
"workbox-strategies": "~7.1.0"
|
||||
},
|
||||
"postcss": {
|
||||
"plugins": {
|
||||
|
@ -68,6 +75,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"overrides": {
|
||||
"vite": {
|
||||
"rollup": ">=4.5.1"
|
||||
}
|
||||
},
|
||||
"browserslist": [
|
||||
"defaults",
|
||||
"android >= 4"
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, viewport-fit=cover"
|
||||
/>
|
||||
<title>Page not found</title>
|
||||
<meta name="color-scheme" content="dark light" />
|
||||
<style>
|
||||
body {
|
||||
text-align: center;
|
||||
font-family: ui-rounded, -apple-system, BlinkMacSystemFont, Segoe UI,
|
||||
Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Page not found</h1>
|
||||
<p><a href="/">Go home</a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -33,8 +33,9 @@ const imageRoute = new Route(
|
|||
const isRemote = !sameOrigin;
|
||||
const isImage = request.destination === 'image';
|
||||
const isAvatar = request.url.includes('/avatars/');
|
||||
const isCustomEmoji = request.url.includes('/custom/_emojis');
|
||||
const isEmoji = request.url.includes('/emoji/');
|
||||
return isRemote && isImage && (isAvatar || isEmoji);
|
||||
return isRemote && isImage && (isAvatar || isCustomEmoji || isEmoji);
|
||||
},
|
||||
new CacheFirst({
|
||||
cacheName: 'remote-images',
|
||||
|
@ -61,7 +62,7 @@ const iconsRoute = new Route(
|
|||
cacheName: 'icons',
|
||||
plugins: [
|
||||
new ExpirationPlugin({
|
||||
maxEntries: 50,
|
||||
maxEntries: 300,
|
||||
maxAgeSeconds: 3 * 24 * 60 * 60, // 3 days
|
||||
purgeOnQuotaError: true,
|
||||
}),
|
||||
|
@ -179,12 +180,12 @@ self.addEventListener('notificationclick', (event) => {
|
|||
console.log('NOTIFICATION CLICK navigate', url);
|
||||
if (bestClient) {
|
||||
console.log('NOTIFICATION CLICK postMessage', bestClient);
|
||||
bestClient.focus();
|
||||
bestClient.postMessage?.({
|
||||
type: 'notification',
|
||||
id: tag,
|
||||
accessToken: access_token,
|
||||
});
|
||||
bestClient.focus();
|
||||
} else {
|
||||
console.log('NOTIFICATION CLICK openWindow', url);
|
||||
await self.clients.openWindow(url);
|
||||
|
|
|
@ -1,34 +1,12 @@
|
|||
import fs from 'fs';
|
||||
|
||||
const { INSTANCES_SOCIAL_SECRET_TOKEN } = process.env;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
count: 0,
|
||||
min_users: 500,
|
||||
sort_by: 'active_users',
|
||||
sort_order: 'desc',
|
||||
});
|
||||
|
||||
const url = `https://instances.social/api/1.0/instances/list?${params.toString()}`;
|
||||
const results = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${INSTANCES_SOCIAL_SECRET_TOKEN}`,
|
||||
},
|
||||
});
|
||||
const url = 'https://api.joinmastodon.org/servers';
|
||||
const results = await fetch(url);
|
||||
|
||||
const json = await results.json();
|
||||
|
||||
// Filters
|
||||
json.instances = json.instances.filter(
|
||||
(instance) => Number(instance.connections) > 20,
|
||||
);
|
||||
|
||||
const names = json.instances.map((instance) => instance.name);
|
||||
const domains = json.map((instance) => instance.domain);
|
||||
|
||||
// Write to file
|
||||
const path = './src/data/instances.json';
|
||||
fs.writeFileSync(path, JSON.stringify(names, null, '\t'), 'utf8');
|
||||
|
||||
// Write everything to file, for debugging
|
||||
const path2 = './src/data/instances-full.json';
|
||||
fs.writeFileSync(path2, JSON.stringify(json, null, '\t'), 'utf8');
|
||||
fs.writeFileSync(path, JSON.stringify(domains, null, '\t'), 'utf8');
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Fetch https://lingva.ml/api/v1/languages/{source|target}
|
||||
import fs from 'fs';
|
||||
|
||||
fetch('https://lingva.ml/api/v1/languages/source')
|
||||
fetch('https://lingva.phanpy.social/api/v1/languages/source')
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
const file = './src/data/lingva-source-languages.json';
|
||||
|
@ -9,7 +8,7 @@ fetch('https://lingva.ml/api/v1/languages/source')
|
|||
fs.writeFileSync(file, JSON.stringify(json.languages, null, '\t'), 'utf8');
|
||||
});
|
||||
|
||||
fetch('https://lingva.ml/api/v1/languages/target')
|
||||
fetch('https://lingva.phanpy.social/api/v1/languages/target')
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
const file = './src/data/lingva-target-languages.json';
|
||||
|
|
843
src/app.css
843
src/app.css
Plik diff jest za duży
Load Diff
453
src/app.jsx
453
src/app.jsx
|
@ -1,5 +1,6 @@
|
|||
import './app.css';
|
||||
|
||||
import debounce from 'just-debounce-it';
|
||||
import {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
|
@ -9,11 +10,11 @@ import {
|
|||
} from 'preact/hooks';
|
||||
import { matchPath, Route, Routes, useLocation } from 'react-router-dom';
|
||||
import 'swiped-events';
|
||||
import { useSnapshot } from 'valtio';
|
||||
import { subscribe } from 'valtio';
|
||||
|
||||
import BackgroundService from './components/background-service';
|
||||
import ComposeButton from './components/compose-button';
|
||||
import { ICONS } from './components/icon';
|
||||
import { ICONS } from './components/ICONS';
|
||||
import KeyboardShortcutsHelp from './components/keyboard-shortcuts-help';
|
||||
import Loader from './components/loader';
|
||||
import Modals from './components/modals';
|
||||
|
@ -23,7 +24,9 @@ import Shortcuts from './components/shortcuts';
|
|||
import NotFound from './pages/404';
|
||||
import AccountStatuses from './pages/account-statuses';
|
||||
import Bookmarks from './pages/bookmarks';
|
||||
import Catchup from './pages/catchup';
|
||||
import Favourites from './pages/favourites';
|
||||
import Filters from './pages/filters';
|
||||
import FollowedHashtags from './pages/followed-hashtags';
|
||||
import Following from './pages/following';
|
||||
import Hashtag from './pages/hashtag';
|
||||
|
@ -48,48 +51,250 @@ import {
|
|||
} from './utils/api';
|
||||
import { getAccessToken } from './utils/auth';
|
||||
import focusDeck from './utils/focus-deck';
|
||||
import states, { initStates } from './utils/states';
|
||||
import states, { initStates, statusKey } from './utils/states';
|
||||
import store from './utils/store';
|
||||
import { getCurrentAccount } from './utils/store-utils';
|
||||
import { getCurrentAccount, setCurrentAccountID } from './utils/store-utils';
|
||||
import './utils/toast-alert';
|
||||
|
||||
window.__STATES__ = states;
|
||||
window.__STATES_STATS__ = () => {
|
||||
const keys = [
|
||||
'statuses',
|
||||
'accounts',
|
||||
'spoilers',
|
||||
'unfurledLinks',
|
||||
'statusQuotes',
|
||||
];
|
||||
const counts = {};
|
||||
keys.forEach((key) => {
|
||||
counts[key] = Object.keys(states[key]).length;
|
||||
});
|
||||
console.warn('STATE stats', counts);
|
||||
|
||||
const { statuses } = states;
|
||||
const unmountedPosts = [];
|
||||
for (const key in statuses) {
|
||||
const $post = document.querySelector(
|
||||
`[data-state-post-id~="${key}"], [data-state-post-ids~="${key}"]`,
|
||||
);
|
||||
if (!$post) {
|
||||
unmountedPosts.push(key);
|
||||
}
|
||||
}
|
||||
console.warn('Unmounted posts', unmountedPosts.length, unmountedPosts);
|
||||
};
|
||||
|
||||
// Experimental "garbage collection" for states
|
||||
// Every 15 minutes
|
||||
// Only posts for now
|
||||
setInterval(() => {
|
||||
if (!window.__IDLE__) return;
|
||||
const { statuses, unfurledLinks, notifications } = states;
|
||||
let keysCount = 0;
|
||||
const { instance } = api();
|
||||
for (const key in statuses) {
|
||||
if (!window.__IDLE__) break;
|
||||
try {
|
||||
const $post = document.querySelector(
|
||||
`[data-state-post-id~="${key}"], [data-state-post-ids~="${key}"]`,
|
||||
);
|
||||
const postInNotifications = notifications.some(
|
||||
(n) => key === statusKey(n.status?.id, instance),
|
||||
);
|
||||
if (!$post && !postInNotifications) {
|
||||
delete states.statuses[key];
|
||||
delete states.statusQuotes[key];
|
||||
for (const link in unfurledLinks) {
|
||||
const unfurled = unfurledLinks[link];
|
||||
const sKey = statusKey(unfurled.id, unfurled.instance);
|
||||
if (sKey === key) {
|
||||
delete states.unfurledLinks[link];
|
||||
break;
|
||||
}
|
||||
}
|
||||
keysCount++;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
if (keysCount) {
|
||||
console.info(`GC: Removed ${keysCount} keys`);
|
||||
}
|
||||
}, 15 * 60 * 1000);
|
||||
|
||||
// Preload icons
|
||||
// There's probably a better way to do this
|
||||
// Related: https://github.com/vitejs/vite/issues/10600
|
||||
setTimeout(() => {
|
||||
for (const icon in ICONS) {
|
||||
if (Array.isArray(ICONS[icon])) {
|
||||
ICONS[icon][0]?.();
|
||||
} else {
|
||||
ICONS[icon]?.();
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (Array.isArray(ICONS[icon])) {
|
||||
ICONS[icon][0]?.();
|
||||
} else {
|
||||
ICONS[icon]?.();
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
(() => {
|
||||
window.__IDLE__ = true;
|
||||
const nonIdleEvents = [
|
||||
'mousemove',
|
||||
'mousedown',
|
||||
'resize',
|
||||
'keydown',
|
||||
'touchstart',
|
||||
'pointerdown',
|
||||
'pointermove',
|
||||
'wheel',
|
||||
];
|
||||
const setIdle = () => {
|
||||
window.__IDLE__ = true;
|
||||
};
|
||||
const IDLE_TIME = 3_000; // 3 seconds
|
||||
const debouncedSetIdle = debounce(setIdle, IDLE_TIME);
|
||||
const onNonIdle = () => {
|
||||
window.__IDLE__ = false;
|
||||
debouncedSetIdle();
|
||||
};
|
||||
nonIdleEvents.forEach((event) => {
|
||||
window.addEventListener(event, onNonIdle, {
|
||||
passive: true,
|
||||
capture: true,
|
||||
});
|
||||
});
|
||||
window.addEventListener('blur', setIdle, {
|
||||
passive: true,
|
||||
});
|
||||
// When cursor leaves the window, set idle
|
||||
document.documentElement.addEventListener(
|
||||
'mouseleave',
|
||||
(e) => {
|
||||
if (!e.relatedTarget && !e.toElement) {
|
||||
setIdle();
|
||||
}
|
||||
},
|
||||
{
|
||||
passive: true,
|
||||
},
|
||||
);
|
||||
// document.addEventListener(
|
||||
// 'visibilitychange',
|
||||
// () => {
|
||||
// if (document.visibilityState === 'visible') {
|
||||
// onNonIdle();
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// passive: true,
|
||||
// },
|
||||
// );
|
||||
})();
|
||||
|
||||
// Possible fix for iOS PWA theme-color bug
|
||||
// It changes when loading web pages in "webview"
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
||||
if (isIOS) {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
const theme = store.local.get('theme');
|
||||
let $meta;
|
||||
if (theme) {
|
||||
// Get current meta
|
||||
$meta = document.querySelector(
|
||||
`meta[name="theme-color"][data-theme-setting="manual"]`,
|
||||
);
|
||||
if ($meta) {
|
||||
const color = $meta.content;
|
||||
const tempColor =
|
||||
theme === 'light'
|
||||
? $meta.dataset.themeLightColorTemp
|
||||
: $meta.dataset.themeDarkColorTemp;
|
||||
$meta.content = tempColor || '';
|
||||
setTimeout(() => {
|
||||
$meta.content = color;
|
||||
}, 10);
|
||||
}
|
||||
} else {
|
||||
// Get current color scheme
|
||||
const colorScheme = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
.matches
|
||||
? 'dark'
|
||||
: 'light';
|
||||
// Get current theme-color
|
||||
$meta = document.querySelector(
|
||||
`meta[name="theme-color"][media*="${colorScheme}"]`,
|
||||
);
|
||||
if ($meta) {
|
||||
const color = $meta.dataset.content;
|
||||
const tempColor = $meta.dataset.contentTemp;
|
||||
$meta.content = tempColor || '';
|
||||
setTimeout(() => {
|
||||
$meta.content = color;
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
const theme = store.local.get('theme');
|
||||
// If there's a theme, it's NOT auto
|
||||
if (theme) {
|
||||
// dark | light
|
||||
document.documentElement.classList.add(`is-${theme}`);
|
||||
document
|
||||
.querySelector('meta[name="color-scheme"]')
|
||||
.setAttribute('content', theme || 'dark light');
|
||||
|
||||
// Enable manual theme <meta>
|
||||
const $manualMeta = document.querySelector(
|
||||
'meta[data-theme-setting="manual"]',
|
||||
);
|
||||
if ($manualMeta) {
|
||||
$manualMeta.name = 'theme-color';
|
||||
$manualMeta.content =
|
||||
theme === 'light'
|
||||
? $manualMeta.dataset.themeLightColor
|
||||
: $manualMeta.dataset.themeDarkColor;
|
||||
}
|
||||
// Disable auto theme <meta>s
|
||||
const $autoMetas = document.querySelectorAll(
|
||||
'meta[data-theme-setting="auto"]',
|
||||
);
|
||||
$autoMetas.forEach((m) => {
|
||||
m.name = '';
|
||||
});
|
||||
}
|
||||
const textSize = store.local.get('textSize');
|
||||
if (textSize) {
|
||||
document.documentElement.style.setProperty('--text-size', `${textSize}px`);
|
||||
}
|
||||
}
|
||||
|
||||
subscribe(states, (changes) => {
|
||||
for (const [action, path, value, prevValue] of changes) {
|
||||
// Change #app dataset based on settings.shortcutsViewMode
|
||||
if (path.join('.') === 'settings.shortcutsViewMode') {
|
||||
const $app = document.getElementById('app');
|
||||
if ($app) {
|
||||
$app.dataset.shortcutsViewMode = states.shortcuts?.length ? value : '';
|
||||
}
|
||||
}
|
||||
|
||||
// Add/Remove cloak class to body
|
||||
if (path.join('.') === 'settings.cloakMode') {
|
||||
const $body = document.body;
|
||||
$body.classList.toggle('cloak', value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function App() {
|
||||
const snapStates = useSnapshot(states);
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
const [uiState, setUIState] = useState('loading');
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const theme = store.local.get('theme');
|
||||
if (theme) {
|
||||
document.documentElement.classList.add(`is-${theme}`);
|
||||
document
|
||||
.querySelector('meta[name="color-scheme"]')
|
||||
.setAttribute('content', theme === 'auto' ? 'dark light' : theme);
|
||||
}
|
||||
const textSize = store.local.get('textSize');
|
||||
if (textSize) {
|
||||
document.documentElement.style.setProperty(
|
||||
'--text-size',
|
||||
`${textSize}px`,
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const instanceURL = store.local.get('instanceURL');
|
||||
const code = decodeURIComponent(
|
||||
|
@ -99,7 +304,11 @@ function App() {
|
|||
if (code) {
|
||||
console.log({ code });
|
||||
// Clear the code from the URL
|
||||
window.history.replaceState({}, document.title, location.pathname || '/');
|
||||
window.history.replaceState(
|
||||
{},
|
||||
document.title,
|
||||
window.location.pathname || '/',
|
||||
);
|
||||
|
||||
const clientID = store.session.get('clientID');
|
||||
const clientSecret = store.session.get('clientSecret');
|
||||
|
@ -114,28 +323,31 @@ function App() {
|
|||
code,
|
||||
});
|
||||
|
||||
const masto = initClient({ instance: instanceURL, accessToken });
|
||||
const client = initClient({ instance: instanceURL, accessToken });
|
||||
await Promise.allSettled([
|
||||
initInstance(masto, instanceURL),
|
||||
initAccount(masto, instanceURL, accessToken, vapidKey),
|
||||
initPreferences(client),
|
||||
initInstance(client, instanceURL),
|
||||
initAccount(client, instanceURL, accessToken, vapidKey),
|
||||
]);
|
||||
initStates();
|
||||
initPreferences(masto);
|
||||
|
||||
setIsLoggedIn(true);
|
||||
setUIState('default');
|
||||
})();
|
||||
} else {
|
||||
window.__IGNORE_GET_ACCOUNT_ERROR__ = true;
|
||||
const account = getCurrentAccount();
|
||||
if (account) {
|
||||
store.session.set('currentAccount', account.info.id);
|
||||
const { masto, instance } = api({ account });
|
||||
console.log('masto', masto);
|
||||
initPreferences(masto);
|
||||
setCurrentAccountID(account.info.id);
|
||||
const { client } = api({ account });
|
||||
const { instance } = client;
|
||||
// console.log('masto', masto);
|
||||
initStates();
|
||||
setUIState('loading');
|
||||
(async () => {
|
||||
try {
|
||||
await initInstance(masto, instance);
|
||||
await initPreferences(client);
|
||||
await initInstance(client, instance);
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setIsLoggedIn(true);
|
||||
|
@ -150,11 +362,72 @@ function App() {
|
|||
|
||||
let location = useLocation();
|
||||
states.currentLocation = location.pathname;
|
||||
// useLayoutEffect(() => {
|
||||
// states.currentLocation = location.pathname;
|
||||
// }, [location.pathname]);
|
||||
|
||||
useEffect(focusDeck, [location, isLoggedIn]);
|
||||
|
||||
const prevLocation = snapStates.prevLocation;
|
||||
const backgroundLocation = useRef(prevLocation || null);
|
||||
if (/\/https?:/.test(location.pathname)) {
|
||||
return <HttpRoute />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<PrimaryRoutes isLoggedIn={isLoggedIn} loading={uiState === 'loading'} />
|
||||
<SecondaryRoutes isLoggedIn={isLoggedIn} />
|
||||
{uiState === 'default' && (
|
||||
<Routes>
|
||||
<Route path="/:instance?/s/:id" element={<StatusRoute />} />
|
||||
</Routes>
|
||||
)}
|
||||
{isLoggedIn && <ComposeButton />}
|
||||
{isLoggedIn && <Shortcuts />}
|
||||
<Modals />
|
||||
{isLoggedIn && <NotificationService />}
|
||||
<BackgroundService isLoggedIn={isLoggedIn} />
|
||||
{uiState !== 'loading' && <SearchCommand onClose={focusDeck} />}
|
||||
<KeyboardShortcutsHelp />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function PrimaryRoutes({ isLoggedIn, loading }) {
|
||||
const location = useLocation();
|
||||
const nonRootLocation = useMemo(() => {
|
||||
const { pathname } = location;
|
||||
return !/^\/(login|welcome)/i.test(pathname);
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
<Routes location={nonRootLocation || location}>
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
isLoggedIn ? (
|
||||
<Home />
|
||||
) : loading ? (
|
||||
<Loader id="loader-root" />
|
||||
) : (
|
||||
<Welcome />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/welcome" element={<Welcome />} />
|
||||
</Routes>
|
||||
);
|
||||
}
|
||||
|
||||
function getPrevLocation() {
|
||||
return states.prevLocation || null;
|
||||
}
|
||||
function SecondaryRoutes({ isLoggedIn }) {
|
||||
// const snapStates = useSnapshot(states);
|
||||
const location = useLocation();
|
||||
// const prevLocation = snapStates.prevLocation;
|
||||
const backgroundLocation = useRef(getPrevLocation());
|
||||
|
||||
const isModalPage = useMemo(() => {
|
||||
return (
|
||||
matchPath('/:instance/s/:id', location.pathname) ||
|
||||
|
@ -162,7 +435,8 @@ function App() {
|
|||
);
|
||||
}, [location.pathname, matchPath]);
|
||||
if (isModalPage) {
|
||||
if (!backgroundLocation.current) backgroundLocation.current = prevLocation;
|
||||
if (!backgroundLocation.current)
|
||||
backgroundLocation.current = getPrevLocation();
|
||||
} else {
|
||||
backgroundLocation.current = null;
|
||||
}
|
||||
|
@ -171,91 +445,34 @@ function App() {
|
|||
location,
|
||||
});
|
||||
|
||||
if (/\/https?:/.test(location.pathname)) {
|
||||
return <HttpRoute />;
|
||||
}
|
||||
|
||||
const nonRootLocation = useMemo(() => {
|
||||
const { pathname } = location;
|
||||
return !/^\/(login|welcome)/.test(pathname);
|
||||
}, [location]);
|
||||
|
||||
// Change #app dataset based on snapStates.settings.shortcutsViewMode
|
||||
useEffect(() => {
|
||||
const $app = document.getElementById('app');
|
||||
if ($app) {
|
||||
$app.dataset.shortcutsViewMode = snapStates.shortcuts?.length
|
||||
? snapStates.settings.shortcutsViewMode
|
||||
: '';
|
||||
}
|
||||
}, [snapStates.shortcuts, snapStates.settings.shortcutsViewMode]);
|
||||
|
||||
// Add/Remove cloak class to body
|
||||
useEffect(() => {
|
||||
const $body = document.body;
|
||||
$body.classList.toggle('cloak', snapStates.settings.cloakMode);
|
||||
}, [snapStates.settings.cloakMode]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Routes location={nonRootLocation || location}>
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
isLoggedIn ? (
|
||||
<Home />
|
||||
) : uiState === 'loading' ? (
|
||||
<Loader id="loader-root" />
|
||||
) : (
|
||||
<Welcome />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/welcome" element={<Welcome />} />
|
||||
</Routes>
|
||||
<Routes location={backgroundLocation.current || location}>
|
||||
{isLoggedIn && (
|
||||
<Routes location={backgroundLocation.current || location}>
|
||||
{isLoggedIn && (
|
||||
<>
|
||||
<Route path="/notifications" element={<Notifications />} />
|
||||
)}
|
||||
{isLoggedIn && <Route path="/mentions" element={<Mentions />} />}
|
||||
{isLoggedIn && <Route path="/following" element={<Following />} />}
|
||||
{isLoggedIn && <Route path="/b" element={<Bookmarks />} />}
|
||||
{isLoggedIn && <Route path="/f" element={<Favourites />} />}
|
||||
{isLoggedIn && (
|
||||
<Route path="/mentions" element={<Mentions />} />
|
||||
<Route path="/following" element={<Following />} />
|
||||
<Route path="/b" element={<Bookmarks />} />
|
||||
<Route path="/f" element={<Favourites />} />
|
||||
<Route path="/l">
|
||||
<Route index element={<Lists />} />
|
||||
<Route path=":id" element={<List />} />
|
||||
</Route>
|
||||
)}
|
||||
{isLoggedIn && <Route path="/ft" element={<FollowedHashtags />} />}
|
||||
<Route path="/:instance?/t/:hashtag" element={<Hashtag />} />
|
||||
<Route path="/:instance?/a/:id" element={<AccountStatuses />} />
|
||||
<Route path="/:instance?/p">
|
||||
<Route index element={<Public />} />
|
||||
<Route path="l" element={<Public local />} />
|
||||
</Route>
|
||||
<Route path="/:instance?/trending" element={<Trending />} />
|
||||
<Route path="/:instance?/search" element={<Search />} />
|
||||
{/* <Route path="/:anything" element={<NotFound />} /> */}
|
||||
</Routes>
|
||||
{uiState === 'default' && (
|
||||
<Routes>
|
||||
<Route path="/:instance?/s/:id" element={<StatusRoute />} />
|
||||
</Routes>
|
||||
<Route path="/fh" element={<FollowedHashtags />} />
|
||||
<Route path="/ft" element={<Filters />} />
|
||||
<Route path="/catchup" element={<Catchup />} />
|
||||
</>
|
||||
)}
|
||||
{isLoggedIn && <ComposeButton />}
|
||||
{isLoggedIn &&
|
||||
!snapStates.settings.shortcutsColumnsMode &&
|
||||
snapStates.settings.shortcutsViewMode !== 'multi-column' && (
|
||||
<Shortcuts />
|
||||
)}
|
||||
<Modals />
|
||||
<NotificationService />
|
||||
<BackgroundService isLoggedIn={isLoggedIn} />
|
||||
<SearchCommand onClose={focusDeck} />
|
||||
<KeyboardShortcutsHelp />
|
||||
</>
|
||||
<Route path="/:instance?/t/:hashtag" element={<Hashtag />} />
|
||||
<Route path="/:instance?/a/:id" element={<AccountStatuses />} />
|
||||
<Route path="/:instance?/p">
|
||||
<Route index element={<Public />} />
|
||||
<Route path="l" element={<Public local />} />
|
||||
</Route>
|
||||
<Route path="/:instance?/trending" element={<Trending />} />
|
||||
<Route path="/:instance?/search" element={<Search />} />
|
||||
{/* <Route path="/:anything" element={<NotFound />} /> */}
|
||||
</Routes>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 25 KiB |
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" viewBox="0 0 641 223">
|
||||
<path fill="#aaa" d="M86 214c-9-1-17-4-24-8l-6-3-5-5-5-4-4-6-4-6-3-8-2-8v-27l2-9 3-9 4-6 4-6 5-5 5-5 7-3 6-4 7-2 7-2 12-1h12l7 1 8 2 7 4 7 3 5 5 5 4-10 10-10 9-4-3-10-5-5-1H88l-5 2-6 3-3 4-4 4-2 5-2 6v6l-1 7 1 7 2 7 3 5 2 4 4 3 4 3 5 2 6 2h9l10-1 5-2 6-3v-16H91v-27h59v54l-1 3-2 3-5 4-4 4-5 3-5 2-8 2-8 2-10 1H92l-6-1zm266-62V91h34v46h44V91h34v121h-34v-46h-44v46h-34v-61zm-182-1V90h34v121h-34v-60zm59-1V90h35l36 1 5 2c3 0 8 2 10 4l5 2 4 5 5 4 3 7 3 7 1 13v13l-4 6-3 7-4 4-5 5-5 2-5 3-6 2-5 1-18 1h-18v32h-34v-61zm67-2 3-2 2-4 2-5v-5l-2-4-2-4-3-2-3-3h-30v31h30l3-2zm226 39v-24l-8-12-18-28a1751 1751 0 0 0-20-31v-2h39l7 12 12 21 6 9 13-21 13-21h38v2l-41 61-7 10v48h-34v-24zM109 66l-4-1-5-5-5-4-1-5-3-9v-5l1-5c2-7 3-10 8-15l4-4 7-2 7-2h7l6 1 5 2 5 2 3 4 4 3 2 6 2 5v13l-2 5-2 6-4 4-3 3-5 2-4 2-9 1h-9l-5-2zm22-11 4-2 3-4 2-5V34l-2-4-2-4-3-2-4-3-5-1h-6l-4 2-5 2-2 4-3 5-1 3v4l1 5 2 5 2 2 5 3 4 2h10l4-2zM37 39V11h33l3 1 3 2 4 3 3 3 1 5 1 4v5l-1 4-3 4-3 5-4 1-3 2-11 1H49v16H37V39zm31 0 3-2 1-2 1-2v-4l-1-3-3-2-2-2H49v18h15l4-1zm107 25a512 512 0 0 0-19-53h14l4 14 6 19 1 4 1-1 7-19 5-17h9l6 19 7 18v-1l2-6 5-17 4-13h14v1l-4 12-16 41v2h-5l-5-1-6-15-6-15-1 1-3 7-6 15-2 8h-11l-1-3zm74-25V11h42v11h-29v2l-1 5v4h29v11h-28v11h2l15 1h13v11h-43V39zm55 0V11h33l5 3 5 2 2 4 2 5v10l-2 3-1 4-5 3-5 3 5 5 8 10 3 4h-14l-7-9-8-10h-9v19h-12V39zm33-3 2-3v-6l-3-3-2-3h-18v16h1v1h17l2-2zm26 3V11h42v11h-29l-1 6v5h29v11h-28v5l-1 5 1 1v1h30v11h-43V39zm54 0V11h17l18 1 4 2 5 3 2 4 3 4 2 6 1 6v5c-1 6-3 12-6 15l-3 4-5 3-5 2-17 1h-16V39zm33 14 5-5 2-3v-6l-1-6-1-3-1-3-4-3-3-2h-5l-6-1-3 1h-3v34h9l8-1 3-2zm50-14V11h34l5 2 4 2 2 3 2 3v9l-2 2-3 4-1 1 3 3 3 4 1 3 1 4-1 4-1 4-3 3-3 3-5 1-5 1h-31V39zm34 15 2-1v-6l-2-2-2-2h-20v13h20l2-2zm-3-22 4-2v-6l-2-1-2-2h-19v12h16l4-1zm42 24V45l-6-9-11-17-5-8h15l4 8 7 11 2 3 7-11 7-11h14l-11 16-11 17v23h-12V56z"/>
|
||||
</svg>
|
Po Szerokość: | Wysokość: | Rozmiar: 1.9 KiB |
|
@ -8,26 +8,33 @@ body.cloak,
|
|||
.name-text *,
|
||||
.status .content-container,
|
||||
.status .content-container *,
|
||||
.status .content-compact,
|
||||
.status .content-compact > *,
|
||||
.account-container :is(header, main > *:not(.actions)),
|
||||
.account-container :is(header, main > *:not(.actions)) *,
|
||||
.header-account,
|
||||
.account-block {
|
||||
.header-double-lines,
|
||||
.account-block,
|
||||
.catchup-filters .filter-author *,
|
||||
.post-peek-html *,
|
||||
.post-peek-content > *,
|
||||
.request-notifications-account * {
|
||||
text-decoration-thickness: 1.1em;
|
||||
text-decoration-line: line-through;
|
||||
text-rendering: optimizeSpeed;
|
||||
/* text-rendering: optimizeSpeed; */
|
||||
filter: opacity(0.5);
|
||||
}
|
||||
.name-text *,
|
||||
.status .content-container *,
|
||||
.account-container :is(header, main > *:not(.actions)) * {
|
||||
.account-container :is(header, main > *:not(.actions)) *,
|
||||
.post-peek-content > * {
|
||||
filter: none;
|
||||
}
|
||||
|
||||
.status :is(img, video, audio),
|
||||
.avatar,
|
||||
.media-post .media,
|
||||
.avatar *,
|
||||
.emoji,
|
||||
.header-banner {
|
||||
.header-banner,
|
||||
.post-peek-media {
|
||||
filter: contrast(0) !important;
|
||||
background-color: #000 !important;
|
||||
}
|
||||
|
@ -36,7 +43,17 @@ body.cloak,
|
|||
/* SPECIAL CASES */
|
||||
|
||||
@supports (display: -webkit-box) {
|
||||
body.cloak .card :is(.title, .meta) {
|
||||
background-color: var(--text-color) !important;
|
||||
:is(body.cloak, .cloak) .card :is(.title, .meta) {
|
||||
background-color: currentColor !important;
|
||||
}
|
||||
}
|
||||
|
||||
body.cloak,
|
||||
.cloak {
|
||||
.media-container figcaption,
|
||||
.media-container figcaption > *,
|
||||
.catchup-filters .filter-author *,
|
||||
.request-notifications-account * {
|
||||
color: var(--text-color) !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
export const ICONS = {
|
||||
x: () => import('@iconify-icons/mingcute/close-line'),
|
||||
heart: () => import('@iconify-icons/mingcute/heart-line'),
|
||||
bookmark: () => import('@iconify-icons/mingcute/bookmark-line'),
|
||||
'check-circle': () => import('@iconify-icons/mingcute/check-circle-line'),
|
||||
'x-circle': () => import('@iconify-icons/mingcute/close-circle-line'),
|
||||
transfer: () => import('@iconify-icons/mingcute/transfer-4-line'),
|
||||
rocket: () => import('@iconify-icons/mingcute/rocket-line'),
|
||||
'arrow-left': () => import('@iconify-icons/mingcute/arrow-left-line'),
|
||||
'arrow-right': () => import('@iconify-icons/mingcute/arrow-right-line'),
|
||||
'arrow-up': () => import('@iconify-icons/mingcute/arrow-up-line'),
|
||||
'arrow-down': () => import('@iconify-icons/mingcute/arrow-down-line'),
|
||||
earth: () => import('@iconify-icons/mingcute/earth-line'),
|
||||
lock: () => import('@iconify-icons/mingcute/lock-line'),
|
||||
unlock: () => import('@iconify-icons/mingcute/unlock-line'),
|
||||
'eye-close': () => import('@iconify-icons/mingcute/eye-close-line'),
|
||||
'eye-open': () => import('@iconify-icons/mingcute/eye-2-line'),
|
||||
message: () => import('@iconify-icons/mingcute/mail-line'),
|
||||
comment: () => import('@iconify-icons/mingcute/chat-3-line'),
|
||||
comment2: () => import('@iconify-icons/mingcute/comment-2-line'),
|
||||
home: () => import('@iconify-icons/mingcute/home-3-line'),
|
||||
notification: () => import('@iconify-icons/mingcute/notification-line'),
|
||||
follow: () => import('@iconify-icons/mingcute/user-follow-line'),
|
||||
'follow-add': () => import('@iconify-icons/mingcute/user-add-line'),
|
||||
poll: [() => import('@iconify-icons/mingcute/chart-bar-line'), '90deg'],
|
||||
pencil: () => import('@iconify-icons/mingcute/pencil-line'),
|
||||
quill: () => import('@iconify-icons/mingcute/quill-pen-line'),
|
||||
at: () => import('@iconify-icons/mingcute/at-line'),
|
||||
attachment: () => import('@iconify-icons/mingcute/attachment-line'),
|
||||
upload: () => import('@iconify-icons/mingcute/upload-3-line'),
|
||||
gear: () => import('@iconify-icons/mingcute/settings-3-line'),
|
||||
more: () => import('@iconify-icons/mingcute/more-3-line'),
|
||||
more2: () => import('@iconify-icons/mingcute/more-1-fill'),
|
||||
external: () => import('@iconify-icons/mingcute/external-link-line'),
|
||||
popout: () => import('@iconify-icons/mingcute/external-link-line'),
|
||||
popin: [() => import('@iconify-icons/mingcute/external-link-line'), '180deg'],
|
||||
plus: () => import('@iconify-icons/mingcute/add-circle-line'),
|
||||
'chevron-left': () => import('@iconify-icons/mingcute/left-line'),
|
||||
'chevron-right': () => import('@iconify-icons/mingcute/right-line'),
|
||||
'chevron-down': () => import('@iconify-icons/mingcute/down-line'),
|
||||
reply: [
|
||||
() => import('@iconify-icons/mingcute/share-forward-line'),
|
||||
'180deg',
|
||||
'horizontal',
|
||||
],
|
||||
thread: () => import('@iconify-icons/mingcute/route-line'),
|
||||
group: () => import('@iconify-icons/mingcute/group-line'),
|
||||
bot: () => import('@iconify-icons/mingcute/android-2-line'),
|
||||
menu: () => import('@iconify-icons/mingcute/rows-4-line'),
|
||||
list: () => import('@iconify-icons/mingcute/list-check-line'),
|
||||
search: () => import('@iconify-icons/mingcute/search-2-line'),
|
||||
hashtag: () => import('@iconify-icons/mingcute/hashtag-line'),
|
||||
info: () => import('@iconify-icons/mingcute/information-line'),
|
||||
shortcut: () => import('@iconify-icons/mingcute/lightning-line'),
|
||||
user: () => import('@iconify-icons/mingcute/user-4-line'),
|
||||
following: () => import('@iconify-icons/mingcute/walk-line'),
|
||||
pin: () => import('@iconify-icons/mingcute/pin-line'),
|
||||
unpin: [() => import('@iconify-icons/mingcute/pin-line'), '180deg'],
|
||||
bus: () => import('@iconify-icons/mingcute/bus-2-line'),
|
||||
link: () => import('@iconify-icons/mingcute/link-2-line'),
|
||||
history: () => import('@iconify-icons/mingcute/history-line'),
|
||||
share: () => import('@iconify-icons/mingcute/share-2-line'),
|
||||
sparkles: () => import('@iconify-icons/mingcute/sparkles-line'),
|
||||
sparkles2: () => import('@iconify-icons/mingcute/sparkles-2-line'),
|
||||
exit: () => import('@iconify-icons/mingcute/exit-line'),
|
||||
translate: () => import('@iconify-icons/mingcute/translate-line'),
|
||||
play: () => import('@iconify-icons/mingcute/play-fill'),
|
||||
trash: () => import('@iconify-icons/mingcute/delete-2-line'),
|
||||
mute: () => import('@iconify-icons/mingcute/volume-mute-line'),
|
||||
unmute: () => import('@iconify-icons/mingcute/volume-line'),
|
||||
block: () => import('@iconify-icons/mingcute/forbid-circle-line'),
|
||||
unblock: [
|
||||
() => import('@iconify-icons/mingcute/forbid-circle-line'),
|
||||
'180deg',
|
||||
],
|
||||
flag: () => import('@iconify-icons/mingcute/flag-1-line'),
|
||||
time: () => import('@iconify-icons/mingcute/time-line'),
|
||||
refresh: () => import('@iconify-icons/mingcute/refresh-2-line'),
|
||||
emoji2: () => import('@iconify-icons/mingcute/emoji-2-line'),
|
||||
filter: () => import('@iconify-icons/mingcute/filter-2-line'),
|
||||
filters: () => import('@iconify-icons/mingcute/filter-line'),
|
||||
chart: () => import('@iconify-icons/mingcute/chart-line-line'),
|
||||
react: () => import('@iconify-icons/mingcute/react-line'),
|
||||
layout4: () => import('@iconify-icons/mingcute/layout-4-line'),
|
||||
layout5: () => import('@iconify-icons/mingcute/layout-5-line'),
|
||||
announce: () => import('@iconify-icons/mingcute/announcement-line'),
|
||||
alert: () => import('@iconify-icons/mingcute/alert-line'),
|
||||
round: () => import('@iconify-icons/mingcute/round-fill'),
|
||||
'arrow-up-circle': () =>
|
||||
import('@iconify-icons/mingcute/arrow-up-circle-line'),
|
||||
'arrow-down-circle': () =>
|
||||
import('@iconify-icons/mingcute/arrow-down-circle-line'),
|
||||
clipboard: () => import('@iconify-icons/mingcute/clipboard-line'),
|
||||
'account-edit': () => import('@iconify-icons/mingcute/user-edit-line'),
|
||||
'account-warning': () => import('@iconify-icons/mingcute/user-warning-line'),
|
||||
keyboard: () => import('@iconify-icons/mingcute/keyboard-line'),
|
||||
cloud: () => import('@iconify-icons/mingcute/cloud-line'),
|
||||
month: () => import('@iconify-icons/mingcute/calendar-month-line'),
|
||||
media: () => import('@iconify-icons/mingcute/photo-album-line'),
|
||||
speak: () => import('@iconify-icons/mingcute/radar-line'),
|
||||
building: () => import('@iconify-icons/mingcute/building-5-line'),
|
||||
history2: () => import('@iconify-icons/mingcute/history-2-line'),
|
||||
document: () => import('@iconify-icons/mingcute/document-line'),
|
||||
'arrows-right': () => import('@iconify-icons/mingcute/arrows-right-line'),
|
||||
code: () => import('@iconify-icons/mingcute/code-line'),
|
||||
copy: () => import('@iconify-icons/mingcute/copy-2-line'),
|
||||
quote: () => import('@iconify-icons/mingcute/quote-left-line'),
|
||||
settings: () => import('@iconify-icons/mingcute/settings-6-line'),
|
||||
'heart-break': () => import('@iconify-icons/mingcute/heart-crack-line'),
|
||||
'user-x': () => import('@iconify-icons/mingcute/user-x-line'),
|
||||
minimize: () => import('@iconify-icons/mingcute/arrows-down-line'),
|
||||
};
|
|
@ -4,6 +4,10 @@
|
|||
gap: 8px;
|
||||
color: var(--text-color);
|
||||
text-decoration: none;
|
||||
|
||||
.account-block-acct {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
.account-block:hover b {
|
||||
text-decoration: underline;
|
||||
|
@ -13,44 +17,54 @@
|
|||
color: var(--bg-faded-color);
|
||||
}
|
||||
|
||||
.account-block .short-desc {
|
||||
max-height: 1.2em; /* just in case clamping ain't working */
|
||||
}
|
||||
.account-block .short-desc,
|
||||
.account-block .short-desc > * {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 1;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
.account-block .short-desc > * + * {
|
||||
display: none;
|
||||
}
|
||||
.account-block .short-desc * {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: inherit;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.account-block .verified-field {
|
||||
color: var(--green-color);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
align-items: baseline;
|
||||
gap: 2px;
|
||||
}
|
||||
.account-block .verified-field .icon {
|
||||
}
|
||||
.account-block .verified-field .invisible {
|
||||
display: none;
|
||||
|
||||
* {
|
||||
-webkit-box-orient: vertical;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 1;
|
||||
line-clamp: 1;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
a {
|
||||
pointer-events: none;
|
||||
color: color-mix(
|
||||
in lch,
|
||||
var(--green-color) 20%,
|
||||
var(--text-insignificant-color) 80%
|
||||
) !important;
|
||||
}
|
||||
|
||||
.icon {
|
||||
color: var(--green-color);
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.invisible {
|
||||
display: none;
|
||||
}
|
||||
.ellipsis:after {
|
||||
content: '…';
|
||||
}
|
||||
}
|
||||
|
||||
.account-block .account-block-stats {
|
||||
line-height: 1.25;
|
||||
margin-top: 2px;
|
||||
font-size: 0.9em;
|
||||
color: var(--text-insignificant-color);
|
||||
}
|
||||
.account-block .account-block-stats a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
column-gap: 4px;
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import './account-block.css';
|
|||
// import { useNavigate } from 'react-router-dom';
|
||||
import enhanceContent from '../utils/enhance-content';
|
||||
import niceDateTime from '../utils/nice-date-time';
|
||||
import shortenNumber from '../utils/shorten-number';
|
||||
import states from '../utils/states';
|
||||
|
||||
import Avatar from './avatar';
|
||||
|
@ -13,6 +14,7 @@ function AccountBlock({
|
|||
skeleton,
|
||||
account,
|
||||
avatarSize = 'xl',
|
||||
useAvatarStatic = false,
|
||||
instance,
|
||||
external,
|
||||
internal,
|
||||
|
@ -21,6 +23,8 @@ function AccountBlock({
|
|||
showStats = false,
|
||||
accountInstance,
|
||||
hideDisplayName = false,
|
||||
relationship = {},
|
||||
excludeRelationshipAttrs = [],
|
||||
}) {
|
||||
if (skeleton) {
|
||||
return (
|
||||
|
@ -29,12 +33,16 @@ function AccountBlock({
|
|||
<span>
|
||||
<b>████████</b>
|
||||
<br />
|
||||
<span class="account-block-acct">@██████</span>
|
||||
<span class="account-block-acct">██████</span>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!account) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// const navigate = useNavigate();
|
||||
|
||||
const {
|
||||
|
@ -52,6 +60,9 @@ function AccountBlock({
|
|||
fields,
|
||||
note,
|
||||
group,
|
||||
followersCount,
|
||||
createdAt,
|
||||
locked,
|
||||
} = account;
|
||||
let [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
||||
if (accountInstance) {
|
||||
|
@ -60,12 +71,23 @@ function AccountBlock({
|
|||
|
||||
const verifiedField = fields?.find((f) => !!f.verifiedAt && !!f.value);
|
||||
|
||||
const excludedRelationship = {};
|
||||
for (const r in relationship) {
|
||||
if (!excludeRelationshipAttrs.includes(r)) {
|
||||
excludedRelationship[r] = relationship[r];
|
||||
}
|
||||
}
|
||||
const hasRelationship =
|
||||
excludedRelationship.following ||
|
||||
excludedRelationship.followedBy ||
|
||||
excludedRelationship.requested;
|
||||
|
||||
return (
|
||||
<a
|
||||
class="account-block"
|
||||
href={url}
|
||||
target={external ? '_blank' : null}
|
||||
title={`@${acct}`}
|
||||
title={acct2 ? acct : `@${acct}`}
|
||||
onClick={(e) => {
|
||||
if (external) return;
|
||||
e.preventDefault();
|
||||
|
@ -81,8 +103,12 @@ function AccountBlock({
|
|||
}
|
||||
}}
|
||||
>
|
||||
<Avatar url={avatar} size={avatarSize} squircle={bot} />
|
||||
<span>
|
||||
<Avatar
|
||||
url={useAvatarStatic ? avatarStatic : avatar || avatarStatic}
|
||||
size={avatarSize}
|
||||
squircle={bot}
|
||||
/>
|
||||
<span class="account-block-content">
|
||||
{!hideDisplayName && (
|
||||
<>
|
||||
{displayName ? (
|
||||
|
@ -92,55 +118,74 @@ function AccountBlock({
|
|||
) : (
|
||||
<b>{username}</b>
|
||||
)}
|
||||
<br />
|
||||
</>
|
||||
)}
|
||||
)}{' '}
|
||||
<span class="account-block-acct">
|
||||
@{acct1}
|
||||
{acct2 ? '' : '@'}
|
||||
{acct1}
|
||||
<wbr />
|
||||
{acct2}
|
||||
{locked && (
|
||||
<>
|
||||
{' '}
|
||||
<Icon icon="lock" size="s" alt="Locked" />
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
{showActivity && (
|
||||
<>
|
||||
<br />
|
||||
<small class="last-status-at insignificant">
|
||||
Posts: {statusesCount}
|
||||
{!!lastStatusAt && (
|
||||
<>
|
||||
{' '}
|
||||
· Last posted:{' '}
|
||||
{niceDateTime(lastStatusAt, {
|
||||
hideTime: true,
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
</small>
|
||||
</>
|
||||
<div class="account-block-stats">
|
||||
Posts: {shortenNumber(statusesCount)}
|
||||
{!!lastStatusAt && (
|
||||
<>
|
||||
{' '}
|
||||
· Last posted:{' '}
|
||||
{niceDateTime(lastStatusAt, {
|
||||
hideTime: true,
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{showStats && (
|
||||
<div class="account-block-stats">
|
||||
<div
|
||||
class="short-desc"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: enhanceContent(note, { emojis }),
|
||||
}}
|
||||
/>
|
||||
{bot && (
|
||||
<>
|
||||
<span class="tag">
|
||||
<span class="tag collapsed">
|
||||
<Icon icon="bot" /> Automated
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
{!!group && (
|
||||
<>
|
||||
<span class="tag">
|
||||
<span class="tag collapsed">
|
||||
<Icon icon="group" /> Group
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
{hasRelationship && (
|
||||
<div key={relationship.id} class="shazam-container-horizontal">
|
||||
<div class="shazam-container-inner">
|
||||
{excludedRelationship.following &&
|
||||
excludedRelationship.followedBy ? (
|
||||
<span class="tag minimal">Mutual</span>
|
||||
) : excludedRelationship.requested ? (
|
||||
<span class="tag minimal">Requested</span>
|
||||
) : excludedRelationship.following ? (
|
||||
<span class="tag minimal">Following</span>
|
||||
) : excludedRelationship.followedBy ? (
|
||||
<span class="tag minimal">Follows you</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{!!followersCount && (
|
||||
<span class="ib">
|
||||
{shortenNumber(followersCount)}{' '}
|
||||
{followersCount === 1 ? 'follower' : 'followers'}
|
||||
</span>
|
||||
)}
|
||||
{!!verifiedField && (
|
||||
<span class="verified-field ib">
|
||||
<span class="verified-field">
|
||||
<Icon icon="check-circle" size="s" />{' '}
|
||||
<span
|
||||
dangerouslySetInnerHTML={{
|
||||
|
@ -149,6 +194,21 @@ function AccountBlock({
|
|||
/>
|
||||
</span>
|
||||
)}
|
||||
{!bot &&
|
||||
!group &&
|
||||
!hasRelationship &&
|
||||
!followersCount &&
|
||||
!verifiedField &&
|
||||
!!createdAt && (
|
||||
<span class="created-at">
|
||||
Joined{' '}
|
||||
<time datetime={createdAt}>
|
||||
{niceDateTime(createdAt, {
|
||||
hideTime: true,
|
||||
})}
|
||||
</time>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</span>
|
||||
|
|
|
@ -1,8 +1,103 @@
|
|||
.account-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
/* display: flex; */
|
||||
/* flex-direction: column; */
|
||||
/* overflow: hidden; */
|
||||
overflow-y: auto;
|
||||
max-width: 100%;
|
||||
--banner-overlap: 44px;
|
||||
--posting-stats-size: 8px;
|
||||
--original-color: var(--link-color);
|
||||
|
||||
.note {
|
||||
font-size: 0.95em;
|
||||
line-height: 1.4;
|
||||
text-wrap: pretty;
|
||||
margin-bottom: 16px;
|
||||
|
||||
&:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
> *:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
> *:last-child {
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
&:not(:has(p)):not(:empty) {
|
||||
/* Some notes don't have <p> tags, so we need to add some padding */
|
||||
padding: 1em 0;
|
||||
}
|
||||
}
|
||||
|
||||
.posting-stats {
|
||||
font-size: 90%;
|
||||
color: var(--text-insignificant-color);
|
||||
background-color: var(--bg-faded-color);
|
||||
padding: 8px 12px;
|
||||
|
||||
&:is(:hover, :focus-within) {
|
||||
background-color: var(--link-bg-hover-color);
|
||||
}
|
||||
}
|
||||
|
||||
.posting-stats-bar {
|
||||
--gap: 0.5px;
|
||||
--gap-color: var(--outline-color);
|
||||
height: var(--posting-stats-size);
|
||||
border-radius: var(--posting-stats-size);
|
||||
overflow: hidden;
|
||||
margin: 8px 0;
|
||||
box-shadow: inset 0 0 0 1px var(--outline-color),
|
||||
inset 0 0 0 1.5px var(--bg-blur-color);
|
||||
background-color: var(--bg-color);
|
||||
background-repeat: no-repeat;
|
||||
animation: swoosh-bg-image 0.3s ease-in-out 0.3s both;
|
||||
background-image: linear-gradient(
|
||||
to right,
|
||||
var(--original-color) 0%,
|
||||
var(--original-color) calc(var(--originals-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--originals-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--originals-percentage) + var(--gap)),
|
||||
var(--reply-to-color) calc(var(--originals-percentage) + var(--gap)),
|
||||
var(--reply-to-color) calc(var(--replies-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--replies-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--replies-percentage) + var(--gap)),
|
||||
var(--reblog-color) calc(var(--replies-percentage) + var(--gap)),
|
||||
var(--reblog-color) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.posting-stats-legends {
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.posting-stats-legend-item {
|
||||
display: inline-block;
|
||||
width: var(--posting-stats-size);
|
||||
height: var(--posting-stats-size);
|
||||
border-radius: var(--posting-stats-size);
|
||||
background-color: var(--text-insignificant-color);
|
||||
vertical-align: middle;
|
||||
margin: 0 4px 2px;
|
||||
/* border: 1px solid var(--outline-color); */
|
||||
box-shadow: inset 0 0 0 1px var(--outline-color),
|
||||
inset 0 0 0 1.5px var(--bg-blur-color);
|
||||
|
||||
&.posting-stats-legend-item-originals {
|
||||
background-color: var(--original-color);
|
||||
}
|
||||
&.posting-stats-legend-item-replies {
|
||||
background-color: var(--reply-to-color);
|
||||
}
|
||||
&.posting-stats-legend-item-boosts {
|
||||
background-color: var(--reblog-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.account-container.skeleton {
|
||||
|
@ -16,7 +111,7 @@
|
|||
position: absolute;
|
||||
top: 8px;
|
||||
inset-inline: 8px;
|
||||
z-index: 2;
|
||||
z-index: 3;
|
||||
border: 1px solid var(--outline-color);
|
||||
box-shadow: 0 8px 16px var(--drop-shadow-color);
|
||||
border-radius: calc(16px - 8px);
|
||||
|
@ -45,12 +140,13 @@
|
|||
|
||||
~ * {
|
||||
/* pointer-events: none; */
|
||||
filter: grayscale(0.75) brightness(0.75);
|
||||
filter: grayscale(0.75) opacity(0.75);
|
||||
}
|
||||
}
|
||||
|
||||
.account-container .header-banner {
|
||||
/* pointer-events: none; */
|
||||
vertical-align: top;
|
||||
aspect-ratio: 6 / 1;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
|
@ -75,7 +171,7 @@
|
|||
hsla(0, 0%, 0%, 0.013) 95.3%,
|
||||
hsla(0, 0%, 0%, 0) 100%
|
||||
);
|
||||
margin-bottom: -44px;
|
||||
margin-bottom: calc(-1 * var(--banner-overlap));
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
opacity: 0;
|
||||
|
@ -116,18 +212,26 @@
|
|||
}
|
||||
.account-container .header-banner:active {
|
||||
mask-image: none;
|
||||
}
|
||||
.account-container .header-banner:active + header .avatar + * {
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
opacity: 0 !important;
|
||||
}
|
||||
.account-container .header-banner:active + header .avatar {
|
||||
transition: filter 0.3s ease-in-out;
|
||||
filter: none !important;
|
||||
}
|
||||
.account-container .header-banner:active + header .avatar img {
|
||||
transition: border-radius 0.3s ease-in-out;
|
||||
border-radius: 8px;
|
||||
|
||||
& + header {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
& + header .avatar + * {
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
&,
|
||||
& + header .avatar {
|
||||
transition: filter 0.3s ease-in-out;
|
||||
filter: none !important;
|
||||
}
|
||||
|
||||
& + header .avatar img {
|
||||
transition: border-radius 0.3s ease-in-out;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-height: 480px) {
|
||||
|
@ -165,13 +269,80 @@
|
|||
animation: fade-in 0.3s both ease-in-out 0.2s;
|
||||
}
|
||||
|
||||
.account-container .note {
|
||||
font-size: 95%;
|
||||
line-height: 1.4;
|
||||
.account-container .account-block .account-block-acct {
|
||||
display: block;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.account-container .note:not(:has(p)):not(:empty) {
|
||||
/* Some notes don't have <p> tags, so we need to add some padding */
|
||||
padding: 1em 0;
|
||||
|
||||
.private-note-tag {
|
||||
z-index: 1;
|
||||
appearance: none;
|
||||
display: inline-block;
|
||||
color: var(--private-note-text-color);
|
||||
background-color: var(--private-note-bg-color);
|
||||
border: 1px solid var(--private-note-border-color);
|
||||
padding: 4px;
|
||||
line-height: normal;
|
||||
font-size: smaller;
|
||||
border-radius: 0;
|
||||
align-self: center !important;
|
||||
/* clip a dog ear on top right */
|
||||
clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 0 100%);
|
||||
/* 4x4px square on top right */
|
||||
background-size: 4px 4px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: top right;
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--private-note-border-color),
|
||||
var(--private-note-border-color)
|
||||
);
|
||||
transition: transform 0.15s ease-in-out;
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
span {
|
||||
color: inherit;
|
||||
opacity: 0.75;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
display: box;
|
||||
-webkit-box-orient: vertical;
|
||||
box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&:hover:not(:active) {
|
||||
filter: none !important;
|
||||
transform: rotate(-0.5deg) scale(1.05);
|
||||
|
||||
span {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
.account-container .private-note {
|
||||
font-size: 90%;
|
||||
color: var(--text-insignificant-color);
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
padding: 12px;
|
||||
background-color: var(--bg-faded-color);
|
||||
display: flex;
|
||||
gap: 0.5em;
|
||||
align-items: center;
|
||||
|
||||
b {
|
||||
font-size: 90%;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.account-container .stats {
|
||||
|
@ -219,7 +390,11 @@
|
|||
color: inherit;
|
||||
}
|
||||
|
||||
.account-container footer {
|
||||
padding: 0 16px 16px;
|
||||
}
|
||||
.account-container .actions {
|
||||
/* margin-block: 8px; */
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: space-between;
|
||||
|
@ -227,10 +402,11 @@
|
|||
align-items: center;
|
||||
}
|
||||
.account-container .actions button {
|
||||
align-self: flex-end;
|
||||
/* align-self: flex-end; */
|
||||
}
|
||||
.account-container .actions .buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.account-container .account-metadata-box {
|
||||
|
@ -317,19 +493,134 @@
|
|||
|
||||
.timeline-start .account-container {
|
||||
border-bottom: 1px solid var(--outline-color);
|
||||
position: relative;
|
||||
}
|
||||
.timeline-start .account-container header {
|
||||
padding: 16px 16px 1px;
|
||||
padding: 16px;
|
||||
animation: none;
|
||||
}
|
||||
.timeline-start .account-container main {
|
||||
padding: 1px 16px 1px;
|
||||
padding: 1px 16px 16px;
|
||||
}
|
||||
.timeline-start .account-container main > * {
|
||||
animation: none;
|
||||
}
|
||||
.timeline-start .account-container .account-block .account-block-acct {
|
||||
opacity: 0.5;
|
||||
|
||||
.faux-header-bg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@keyframes bye-banner {
|
||||
20% {
|
||||
filter: blur(0) opacity(1);
|
||||
}
|
||||
100% {
|
||||
filter: blur(16px) opacity(0.2);
|
||||
}
|
||||
}
|
||||
@keyframes surface-header {
|
||||
0% {
|
||||
border-bottom-color: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
100% {
|
||||
border-bottom-color: var(--outline-color);
|
||||
box-shadow: 0 8px 16px -8px var(--drop-shadow-color);
|
||||
}
|
||||
}
|
||||
@keyframes shrink-avatar {
|
||||
0% {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
}
|
||||
100% {
|
||||
width: 2.5em;
|
||||
height: 2.5em;
|
||||
}
|
||||
}
|
||||
.sheet .account-container {
|
||||
border-radius: 16px 16px 0 0;
|
||||
overflow-x: hidden;
|
||||
max-height: 75vh;
|
||||
overscroll-behavior: none;
|
||||
scroll-timeline: --account-scroll;
|
||||
|
||||
header {
|
||||
padding-bottom: 16px;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
transparent 30%,
|
||||
var(--bg-color) var(--banner-overlap),
|
||||
var(--bg-color) calc(100% - 8px),
|
||||
transparent
|
||||
);
|
||||
|
||||
.account-block-content {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
line-clamp: 3;
|
||||
-webkit-line-clamp: 3;
|
||||
}
|
||||
}
|
||||
|
||||
.faux-header-bg {
|
||||
display: block;
|
||||
height: var(--banner-overlap);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
background-color: var(--bg-color);
|
||||
margin-top: calc(-1 * var(--banner-overlap));
|
||||
}
|
||||
|
||||
@supports (animation-timeline: scroll()) {
|
||||
.header-banner:not(.header-is-avatar):not(:hover):not(:active) {
|
||||
animation: bye-banner 1s linear both;
|
||||
animation-timeline: view();
|
||||
animation-range: contain 100% cover 100%;
|
||||
}
|
||||
|
||||
header {
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
transparent 30%,
|
||||
var(--bg-color) var(--banner-overlap)
|
||||
);
|
||||
border-bottom: 1px solid transparent;
|
||||
animation: surface-header 1s linear both;
|
||||
animation-timeline: --account-scroll;
|
||||
animation-range: 0 150px;
|
||||
}
|
||||
|
||||
header .avatar {
|
||||
animation: shrink-avatar 1s linear both;
|
||||
animation-timeline: --account-scroll;
|
||||
animation-range: 0 150px;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
/* margin-top: -8px; */
|
||||
padding-top: 1px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
footer {
|
||||
min-height: calc(40px + 16px);
|
||||
animation: slide-up 0.3s ease-out 0.3s both;
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
background-color: var(--bg-faded-blur-color);
|
||||
backdrop-filter: blur(16px) saturate(3);
|
||||
padding: 8px 16px;
|
||||
border-top: var(--hairline-width) solid var(--outline-color);
|
||||
padding-bottom: max(8px, env(safe-area-inset-bottom));
|
||||
box-shadow: 0 -8px 16px -8px var(--drop-shadow-color);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes swoosh-bg-image {
|
||||
|
@ -342,109 +633,60 @@
|
|||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.account-container .posting-stats {
|
||||
font-size: 90%;
|
||||
color: var(--text-insignificant-color);
|
||||
.account-container .posting-stats-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
color: inherit;
|
||||
background-color: var(--bg-faded-color);
|
||||
padding: 8px 12px;
|
||||
--size: 8px;
|
||||
--original-color: var(--link-color);
|
||||
font-size: 90%;
|
||||
color: var(--text-insignificant-color);
|
||||
line-height: 1;
|
||||
vertical-align: text-top;
|
||||
border-radius: 4px;
|
||||
|
||||
&:is(:hover, :focus-within) {
|
||||
color: var(--text-color);
|
||||
background-color: var(--link-bg-hover-color);
|
||||
filter: none !important;
|
||||
}
|
||||
|
||||
.posting-stats-bar {
|
||||
--gap: 0.5px;
|
||||
--gap-color: var(--outline-color);
|
||||
height: var(--size);
|
||||
border-radius: var(--size);
|
||||
overflow: hidden;
|
||||
margin: 8px 0;
|
||||
box-shadow: inset 0 0 0 1px var(--outline-color),
|
||||
inset 0 0 0 1.5px var(--bg-blur-color);
|
||||
background-color: var(--bg-color);
|
||||
background-repeat: no-repeat;
|
||||
animation: swoosh-bg-image 0.3s ease-in-out 0.3s both;
|
||||
background-image: linear-gradient(
|
||||
to right,
|
||||
var(--original-color) 0%,
|
||||
var(--original-color) calc(var(--originals-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--originals-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--originals-percentage) + var(--gap)),
|
||||
var(--reply-to-color) calc(var(--originals-percentage) + var(--gap)),
|
||||
var(--reply-to-color) calc(var(--replies-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--replies-percentage) - var(--gap)),
|
||||
var(--gap-color) calc(var(--replies-percentage) + var(--gap)),
|
||||
var(--reblog-color) calc(var(--replies-percentage) + var(--gap)),
|
||||
var(--reblog-color) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.posting-stats-legends {
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.posting-stats-legend-item {
|
||||
display: inline-block;
|
||||
width: var(--size);
|
||||
height: var(--size);
|
||||
border-radius: var(--size);
|
||||
background-color: var(--text-insignificant-color);
|
||||
vertical-align: middle;
|
||||
margin: 0 4px 2px;
|
||||
/* border: 1px solid var(--outline-color); */
|
||||
box-shadow: inset 0 0 0 1px var(--outline-color),
|
||||
inset 0 0 0 1.5px var(--bg-blur-color);
|
||||
|
||||
&.posting-stats-legend-item-originals {
|
||||
background-color: var(--original-color);
|
||||
}
|
||||
&.posting-stats-legend-item-replies {
|
||||
background-color: var(--reply-to-color);
|
||||
}
|
||||
&.posting-stats-legend-item-boosts {
|
||||
background-color: var(--reblog-color);
|
||||
}
|
||||
.loader-container {
|
||||
margin: 0;
|
||||
opacity: 0.5;
|
||||
transform: scale(0.75);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes shine {
|
||||
@keyframes wobble {
|
||||
0% {
|
||||
left: -100%;
|
||||
transform: rotate(-4deg);
|
||||
}
|
||||
100% {
|
||||
left: 100%;
|
||||
transform: rotate(4deg);
|
||||
}
|
||||
}
|
||||
.timeline-start .account-container {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.timeline-start .account-container:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: linear-gradient(
|
||||
100deg,
|
||||
rgba(255, 255, 255, 0) 30%,
|
||||
rgba(255, 255, 255, 0.25),
|
||||
rgba(255, 255, 255, 0) 70%
|
||||
);
|
||||
top: 0;
|
||||
left: -100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.timeline-start .account-container:before {
|
||||
opacity: 0.25;
|
||||
@keyframes loading-spin {
|
||||
0% {
|
||||
transform: rotate(0deg) scale(0.75);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg) scale(0.75);
|
||||
}
|
||||
}
|
||||
.timeline-start .account-container:hover:before {
|
||||
animation: shine 1s ease-in-out 1s;
|
||||
.posting-stats-icon {
|
||||
display: inline-block;
|
||||
width: 24px;
|
||||
height: 8px;
|
||||
filter: opacity(0.75);
|
||||
animation: wobble 2s linear both infinite alternate !important;
|
||||
|
||||
&.loading {
|
||||
animation: loading-spin 0.35s linear both infinite !important;
|
||||
}
|
||||
}
|
||||
|
||||
#list-add-remove-container .list-add-remove {
|
||||
|
@ -477,6 +719,7 @@
|
|||
|
||||
@media (min-width: 40em) {
|
||||
.timeline-start .account-container {
|
||||
--banner-overlap: 77px;
|
||||
--item-radius: 16px;
|
||||
border: 1px solid var(--divider-color);
|
||||
margin: 16px 0;
|
||||
|
@ -493,9 +736,9 @@
|
|||
var(--shadow-offset) var(--shadow-offset) var(--shadow-blur)
|
||||
var(--shadow-spread) var(--header-color-2, var(--drop-shadow-color));
|
||||
}
|
||||
.timeline-start .account-container .header-banner {
|
||||
/* .timeline-start .account-container .header-banner {
|
||||
margin-bottom: -77px;
|
||||
}
|
||||
} */
|
||||
.timeline-start .account-container header .account-block {
|
||||
font-size: 175%;
|
||||
/* margin-bottom: -8px; */
|
||||
|
@ -511,3 +754,135 @@
|
|||
drop-shadow(8px 0 8px var(--header-color-4, --bg-color));
|
||||
}
|
||||
}
|
||||
|
||||
#private-note-container {
|
||||
textarea {
|
||||
margin-top: 8px;
|
||||
width: 100%;
|
||||
resize: vertical;
|
||||
height: 33vh;
|
||||
min-height: 25vh;
|
||||
max-height: 50vh;
|
||||
color: var(--private-note-text-color);
|
||||
background-color: var(--private-note-bg-color);
|
||||
border: 1px solid var(--private-note-border-color);
|
||||
box-shadow: 0 2px 8px var(--drop-shadow-color);
|
||||
border-radius: 0;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 8px 0;
|
||||
|
||||
* {
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#edit-profile-container {
|
||||
p {
|
||||
margin-block: 8px;
|
||||
}
|
||||
|
||||
label {
|
||||
input,
|
||||
textarea {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
min-height: 5em;
|
||||
max-height: 50vh;
|
||||
}
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
color: var(--text-insignificant-color);
|
||||
font-weight: normal;
|
||||
font-size: 0.8em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
tbody tr td:first-child {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 8px 0;
|
||||
|
||||
* {
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.handle-info {
|
||||
.handle-handle {
|
||||
display: inline-block;
|
||||
margin-block: 5px;
|
||||
|
||||
b {
|
||||
font-weight: 600;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
display: inline-block;
|
||||
box-shadow: 0 0 0 5px var(--bg-blur-color);
|
||||
|
||||
&.handle-username {
|
||||
color: var(--orange-fg-color);
|
||||
background-color: var(--orange-bg-color);
|
||||
}
|
||||
|
||||
&.handle-server {
|
||||
color: var(--purple-fg-color);
|
||||
background-color: var(--purple-bg-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.handle-at {
|
||||
display: inline-block;
|
||||
margin-inline: -3px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.handle-legend {
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
|
||||
.handle-legend-icon {
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 4px solid transparent;
|
||||
border-radius: 8px;
|
||||
background-clip: padding-box;
|
||||
|
||||
&.username {
|
||||
background-color: var(--orange-fg-color);
|
||||
border-color: var(--orange-bg-color);
|
||||
}
|
||||
&.server {
|
||||
background-color: var(--purple-fg-color);
|
||||
border-color: var(--purple-bg-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Plik diff jest za duży
Load Diff
|
@ -2,6 +2,7 @@ import { useEffect } from 'preact/hooks';
|
|||
|
||||
import { api } from '../utils/api';
|
||||
import states from '../utils/states';
|
||||
import useLocationChange from '../utils/useLocationChange';
|
||||
|
||||
import AccountInfo from './account-info';
|
||||
import Icon from './icon';
|
||||
|
@ -16,17 +17,19 @@ function AccountSheet({ account, instance: propInstance, onClose }) {
|
|||
}
|
||||
}, [account]);
|
||||
|
||||
useLocationChange(onClose);
|
||||
|
||||
return (
|
||||
<div
|
||||
class="sheet"
|
||||
onClick={(e) => {
|
||||
const accountBlock = e.target.closest('.account-block');
|
||||
if (accountBlock) {
|
||||
onClose({
|
||||
destination: 'account-statuses',
|
||||
});
|
||||
}
|
||||
}}
|
||||
// onClick={(e) => {
|
||||
// const accountBlock = e.target.closest('.account-block');
|
||||
// if (accountBlock) {
|
||||
// onClose({
|
||||
// destination: 'account-statuses',
|
||||
// });
|
||||
// }
|
||||
// }}
|
||||
>
|
||||
{!!onClose && (
|
||||
<button type="button" class="sheet-close outer" onClick={onClose}>
|
||||
|
@ -46,7 +49,7 @@ function AccountSheet({ account, instance: propInstance, onClose }) {
|
|||
});
|
||||
return info;
|
||||
} catch (e) {
|
||||
const result = await masto.v2.search({
|
||||
const result = await masto.v2.search.fetch({
|
||||
q: account,
|
||||
type: 'accounts',
|
||||
limit: 1,
|
||||
|
@ -56,8 +59,12 @@ function AccountSheet({ account, instance: propInstance, onClose }) {
|
|||
return result.accounts[0];
|
||||
} else if (/https?:\/\/[^/]+\/@/.test(account)) {
|
||||
const accountURL = new URL(account);
|
||||
const acct = accountURL.pathname.replace(/^\//, '');
|
||||
const result = await masto.v2.search({
|
||||
const { hostname, pathname } = accountURL;
|
||||
const acct =
|
||||
pathname.replace(/^\//, '').replace(/\/$/, '') +
|
||||
'@' +
|
||||
hostname;
|
||||
const result = await masto.v2.search.fetch({
|
||||
q: acct,
|
||||
type: 'accounts',
|
||||
limit: 1,
|
||||
|
|
|
@ -8,23 +8,31 @@
|
|||
box-shadow: 0 0 0 1px var(--bg-blur-color);
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.avatar.has-alpha {
|
||||
border-radius: 0;
|
||||
}
|
||||
.avatar:not(.has-alpha).squircle {
|
||||
border-radius: 25%;
|
||||
}
|
||||
|
||||
.avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
background-color: var(--img-bg-color);
|
||||
}
|
||||
&.has-alpha {
|
||||
border-radius: 0;
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
|
||||
.avatar[data-loaded],
|
||||
.avatar[data-loaded] img {
|
||||
box-shadow: none;
|
||||
background-color: transparent;
|
||||
img {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
&:not(.has-alpha).squircle {
|
||||
border-radius: 25%;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
background-color: var(--img-bg-color);
|
||||
contain: none;
|
||||
}
|
||||
|
||||
&[data-loaded],
|
||||
&[data-loaded] img {
|
||||
box-shadow: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ import './avatar.css';
|
|||
|
||||
import { useRef } from 'preact/hooks';
|
||||
|
||||
import mem from '../utils/mem';
|
||||
|
||||
const SIZES = {
|
||||
s: 16,
|
||||
m: 20,
|
||||
|
@ -19,6 +21,7 @@ const canvas = window.OffscreenCanvas
|
|||
const ctx = canvas.getContext('2d', {
|
||||
willReadFrequently: true,
|
||||
});
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
|
||||
function Avatar({ url, size, alt = '', squircle, ...props }) {
|
||||
size = SIZES[size] || size || SIZES.m;
|
||||
|
@ -60,29 +63,32 @@ function Avatar({ url, size, alt = '', squircle, ...props }) {
|
|||
if (avatarRef.current) avatarRef.current.dataset.loaded = true;
|
||||
if (alphaCache[url] !== undefined) return;
|
||||
if (isMissing) return;
|
||||
try {
|
||||
// Check if image has alpha channel
|
||||
const { width, height } = e.target;
|
||||
if (canvas.width !== width) canvas.width = width;
|
||||
if (canvas.height !== height) canvas.height = height;
|
||||
ctx.drawImage(e.target, 0, 0);
|
||||
const allPixels = ctx.getImageData(0, 0, width, height);
|
||||
// At least 10% of pixels have alpha <= 128
|
||||
const hasAlpha =
|
||||
allPixels.data.filter((pixel, i) => i % 4 === 3 && pixel <= 128)
|
||||
.length /
|
||||
(allPixels.data.length / 4) >
|
||||
0.1;
|
||||
if (hasAlpha) {
|
||||
// console.log('hasAlpha', hasAlpha, allPixels.data);
|
||||
avatarRef.current.classList.add('has-alpha');
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// Check if image has alpha channel
|
||||
const { width, height } = e.target;
|
||||
if (canvas.width !== width) canvas.width = width;
|
||||
if (canvas.height !== height) canvas.height = height;
|
||||
ctx.drawImage(e.target, 0, 0);
|
||||
const allPixels = ctx.getImageData(0, 0, width, height);
|
||||
// At least 10% of pixels have alpha <= 128
|
||||
const hasAlpha =
|
||||
allPixels.data.filter(
|
||||
(pixel, i) => i % 4 === 3 && pixel <= 128,
|
||||
).length /
|
||||
(allPixels.data.length / 4) >
|
||||
0.1;
|
||||
if (hasAlpha) {
|
||||
// console.log('hasAlpha', hasAlpha, allPixels.data);
|
||||
avatarRef.current.classList.add('has-alpha');
|
||||
}
|
||||
alphaCache[url] = hasAlpha;
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
} catch (e) {
|
||||
// Silent fail
|
||||
alphaCache[url] = false;
|
||||
}
|
||||
alphaCache[url] = hasAlpha;
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
} catch (e) {
|
||||
// Silent fail
|
||||
alphaCache[url] = false;
|
||||
}
|
||||
}, 1);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
@ -90,4 +96,4 @@ function Avatar({ url, size, alt = '', squircle, ...props }) {
|
|||
);
|
||||
}
|
||||
|
||||
export default Avatar;
|
||||
export default mem(Avatar);
|
||||
|
|
|
@ -1,75 +1,101 @@
|
|||
import { memo } from 'preact/compat';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
import showToast from '../utils/show-toast';
|
||||
import states, { saveStatus } from '../utils/states';
|
||||
import useInterval from '../utils/useInterval';
|
||||
import usePageVisibility from '../utils/usePageVisibility';
|
||||
|
||||
const STREAMING_TIMEOUT = 1000 * 3; // 3 seconds
|
||||
const POLL_INTERVAL = 15_000; // 15 seconds
|
||||
|
||||
export default memo(function BackgroundService({ isLoggedIn }) {
|
||||
// Notifications service
|
||||
// - WebSocket to receive notifications when page is visible
|
||||
const [visible, setVisible] = useState(true);
|
||||
usePageVisibility(setVisible);
|
||||
const notificationStream = useRef();
|
||||
useEffect(() => {
|
||||
if (isLoggedIn && visible) {
|
||||
const { masto, instance } = api();
|
||||
(async () => {
|
||||
// 1. Get the latest notification
|
||||
if (states.notificationsLast) {
|
||||
const notificationsIterator = masto.v1.notifications.list({
|
||||
limit: 1,
|
||||
since_id: states.notificationsLast.id,
|
||||
});
|
||||
const { value: notifications } = await notificationsIterator.next();
|
||||
if (notifications?.length) {
|
||||
let lastReadId;
|
||||
try {
|
||||
const markers = await masto.v1.markers.fetch({
|
||||
timeline: 'notifications',
|
||||
});
|
||||
lastReadId = markers?.notifications?.lastReadId;
|
||||
} catch (e) {}
|
||||
if (lastReadId) {
|
||||
if (notifications[0].id !== lastReadId) {
|
||||
states.notificationsShowNew = true;
|
||||
}
|
||||
} else {
|
||||
states.notificationsShowNew = true;
|
||||
}
|
||||
const checkLatestNotification = async (masto, instance, skipCheckMarkers) => {
|
||||
if (states.notificationsLast) {
|
||||
const notificationsIterator = masto.v1.notifications.list({
|
||||
limit: 1,
|
||||
sinceId: states.notificationsLast.id,
|
||||
});
|
||||
const { value: notifications } = await notificationsIterator.next();
|
||||
if (notifications?.length) {
|
||||
if (skipCheckMarkers) {
|
||||
states.notificationsShowNew = true;
|
||||
} else {
|
||||
let lastReadId;
|
||||
try {
|
||||
const markers = await masto.v1.markers.fetch({
|
||||
timeline: 'notifications',
|
||||
});
|
||||
lastReadId = markers?.notifications?.lastReadId;
|
||||
} catch (e) {}
|
||||
if (lastReadId) {
|
||||
states.notificationsShowNew = notifications[0].id !== lastReadId;
|
||||
} else {
|
||||
states.notificationsShowNew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
let sub;
|
||||
let pollNotifications;
|
||||
if (isLoggedIn && visible) {
|
||||
const { masto, streaming, instance } = api();
|
||||
(async () => {
|
||||
// 1. Get the latest notification
|
||||
await checkLatestNotification(masto, instance);
|
||||
|
||||
let hasStreaming = false;
|
||||
// 2. Start streaming
|
||||
notificationStream.current = await masto.ws.stream(
|
||||
'/api/v1/streaming',
|
||||
{
|
||||
stream: 'user:notification',
|
||||
},
|
||||
);
|
||||
console.log('🎏 Streaming notification', notificationStream.current);
|
||||
if (streaming) {
|
||||
pollNotifications = setTimeout(() => {
|
||||
(async () => {
|
||||
try {
|
||||
hasStreaming = true;
|
||||
sub = streaming.user.notification.subscribe();
|
||||
console.log('🎏 Streaming notification', sub);
|
||||
for await (const entry of sub) {
|
||||
if (!sub) break;
|
||||
if (!visible) break;
|
||||
console.log('🔔🔔 Notification entry', entry);
|
||||
if (entry.event === 'notification') {
|
||||
console.log('🔔🔔 Notification', entry);
|
||||
saveStatus(entry.payload, instance, {
|
||||
skipThreading: true,
|
||||
});
|
||||
}
|
||||
states.notificationsShowNew = true;
|
||||
}
|
||||
console.log('💥 Streaming notification loop STOPPED');
|
||||
} catch (e) {
|
||||
hasStreaming = false;
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
notificationStream.current.on('notification', (notification) => {
|
||||
console.log('🔔🔔 Notification', notification);
|
||||
if (notification.status) {
|
||||
saveStatus(notification.status, instance, {
|
||||
skipThreading: true,
|
||||
});
|
||||
}
|
||||
states.notificationsShowNew = true;
|
||||
});
|
||||
|
||||
notificationStream.current.ws.onclose = () => {
|
||||
console.log('🔔🔔 Notification stream closed');
|
||||
};
|
||||
if (!hasStreaming) {
|
||||
console.log('🎏 Streaming failed, fallback to polling');
|
||||
pollNotifications = setInterval(() => {
|
||||
checkLatestNotification(masto, instance, true);
|
||||
}, POLL_INTERVAL);
|
||||
}
|
||||
})();
|
||||
}, STREAMING_TIMEOUT);
|
||||
}
|
||||
})();
|
||||
}
|
||||
return () => {
|
||||
if (notificationStream.current) {
|
||||
notificationStream.current.ws.close();
|
||||
notificationStream.current = null;
|
||||
}
|
||||
sub?.unsubscribe?.();
|
||||
sub = null;
|
||||
clearTimeout(pollNotifications);
|
||||
clearInterval(pollNotifications);
|
||||
};
|
||||
}, [visible, isLoggedIn]);
|
||||
|
||||
|
@ -102,5 +128,14 @@ export default memo(function BackgroundService({ isLoggedIn }) {
|
|||
}
|
||||
});
|
||||
|
||||
// Global keyboard shortcuts "service"
|
||||
useHotkeys('shift+alt+k', () => {
|
||||
const currentCloakMode = states.settings.cloakMode;
|
||||
states.settings.cloakMode = !currentCloakMode;
|
||||
showToast({
|
||||
text: `Cloak mode ${currentCloakMode ? 'disabled' : 'enabled'}`,
|
||||
});
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ import List from '../pages/list';
|
|||
import Mentions from '../pages/mentions';
|
||||
import Notifications from '../pages/notifications';
|
||||
import Public from '../pages/public';
|
||||
import Search from '../pages/search';
|
||||
import Trending from '../pages/trending';
|
||||
import states from '../utils/states';
|
||||
import useTitle from '../utils/useTitle';
|
||||
|
@ -33,8 +34,13 @@ function Columns() {
|
|||
hashtag: Hashtag,
|
||||
mentions: Mentions,
|
||||
trending: Trending,
|
||||
search: Search,
|
||||
}[type];
|
||||
if (!Component) return null;
|
||||
// Don't show Search column with no query, for now
|
||||
if (type === 'search' && !params.query) return null;
|
||||
// Don't show List column with no list, for now
|
||||
if (type === 'list' && !params.id) return null;
|
||||
return (
|
||||
<Component key={type + JSON.stringify(params)} {...params} columnMode />
|
||||
);
|
||||
|
@ -49,7 +55,24 @@ function Columns() {
|
|||
}
|
||||
});
|
||||
|
||||
return <div id="columns">{components}</div>;
|
||||
return (
|
||||
<div
|
||||
id="columns"
|
||||
onContextMenu={(e) => {
|
||||
// If right-click on header, but not links or buttons
|
||||
if (
|
||||
e.target.closest('.deck > header') &&
|
||||
!e.target.closest('a') &&
|
||||
!e.target.closest('button')
|
||||
) {
|
||||
e.preventDefault();
|
||||
states.showShortcutsSettings = true;
|
||||
}
|
||||
}}
|
||||
>
|
||||
{components}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Columns;
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
import openCompose from '../utils/open-compose';
|
||||
import openOSK from '../utils/open-osk';
|
||||
import states from '../utils/states';
|
||||
|
||||
import Icon from './icon';
|
||||
|
||||
export default function ComposeButton() {
|
||||
const snapStates = useSnapshot(states);
|
||||
|
||||
function handleButton(e) {
|
||||
if (snapStates.composerState.minimized) {
|
||||
states.composerState.minimized = false;
|
||||
openOSK();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey) {
|
||||
const newWin = openCompose();
|
||||
|
||||
if (!newWin) {
|
||||
alert('Looks like your browser is blocking popups.');
|
||||
states.showCompose = true;
|
||||
}
|
||||
} else {
|
||||
openOSK();
|
||||
states.showCompose = true;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +37,14 @@ export default function ComposeButton() {
|
|||
});
|
||||
|
||||
return (
|
||||
<button type="button" id="compose-button" onClick={handleButton}>
|
||||
<button
|
||||
type="button"
|
||||
id="compose-button"
|
||||
onClick={handleButton}
|
||||
class={`${snapStates.composerState.minimized ? 'min' : ''} ${
|
||||
snapStates.composerState.publishing ? 'loading' : ''
|
||||
} ${snapStates.composerState.publishingError ? 'error' : ''}`}
|
||||
>
|
||||
<Icon icon="quill" size="xl" alt="Compose" />
|
||||
</button>
|
||||
);
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
import { shouldPolyfill } from '@formatjs/intl-segmenter/should-polyfill';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
|
||||
import Loader from './loader';
|
||||
|
||||
const supportsIntlSegmenter = !shouldPolyfill();
|
||||
|
||||
function importIntlSegmenter() {
|
||||
if (!supportsIntlSegmenter) {
|
||||
return import('@formatjs/intl-segmenter/polyfill-force').catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
function importCompose() {
|
||||
return import('./compose');
|
||||
}
|
||||
|
||||
export async function preload() {
|
||||
try {
|
||||
await importIntlSegmenter();
|
||||
importCompose();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
export default function ComposeSuspense(props) {
|
||||
const [Compose, setCompose] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
if (supportsIntlSegmenter) {
|
||||
const component = await importCompose();
|
||||
setCompose(component);
|
||||
} else {
|
||||
await importIntlSegmenter();
|
||||
const component = await importCompose();
|
||||
setCompose(component);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return Compose?.default ? <Compose.default {...props} /> : <Loader />;
|
||||
}
|
|
@ -40,28 +40,6 @@
|
|||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
#compose-container textarea {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 5em;
|
||||
min-height: 5em;
|
||||
max-height: 50vh;
|
||||
resize: vertical;
|
||||
line-height: 1.4;
|
||||
border-color: transparent;
|
||||
}
|
||||
#compose-container textarea:hover {
|
||||
border-color: var(--divider-color);
|
||||
}
|
||||
|
||||
@media (min-width: 40em) {
|
||||
#compose-container textarea {
|
||||
font-size: 150%;
|
||||
font-size: calc(100% + 50% / var(--text-weight));
|
||||
max-height: 65vh;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes appear-up {
|
||||
0% {
|
||||
opacity: 0;
|
||||
|
@ -117,6 +95,10 @@
|
|||
0 1px 10px var(--bg-color), 0 1px 10px var(--bg-color),
|
||||
0 1px 10px var(--bg-color);
|
||||
z-index: 2;
|
||||
|
||||
strong {
|
||||
color: var(--red-color);
|
||||
}
|
||||
}
|
||||
#_compose-container .status-preview-legend.reply-to {
|
||||
color: var(--reply-to-color);
|
||||
|
@ -129,19 +111,45 @@
|
|||
}
|
||||
|
||||
#compose-container form {
|
||||
border-radius: 16px;
|
||||
padding: 4px 12px;
|
||||
--form-padding-inline: 8px;
|
||||
--form-padding-block: 0;
|
||||
/* border-radius: 16px; */
|
||||
padding: var(--form-padding-block) var(--form-padding-inline);
|
||||
background-color: var(--bg-blur-color);
|
||||
/* background-image: linear-gradient(var(--bg-color) 85%, transparent); */
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
--drop-shadow: 0 3px 6px -3px var(--drop-shadow-color);
|
||||
box-shadow: var(--drop-shadow);
|
||||
|
||||
@media (min-width: 40em) {
|
||||
border-radius: 16px;
|
||||
}
|
||||
}
|
||||
#compose-container .status-preview ~ form {
|
||||
box-shadow: var(--drop-shadow), 0 -3px 6px -3px var(--drop-shadow-color);
|
||||
}
|
||||
|
||||
#compose-container textarea {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 5em;
|
||||
min-height: 5em;
|
||||
max-height: 50vh;
|
||||
resize: vertical;
|
||||
line-height: 1.4;
|
||||
border-color: transparent;
|
||||
|
||||
&.compose-field {
|
||||
@media (min-width: 40em) {
|
||||
max-height: 65vh;
|
||||
}
|
||||
}
|
||||
}
|
||||
#compose-container textarea:hover {
|
||||
border-color: var(--divider-color);
|
||||
}
|
||||
|
||||
#compose-container .toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
@ -200,11 +208,12 @@
|
|||
left: -100vw !important;
|
||||
}
|
||||
#compose-container .toolbar-button select {
|
||||
background-color: inherit;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
padding: 0 0 0 8px;
|
||||
margin: 0;
|
||||
appearance: none;
|
||||
line-height: 1em;
|
||||
}
|
||||
#compose-container .toolbar-button:not(.show-field) select {
|
||||
right: 0;
|
||||
|
@ -269,6 +278,15 @@
|
|||
gap: 8px;
|
||||
align-items: center;
|
||||
font-size: 90%;
|
||||
|
||||
.grow {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.count {
|
||||
font-size: 80%;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
#compose-container .text-expander-menu li b img {
|
||||
/* The shortcode emojis */
|
||||
|
@ -280,19 +298,25 @@
|
|||
height: 2.2em;
|
||||
}
|
||||
#compose-container .text-expander-menu li:is(:hover, :focus, [aria-selected]) {
|
||||
color: var(--bg-color);
|
||||
background-color: var(--link-color);
|
||||
}
|
||||
#compose-container
|
||||
.text-expander-menu:hover
|
||||
li[aria-selected]:not(:hover, :focus) {
|
||||
background-color: var(--link-bg-color);
|
||||
color: var(--text-color);
|
||||
background-color: var(--bg-color);
|
||||
}
|
||||
#compose-container .text-expander-menu li[aria-selected] {
|
||||
box-shadow: inset 4px 0 0 0 var(--button-bg-color);
|
||||
}
|
||||
#compose-container .text-expander-menu li[data-more] {
|
||||
&:not(:hover, :focus, [aria-selected]) {
|
||||
color: var(--text-insignificant-color);
|
||||
background-color: var(--bg-faded-color);
|
||||
}
|
||||
|
||||
font-size: 0.8em;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#compose-container .form-visibility-direct {
|
||||
--yellow-stripes: repeating-linear-gradient(
|
||||
-45deg,
|
||||
135deg,
|
||||
var(--reply-to-faded-color),
|
||||
var(--reply-to-faded-color) 10px,
|
||||
var(--reply-to-faded-color) 10px,
|
||||
|
@ -316,6 +340,21 @@
|
|||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: stretch;
|
||||
|
||||
.media-error {
|
||||
padding: 2px;
|
||||
color: var(--orange-fg-color);
|
||||
background-color: transparent;
|
||||
border: 1.5px dashed transparent;
|
||||
line-height: 1;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
|
||||
&:is(:hover, :focus) {
|
||||
background-color: var(--bg-color);
|
||||
border-color: var(--orange-fg-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#compose-container .media-preview {
|
||||
flex-shrink: 0;
|
||||
|
@ -482,11 +521,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
@media (min-width: 480px) {
|
||||
#compose-container button[type='submit'] {
|
||||
#compose-container button[type='submit'] {
|
||||
border-radius: 8px;
|
||||
@media (min-width: 480px) {
|
||||
padding-inline: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes breathe {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
40% {
|
||||
opacity: 0.4;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
#media-sheet {
|
||||
.media-form {
|
||||
flex: 1;
|
||||
|
@ -500,6 +553,10 @@
|
|||
resize: none;
|
||||
width: 100%;
|
||||
/* height: 10em; */
|
||||
|
||||
&.loading {
|
||||
animation: skeleton-breathe 1.5s linear infinite;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
|
@ -559,42 +616,448 @@
|
|||
} */
|
||||
}
|
||||
|
||||
#mention-sheet {
|
||||
height: 50vh;
|
||||
|
||||
.accounts-list {
|
||||
--list-gap: 1px;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 8px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: var(--list-gap);
|
||||
|
||||
&.loading {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
/* align-items: center; */
|
||||
margin: 0 -8px;
|
||||
padding: 8px;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
justify-content: space-between;
|
||||
border-radius: 8px;
|
||||
/* align-items: center; */
|
||||
|
||||
&:hover {
|
||||
background-image: linear-gradient(
|
||||
to right,
|
||||
transparent 75%,
|
||||
var(--link-bg-color)
|
||||
);
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background-image: linear-gradient(
|
||||
to right,
|
||||
var(--bg-faded-color) 75%,
|
||||
var(--link-bg-color)
|
||||
);
|
||||
}
|
||||
|
||||
&:before {
|
||||
content: '';
|
||||
display: block;
|
||||
border-top: var(--hairline-width) solid var(--divider-color);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 58px;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
&:has(+ li:is(.selected, :hover)):before,
|
||||
&:is(.selected, :hover):before {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
> button {
|
||||
border-radius: 4px;
|
||||
&:hover {
|
||||
outline: 2px solid var(--button-bg-blur-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#custom-emojis-sheet {
|
||||
max-height: 50vh;
|
||||
max-height: 50dvh;
|
||||
|
||||
header {
|
||||
.loader-container {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
form {
|
||||
margin: 8px 0 0;
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
mask-image: none;
|
||||
min-height: 40vh;
|
||||
padding-bottom: 88px;
|
||||
}
|
||||
|
||||
.custom-emojis-matches {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.custom-emojis-list {
|
||||
.section-header {
|
||||
font-size: 80%;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-insignificant-color);
|
||||
padding: 8px 0 4px;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background-color: var(--bg-color);
|
||||
z-index: 1;
|
||||
}
|
||||
section {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
button {
|
||||
color: var(--text-color);
|
||||
border-radius: 8px;
|
||||
background-image: radial-gradient(
|
||||
closest-side,
|
||||
var(--img-bg-color),
|
||||
transparent
|
||||
);
|
||||
text-shadow: 0 1px 0 var(--bg-color);
|
||||
position: relative;
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
font-variant-numeric: slashed-zero;
|
||||
font-feature-settings: 'ss01';
|
||||
|
||||
&[data-title]:after {
|
||||
max-width: 50vw;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
content: attr(data-title);
|
||||
left: 50%;
|
||||
top: 0;
|
||||
background-color: var(--bg-color);
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
border: 1px solid var(--text-color);
|
||||
transform: translate(-50%, -110%);
|
||||
opacity: 0;
|
||||
transition: opacity 0.1s ease-out 0.1s;
|
||||
font-family: var(--monospace-font);
|
||||
line-height: 1;
|
||||
}
|
||||
&.edge-left[data-title]:after {
|
||||
left: 0;
|
||||
transform: translate(0, -110%);
|
||||
}
|
||||
&.edge-right[data-title]:after {
|
||||
left: 100%;
|
||||
transform: translate(-100%, -110%);
|
||||
}
|
||||
|
||||
&:is(:hover, :focus) {
|
||||
z-index: 1;
|
||||
filter: none;
|
||||
background-color: var(--bg-faded-color);
|
||||
|
||||
&[data-title]:after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
transition: transform 0.1s ease-out;
|
||||
}
|
||||
|
||||
&:is(:hover, :focus) img {
|
||||
transform: scale(2);
|
||||
}
|
||||
&.edge-left img {
|
||||
transform-origin: left center;
|
||||
}
|
||||
&.edge-right img {
|
||||
transform-origin: right center;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#custom-emojis-sheet main {
|
||||
mask-image: none;
|
||||
|
||||
.compose-field-container {
|
||||
display: grid !important;
|
||||
|
||||
@media (width < 30em) {
|
||||
margin-inline: calc(-1 * var(--form-padding-inline));
|
||||
width: 100vw !important;
|
||||
max-width: 100vw;
|
||||
|
||||
.compose-field {
|
||||
border-radius: 0;
|
||||
outline-offset: -2px;
|
||||
}
|
||||
}
|
||||
|
||||
&.debug {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
> .compose-field,
|
||||
> .compose-highlight {
|
||||
grid-area: 1 / 1 / 2 / 2;
|
||||
}
|
||||
|
||||
.compose-highlight {
|
||||
user-drag: none;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
touch-action: none;
|
||||
padding: 8px;
|
||||
color: transparent;
|
||||
background-color: transparent;
|
||||
border: 2px solid transparent;
|
||||
line-height: 1.4;
|
||||
overflow: auto;
|
||||
unicode-bidi: plaintext;
|
||||
-webkit-rtl-ordering: logical;
|
||||
rtl-ordering: logical;
|
||||
overflow-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
min-height: 5em;
|
||||
max-height: 50vh;
|
||||
scrollbar-width: none;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Follow textarea styles */
|
||||
@media (min-width: 40em) {
|
||||
max-height: 65vh;
|
||||
}
|
||||
|
||||
mark {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.compose-highlight-url,
|
||||
.compose-highlight-hashtag {
|
||||
background-color: transparent;
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--link-faded-color);
|
||||
text-decoration-thickness: 2px;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
.compose-highlight-mention,
|
||||
.compose-highlight-emoji-shortcode,
|
||||
.compose-highlight-exceeded {
|
||||
mix-blend-mode: multiply;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 0 0 1px;
|
||||
}
|
||||
.compose-highlight-mention {
|
||||
background-color: var(--orange-light-bg-color);
|
||||
box-shadow-color: var(--orange-light-bg-color);
|
||||
}
|
||||
.compose-highlight-emoji-shortcode {
|
||||
background-color: var(--bg-faded-color);
|
||||
box-shadow-color: var(--bg-faded-color);
|
||||
}
|
||||
.compose-highlight-exceeded {
|
||||
background-color: var(--red-bg-color);
|
||||
box-shadow-color: var(--red-bg-color);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.compose-highlight-mention,
|
||||
.compose-highlight-emoji-shortcode,
|
||||
.compose-highlight-exceeded {
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#custom-emojis-sheet .custom-emojis-list .section-header {
|
||||
font-size: 80%;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-insignificant-color);
|
||||
padding: 8px 0 4px;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background-color: var(--bg-blur-color);
|
||||
backdrop-filter: blur(1px);
|
||||
|
||||
@keyframes gif-shake {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
25% {
|
||||
transform: rotate(5deg);
|
||||
}
|
||||
50% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
75% {
|
||||
transform: rotate(-5deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
#custom-emojis-sheet .custom-emojis-list section {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.gif-picker-button {
|
||||
span {
|
||||
font-weight: bold;
|
||||
font-size: 11.5px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&:is(:hover, :focus) {
|
||||
span {
|
||||
animation: gif-shake 0.3s 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
#custom-emojis-sheet .custom-emojis-list button {
|
||||
border-radius: 8px;
|
||||
background-image: radial-gradient(
|
||||
closest-side,
|
||||
var(--img-bg-color),
|
||||
transparent
|
||||
);
|
||||
}
|
||||
#custom-emojis-sheet .custom-emojis-list button:is(:hover, :focus) {
|
||||
filter: none;
|
||||
background-color: var(--bg-faded-color);
|
||||
}
|
||||
#custom-emojis-sheet .custom-emojis-list button img {
|
||||
transition: transform 0.1s ease-out;
|
||||
}
|
||||
#custom-emojis-sheet .custom-emojis-list button:is(:hover, :focus) img {
|
||||
transform: scale(1.5);
|
||||
|
||||
#gif-picker-sheet {
|
||||
height: 50vh;
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
input[type='search'] {
|
||||
flex-grow: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
mask-image: linear-gradient(
|
||||
to right,
|
||||
transparent 2px,
|
||||
black 16px,
|
||||
black calc(100% - 16px),
|
||||
transparent calc(100% - 2px)
|
||||
);
|
||||
|
||||
@media (min-height: 480px) {
|
||||
overflow-y: auto;
|
||||
max-height: 50vh;
|
||||
}
|
||||
|
||||
&.loading {
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
.ui-state {
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
ul {
|
||||
min-height: 100px;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
list-style: none;
|
||||
padding: 8px 2px;
|
||||
margin: 0;
|
||||
|
||||
@media (min-height: 480px) {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
grid-auto-rows: 1fr;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
max-width: 100%;
|
||||
display: flex;
|
||||
|
||||
button {
|
||||
padding: 4px;
|
||||
margin: 0;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
background-color: var(--bg-faded-color);
|
||||
|
||||
@media (min-height: 480px) {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&:is(:hover, :focus) {
|
||||
background-color: var(--link-bg-color);
|
||||
box-shadow: 0 0 0 2px var(--link-light-color);
|
||||
filter: none;
|
||||
}
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: var(--figure-width);
|
||||
max-width: 100%;
|
||||
|
||||
@media (min-height: 480px) {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
font-size: 0.8em;
|
||||
padding: 2px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--text-insignificant-color);
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
background-color: var(--img-bg-color);
|
||||
border-radius: 4px;
|
||||
vertical-align: top;
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
|
||||
@media (min-height: 480px) {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,19 @@
|
|||
export default function CustomEmoji({ staticUrl, alt, url }) {
|
||||
return (
|
||||
<picture>
|
||||
{staticUrl && (
|
||||
<source srcset={staticUrl} media="(prefers-reduced-motion: reduce)" />
|
||||
)}
|
||||
<img
|
||||
key={alt || url}
|
||||
src={url}
|
||||
alt={alt}
|
||||
class="shortcode-emoji emoji"
|
||||
width="16"
|
||||
height="16"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</picture>
|
||||
);
|
||||
}
|
|
@ -128,9 +128,9 @@ function Drafts({ onClose }) {
|
|||
if (replyTo) {
|
||||
setUIState('loading');
|
||||
try {
|
||||
replyToStatus = await masto.v1.statuses.fetch(
|
||||
replyTo.id,
|
||||
);
|
||||
replyToStatus = await masto.v1.statuses
|
||||
.$select(replyTo.id)
|
||||
.fetch();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('Error fetching reply-to status!');
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
.embed-modal-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
pointer-events: none;
|
||||
|
||||
.top-controls {
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: space-between;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.embed-content {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
iframe {
|
||||
pointer-events: auto;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: max(var(--width), 480px);
|
||||
height: auto;
|
||||
aspect-ratio: var(--aspect-ratio);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
import './embed-modal.css';
|
||||
|
||||
import Icon from './icon';
|
||||
|
||||
function EmbedModal({ html, url, width, height, onClose = () => {} }) {
|
||||
return (
|
||||
<div class="embed-modal-container">
|
||||
<div class="top-controls">
|
||||
<button type="button" class="light" onClick={() => onClose()}>
|
||||
<Icon icon="x" />
|
||||
</button>
|
||||
{url && (
|
||||
<a
|
||||
href={url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="button plain"
|
||||
>
|
||||
<span>Open link</span> <Icon icon="external" />
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
class="embed-content"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
style={{
|
||||
'--width': width + 'px',
|
||||
'--height': height + 'px',
|
||||
'--aspect-ratio': `${width}/${height}`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default EmbedModal;
|
|
@ -1,3 +1,7 @@
|
|||
import { memo } from 'preact/compat';
|
||||
|
||||
import CustomEmoji from './custom-emoji';
|
||||
|
||||
function EmojiText({ text, emojis }) {
|
||||
if (!text) return '';
|
||||
if (!emojis?.length) return text;
|
||||
|
@ -10,25 +14,16 @@ function EmojiText({ text, emojis }) {
|
|||
const emoji = emojis.find((e) => e.shortcode === word);
|
||||
if (emoji) {
|
||||
const { url, staticUrl } = emoji;
|
||||
return (
|
||||
<picture>
|
||||
<source srcset={staticUrl} media="(prefers-reduced-motion: reduce)" />
|
||||
<img
|
||||
key={word}
|
||||
src={url}
|
||||
alt={word}
|
||||
class="shortcode-emoji emoji"
|
||||
width="16"
|
||||
height="16"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</picture>
|
||||
);
|
||||
return <CustomEmoji staticUrl={staticUrl} alt={word} url={url} />;
|
||||
}
|
||||
return word;
|
||||
});
|
||||
return elements;
|
||||
}
|
||||
|
||||
export default EmojiText;
|
||||
export default memo(
|
||||
EmojiText,
|
||||
(oldProps, newProps) =>
|
||||
oldProps.text === newProps.text &&
|
||||
oldProps.emojis?.length === newProps.emojis?.length,
|
||||
);
|
||||
|
|
|
@ -17,13 +17,15 @@ function FollowRequestButtons({ accountID, onChange }) {
|
|||
<p class="follow-request-buttons">
|
||||
<button
|
||||
type="button"
|
||||
disabled={uiState === 'loading'}
|
||||
disabled={uiState === 'loading' || hasRelationship}
|
||||
onClick={() => {
|
||||
setUIState('loading');
|
||||
setRequestState('accept');
|
||||
(async () => {
|
||||
try {
|
||||
const rel = await masto.v1.followRequests.authorize(accountID);
|
||||
const rel = await masto.v1.followRequests
|
||||
.$select(accountID)
|
||||
.authorize();
|
||||
if (!rel?.followedBy) {
|
||||
throw new Error('Follow request not accepted');
|
||||
}
|
||||
|
@ -40,14 +42,16 @@ function FollowRequestButtons({ accountID, onChange }) {
|
|||
</button>{' '}
|
||||
<button
|
||||
type="button"
|
||||
disabled={uiState === 'loading'}
|
||||
disabled={uiState === 'loading' || hasRelationship}
|
||||
class="light danger"
|
||||
onClick={() => {
|
||||
setUIState('loading');
|
||||
setRequestState('reject');
|
||||
(async () => {
|
||||
try {
|
||||
const rel = await masto.v1.followRequests.reject(accountID);
|
||||
const rel = await masto.v1.followRequests
|
||||
.$select(accountID)
|
||||
.reject();
|
||||
if (rel?.followedBy) {
|
||||
throw new Error('Follow request not rejected');
|
||||
}
|
||||
|
|
|
@ -1,5 +1,41 @@
|
|||
#generic-accounts-container {
|
||||
.post-preview {
|
||||
--max-height: 120px;
|
||||
max-height: var(--max-height);
|
||||
overflow: hidden;
|
||||
margin-block: 8px;
|
||||
border: 1px solid var(--outline-color);
|
||||
border-radius: 8px;
|
||||
pointer-events: none;
|
||||
|
||||
.status {
|
||||
font-size: calc(var(--text-size) * 0.9);
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
black calc(var(--max-height) / 2),
|
||||
transparent calc(var(--max-height) - 8px)
|
||||
);
|
||||
filter: saturate(0.5);
|
||||
}
|
||||
|
||||
&:is(a) {
|
||||
pointer-events: auto;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--outline-hover-color);
|
||||
}
|
||||
|
||||
> * {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.accounts-list {
|
||||
--list-gap: 16px;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 8px 0;
|
||||
|
@ -7,29 +43,46 @@
|
|||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
column-gap: 1.5em;
|
||||
row-gap: 16px;
|
||||
row-gap: var(--list-gap);
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
flex-basis: 16em;
|
||||
align-items: center;
|
||||
/* align-items: center; */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
gap: 8px;
|
||||
|
||||
position: relative;
|
||||
|
||||
&:before {
|
||||
content: '';
|
||||
display: block;
|
||||
border-top: var(--hairline-width) solid var(--divider-color);
|
||||
position: absolute;
|
||||
bottom: calc(-1 * var(--list-gap) / 2);
|
||||
left: 40px;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
&:has(.reactions-block):before {
|
||||
/* avatar + reactions + gap */
|
||||
left: calc(40px + 16px + 8px);
|
||||
}
|
||||
}
|
||||
|
||||
.account-block-acct {
|
||||
font-size: 80%;
|
||||
font-size: 0.9em;
|
||||
color: var(--text-insignificant-color);
|
||||
display: block;
|
||||
/* display: block; */
|
||||
}
|
||||
}
|
||||
|
||||
.reactions-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-self: center;
|
||||
/* align-self: center; */
|
||||
|
||||
.favourite-icon {
|
||||
color: var(--favourite-color);
|
||||
|
@ -38,5 +91,21 @@
|
|||
.reblog-icon {
|
||||
color: var(--reblog-color);
|
||||
}
|
||||
|
||||
> .icon:only-child {
|
||||
margin-top: 8px; /* half of icon dimension */
|
||||
}
|
||||
}
|
||||
|
||||
.account-relationships {
|
||||
flex-grow: 1;
|
||||
|
||||
.tag {
|
||||
animation: appear 0.3s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
.account-block {
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,37 @@
|
|||
import './generic-accounts.css';
|
||||
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { InView } from 'react-intersection-observer';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
import { fetchRelationships } from '../utils/relationships';
|
||||
import states from '../utils/states';
|
||||
import useLocationChange from '../utils/useLocationChange';
|
||||
|
||||
import AccountBlock from './account-block';
|
||||
import Icon from './icon';
|
||||
import Link from './link';
|
||||
import Loader from './loader';
|
||||
import Status from './status';
|
||||
|
||||
export default function GenericAccounts({ onClose = () => {} }) {
|
||||
export default function GenericAccounts({
|
||||
instance,
|
||||
excludeRelationshipAttrs = [],
|
||||
postID,
|
||||
onClose = () => {},
|
||||
blankCopy = 'Nothing to show',
|
||||
}) {
|
||||
const { masto, instance: currentInstance } = api();
|
||||
const isCurrentInstance = instance ? instance === currentInstance : true;
|
||||
const snapStates = useSnapshot(states);
|
||||
``;
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [accounts, setAccounts] = useState([]);
|
||||
const [showMore, setShowMore] = useState(false);
|
||||
|
||||
useLocationChange(onClose);
|
||||
|
||||
if (!snapStates.showGenericAccounts) {
|
||||
return null;
|
||||
}
|
||||
|
@ -28,6 +44,20 @@ export default function GenericAccounts({ onClose = () => {} }) {
|
|||
showReactions,
|
||||
} = snapStates.showGenericAccounts;
|
||||
|
||||
const [relationshipsMap, setRelationshipsMap] = useState({});
|
||||
|
||||
const loadRelationships = async (accounts) => {
|
||||
if (!accounts?.length) return;
|
||||
if (!isCurrentInstance) return;
|
||||
const relationships = await fetchRelationships(accounts, relationshipsMap);
|
||||
if (relationships) {
|
||||
setRelationshipsMap({
|
||||
...relationshipsMap,
|
||||
...relationships,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const loadAccounts = (firstLoad) => {
|
||||
if (!fetchAccounts) return;
|
||||
if (firstLoad) setAccounts([]);
|
||||
|
@ -37,11 +67,41 @@ export default function GenericAccounts({ onClose = () => {} }) {
|
|||
const { done, value } = await fetchAccounts(firstLoad);
|
||||
if (Array.isArray(value)) {
|
||||
if (firstLoad) {
|
||||
setAccounts(value);
|
||||
const accounts = [];
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const account = value[i];
|
||||
const theAccount = accounts.find(
|
||||
(a, j) => a.id === account.id && i !== j,
|
||||
);
|
||||
if (!theAccount) {
|
||||
accounts.push({
|
||||
_types: [],
|
||||
...account,
|
||||
});
|
||||
} else {
|
||||
theAccount._types.push(...account._types);
|
||||
}
|
||||
}
|
||||
setAccounts(accounts);
|
||||
} else {
|
||||
setAccounts((prev) => [...prev, ...value]);
|
||||
// setAccounts((prev) => [...prev, ...value]);
|
||||
// Merge accounts by id and _types
|
||||
setAccounts((prev) => {
|
||||
const newAccounts = prev;
|
||||
for (const account of value) {
|
||||
const theAccount = newAccounts.find((a) => a.id === account.id);
|
||||
if (!theAccount) {
|
||||
newAccounts.push(account);
|
||||
} else {
|
||||
theAccount._types.push(...account._types);
|
||||
}
|
||||
}
|
||||
return newAccounts;
|
||||
});
|
||||
}
|
||||
setShowMore(!done);
|
||||
|
||||
loadRelationships(value);
|
||||
} else {
|
||||
setShowMore(false);
|
||||
}
|
||||
|
@ -53,15 +113,19 @@ export default function GenericAccounts({ onClose = () => {} }) {
|
|||
})();
|
||||
};
|
||||
|
||||
const firstLoad = useRef(true);
|
||||
useEffect(() => {
|
||||
if (staticAccounts?.length > 0) {
|
||||
setAccounts(staticAccounts);
|
||||
loadRelationships(staticAccounts);
|
||||
} else {
|
||||
loadAccounts(true);
|
||||
firstLoad.current = false;
|
||||
}
|
||||
}, [staticAccounts, fetchAccounts]);
|
||||
|
||||
useEffect(() => {
|
||||
if (firstLoad.current) return;
|
||||
// reloadGenericAccounts contains value like {id: 'mute', counter: 1}
|
||||
// We only need to reload if the id matches
|
||||
if (snapStates.reloadGenericAccounts?.id === id) {
|
||||
|
@ -69,6 +133,8 @@ export default function GenericAccounts({ onClose = () => {} }) {
|
|||
}
|
||||
}, [snapStates.reloadGenericAccounts.counter]);
|
||||
|
||||
const post = states.statuses[postID];
|
||||
|
||||
return (
|
||||
<div id="generic-accounts-container" class="sheet" tabindex="-1">
|
||||
<button type="button" class="sheet-close" onClick={onClose}>
|
||||
|
@ -78,29 +144,48 @@ export default function GenericAccounts({ onClose = () => {} }) {
|
|||
<h2>{heading || 'Accounts'}</h2>
|
||||
</header>
|
||||
<main>
|
||||
{post && (
|
||||
<Link
|
||||
to={`/${instance || currentInstance}/s/${post.id}`}
|
||||
class="post-preview"
|
||||
>
|
||||
<Status status={post} size="s" readOnly />
|
||||
</Link>
|
||||
)}
|
||||
{accounts.length > 0 ? (
|
||||
<>
|
||||
<ul class="accounts-list">
|
||||
{accounts.map((account) => (
|
||||
<li key={account.id + (account._types || '')}>
|
||||
{showReactions && account._types?.length > 0 && (
|
||||
<div class="reactions-block">
|
||||
{account._types.map((type) => (
|
||||
<Icon
|
||||
icon={
|
||||
{
|
||||
reblog: 'rocket',
|
||||
favourite: 'heart',
|
||||
}[type]
|
||||
}
|
||||
class={`${type}-icon`}
|
||||
/>
|
||||
))}
|
||||
{accounts.map((account) => {
|
||||
const relationship = relationshipsMap[account.id];
|
||||
const key = `${account.id}-${account._types?.length || ''}`;
|
||||
return (
|
||||
<li key={key}>
|
||||
{showReactions && account._types?.length > 0 && (
|
||||
<div class="reactions-block">
|
||||
{account._types.map((type) => (
|
||||
<Icon
|
||||
icon={
|
||||
{
|
||||
reblog: 'rocket',
|
||||
favourite: 'heart',
|
||||
}[type]
|
||||
}
|
||||
class={`${type}-icon`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div class="account-relationships">
|
||||
<AccountBlock
|
||||
account={account}
|
||||
showStats
|
||||
relationship={relationship}
|
||||
excludeRelationshipAttrs={excludeRelationshipAttrs}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<AccountBlock account={account} />
|
||||
</li>
|
||||
))}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{uiState === 'default' ? (
|
||||
showMore ? (
|
||||
|
@ -137,7 +222,7 @@ export default function GenericAccounts({ onClose = () => {} }) {
|
|||
) : uiState === 'error' ? (
|
||||
<p class="ui-state">Error loading accounts</p>
|
||||
) : (
|
||||
<p class="ui-state insignificant">Nothing to show</p>
|
||||
<p class="ui-state insignificant">{blankCopy}</p>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { useEffect, useState } from 'preact/hooks';
|
||||
import moize from 'moize';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
|
||||
import { ICONS } from './ICONS';
|
||||
|
||||
const SIZES = {
|
||||
s: 12,
|
||||
|
@ -8,99 +11,30 @@ const SIZES = {
|
|||
xxl: 32,
|
||||
};
|
||||
|
||||
export const ICONS = {
|
||||
x: () => import('@iconify-icons/mingcute/close-line'),
|
||||
heart: () => import('@iconify-icons/mingcute/heart-line'),
|
||||
bookmark: () => import('@iconify-icons/mingcute/bookmark-line'),
|
||||
'check-circle': () => import('@iconify-icons/mingcute/check-circle-line'),
|
||||
'x-circle': () => import('@iconify-icons/mingcute/close-circle-line'),
|
||||
transfer: () => import('@iconify-icons/mingcute/transfer-4-line'),
|
||||
rocket: () => import('@iconify-icons/mingcute/rocket-line'),
|
||||
'arrow-left': () => import('@iconify-icons/mingcute/arrow-left-line'),
|
||||
'arrow-right': () => import('@iconify-icons/mingcute/arrow-right-line'),
|
||||
'arrow-up': () => import('@iconify-icons/mingcute/arrow-up-line'),
|
||||
'arrow-down': () => import('@iconify-icons/mingcute/arrow-down-line'),
|
||||
earth: () => import('@iconify-icons/mingcute/earth-line'),
|
||||
lock: () => import('@iconify-icons/mingcute/lock-line'),
|
||||
unlock: () => import('@iconify-icons/mingcute/unlock-line'),
|
||||
'eye-close': () => import('@iconify-icons/mingcute/eye-close-line'),
|
||||
'eye-open': () => import('@iconify-icons/mingcute/eye-2-line'),
|
||||
message: () => import('@iconify-icons/mingcute/mail-line'),
|
||||
comment: () => import('@iconify-icons/mingcute/chat-3-line'),
|
||||
home: () => import('@iconify-icons/mingcute/home-3-line'),
|
||||
notification: () => import('@iconify-icons/mingcute/notification-line'),
|
||||
follow: () => import('@iconify-icons/mingcute/user-follow-line'),
|
||||
'follow-add': () => import('@iconify-icons/mingcute/user-add-line'),
|
||||
poll: [() => import('@iconify-icons/mingcute/chart-bar-line'), '90deg'],
|
||||
pencil: () => import('@iconify-icons/mingcute/pencil-line'),
|
||||
quill: () => import('@iconify-icons/mingcute/quill-pen-line'),
|
||||
at: () => import('@iconify-icons/mingcute/at-line'),
|
||||
attachment: () => import('@iconify-icons/mingcute/attachment-line'),
|
||||
upload: () => import('@iconify-icons/mingcute/upload-3-line'),
|
||||
gear: () => import('@iconify-icons/mingcute/settings-3-line'),
|
||||
more: () => import('@iconify-icons/mingcute/more-3-line'),
|
||||
external: () => import('@iconify-icons/mingcute/external-link-line'),
|
||||
popout: () => import('@iconify-icons/mingcute/external-link-line'),
|
||||
popin: [() => import('@iconify-icons/mingcute/external-link-line'), '180deg'],
|
||||
plus: () => import('@iconify-icons/mingcute/add-circle-line'),
|
||||
'chevron-left': () => import('@iconify-icons/mingcute/left-line'),
|
||||
'chevron-right': () => import('@iconify-icons/mingcute/right-line'),
|
||||
'chevron-down': () => import('@iconify-icons/mingcute/down-line'),
|
||||
reply: [
|
||||
() => import('@iconify-icons/mingcute/share-forward-line'),
|
||||
'180deg',
|
||||
'horizontal',
|
||||
],
|
||||
thread: () => import('@iconify-icons/mingcute/route-line'),
|
||||
group: () => import('@iconify-icons/mingcute/group-line'),
|
||||
bot: () => import('@iconify-icons/mingcute/android-2-line'),
|
||||
menu: () => import('@iconify-icons/mingcute/rows-4-line'),
|
||||
list: () => import('@iconify-icons/mingcute/list-check-line'),
|
||||
search: () => import('@iconify-icons/mingcute/search-2-line'),
|
||||
hashtag: () => import('@iconify-icons/mingcute/hashtag-line'),
|
||||
info: () => import('@iconify-icons/mingcute/information-line'),
|
||||
shortcut: () => import('@iconify-icons/mingcute/lightning-line'),
|
||||
user: () => import('@iconify-icons/mingcute/user-4-line'),
|
||||
following: () => import('@iconify-icons/mingcute/walk-line'),
|
||||
pin: () => import('@iconify-icons/mingcute/pin-line'),
|
||||
bus: () => import('@iconify-icons/mingcute/bus-2-line'),
|
||||
link: () => import('@iconify-icons/mingcute/link-2-line'),
|
||||
history: () => import('@iconify-icons/mingcute/history-line'),
|
||||
share: () => import('@iconify-icons/mingcute/share-2-line'),
|
||||
sparkles: () => import('@iconify-icons/mingcute/sparkles-line'),
|
||||
exit: () => import('@iconify-icons/mingcute/exit-line'),
|
||||
translate: () => import('@iconify-icons/mingcute/translate-line'),
|
||||
play: () => import('@iconify-icons/mingcute/play-fill'),
|
||||
trash: () => import('@iconify-icons/mingcute/delete-2-line'),
|
||||
mute: () => import('@iconify-icons/mingcute/volume-mute-line'),
|
||||
unmute: () => import('@iconify-icons/mingcute/volume-line'),
|
||||
block: () => import('@iconify-icons/mingcute/forbid-circle-line'),
|
||||
unblock: [
|
||||
() => import('@iconify-icons/mingcute/forbid-circle-line'),
|
||||
'180deg',
|
||||
],
|
||||
flag: () => import('@iconify-icons/mingcute/flag-4-line'),
|
||||
time: () => import('@iconify-icons/mingcute/time-line'),
|
||||
refresh: () => import('@iconify-icons/mingcute/refresh-2-line'),
|
||||
emoji2: () => import('@iconify-icons/mingcute/emoji-2-line'),
|
||||
filter: () => import('@iconify-icons/mingcute/filter-2-line'),
|
||||
chart: () => import('@iconify-icons/mingcute/chart-line-line'),
|
||||
react: () => import('@iconify-icons/mingcute/react-line'),
|
||||
layout4: () => import('@iconify-icons/mingcute/layout-4-line'),
|
||||
layout5: () => import('@iconify-icons/mingcute/layout-5-line'),
|
||||
announce: () => import('@iconify-icons/mingcute/announcement-line'),
|
||||
alert: () => import('@iconify-icons/mingcute/alert-line'),
|
||||
round: () => import('@iconify-icons/mingcute/round-fill'),
|
||||
'arrow-up-circle': () =>
|
||||
import('@iconify-icons/mingcute/arrow-up-circle-line'),
|
||||
'arrow-down-circle': () =>
|
||||
import('@iconify-icons/mingcute/arrow-down-circle-line'),
|
||||
clipboard: () => import('@iconify-icons/mingcute/clipboard-line'),
|
||||
'account-edit': () => import('@iconify-icons/mingcute/user-edit-line'),
|
||||
'account-warning': () => import('@iconify-icons/mingcute/user-warning-line'),
|
||||
keyboard: () => import('@iconify-icons/mingcute/keyboard-line'),
|
||||
cloud: () => import('@iconify-icons/mingcute/cloud-line'),
|
||||
};
|
||||
const ICONDATA = {};
|
||||
|
||||
// Memoize the dangerouslySetInnerHTML of the SVGs
|
||||
const SVGICon = moize(
|
||||
function ({ width, height, body, rotate, flip }) {
|
||||
return (
|
||||
<svg
|
||||
viewBox={`0 0 ${width} ${height}`}
|
||||
dangerouslySetInnerHTML={{ __html: body }}
|
||||
style={{
|
||||
transform: `${rotate ? `rotate(${rotate})` : ''} ${
|
||||
flip ? `scaleX(-1)` : ''
|
||||
}`,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
},
|
||||
{
|
||||
isShallowEqual: true,
|
||||
maxSize: Object.keys(ICONS).length,
|
||||
matchesArg: (cacheKeyArg, keyArg) =>
|
||||
cacheKeyArg.icon === keyArg.icon && cacheKeyArg.body === keyArg.body,
|
||||
},
|
||||
);
|
||||
|
||||
function Icon({
|
||||
icon,
|
||||
|
@ -114,16 +48,27 @@ function Icon({
|
|||
|
||||
const iconSize = SIZES[size];
|
||||
let iconBlock = ICONS[icon];
|
||||
if (!iconBlock) {
|
||||
console.warn(`Icon ${icon} not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
let rotate, flip;
|
||||
if (Array.isArray(iconBlock)) {
|
||||
[iconBlock, rotate, flip] = iconBlock;
|
||||
}
|
||||
|
||||
const [iconData, setIconData] = useState(null);
|
||||
useEffect(async () => {
|
||||
const icon = await iconBlock();
|
||||
setIconData(icon.default);
|
||||
}, [iconBlock]);
|
||||
const [iconData, setIconData] = useState(ICONDATA[icon]);
|
||||
const currentIcon = useRef(icon);
|
||||
useEffect(() => {
|
||||
if (iconData && currentIcon.current === icon) return;
|
||||
(async () => {
|
||||
const iconB = await iconBlock();
|
||||
setIconData(iconB.default);
|
||||
ICONDATA[icon] = iconB.default;
|
||||
})();
|
||||
currentIcon.current = icon;
|
||||
}, [icon]);
|
||||
|
||||
return (
|
||||
<span
|
||||
|
@ -132,23 +77,28 @@ function Icon({
|
|||
style={{
|
||||
width: `${iconSize}px`,
|
||||
height: `${iconSize}px`,
|
||||
display: 'inline-block',
|
||||
overflow: 'hidden',
|
||||
lineHeight: 0,
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
{iconData && (
|
||||
<svg
|
||||
width={iconSize}
|
||||
height={iconSize}
|
||||
viewBox={`0 0 ${iconData.width} ${iconData.height}`}
|
||||
dangerouslySetInnerHTML={{ __html: iconData.body }}
|
||||
style={{
|
||||
transform: `${rotate ? `rotate(${rotate})` : ''} ${
|
||||
flip ? `scaleX(-1)` : ''
|
||||
}`,
|
||||
}}
|
||||
// <svg
|
||||
// width={iconSize}
|
||||
// height={iconSize}
|
||||
// viewBox={`0 0 ${iconData.width} ${iconData.height}`}
|
||||
// dangerouslySetInnerHTML={{ __html: iconData.body }}
|
||||
// style={{
|
||||
// transform: `${rotate ? `rotate(${rotate})` : ''} ${
|
||||
// flip ? `scaleX(-1)` : ''
|
||||
// }`,
|
||||
// }}
|
||||
// />
|
||||
<SVGICon
|
||||
icon={icon}
|
||||
width={iconData.width}
|
||||
height={iconData.height}
|
||||
body={iconData.body}
|
||||
rotate={rotate}
|
||||
flip={flip}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
import { shouldPolyfill } from '@formatjs/intl-segmenter/should-polyfill';
|
||||
import { Suspense } from 'preact/compat';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
|
||||
import Loader from './loader';
|
||||
|
||||
const supportsIntlSegmenter = !shouldPolyfill();
|
||||
|
||||
// Preload IntlSegmenter
|
||||
setTimeout(() => {
|
||||
queueMicrotask(() => {
|
||||
if (!supportsIntlSegmenter) {
|
||||
import('@formatjs/intl-segmenter/polyfill-force').catch(() => {});
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
export default function IntlSegmenterSuspense({ children }) {
|
||||
if (supportsIntlSegmenter) {
|
||||
return <Suspense fallback={<Loader />}>{children}</Suspense>;
|
||||
}
|
||||
|
||||
const [polyfillLoaded, setPolyfillLoaded] = useState(false);
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
await import('@formatjs/intl-segmenter/polyfill-force');
|
||||
setPolyfillLoaded(true);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return polyfillLoaded ? (
|
||||
<Suspense fallback={<Loader />}>{children}</Suspense>
|
||||
) : (
|
||||
<Loader />
|
||||
);
|
||||
}
|
|
@ -17,7 +17,7 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
}
|
||||
|
||||
useHotkeys(
|
||||
'?, shift+?',
|
||||
'?, shift+?, shift+slash',
|
||||
(e) => {
|
||||
console.log('help');
|
||||
states.showKeyboardShortcutsHelp = true;
|
||||
|
@ -30,24 +30,10 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
},
|
||||
);
|
||||
|
||||
const escRef = useHotkeys('esc', onClose, []);
|
||||
|
||||
return (
|
||||
!!snapStates.showKeyboardShortcutsHelp && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
onClose();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
id="keyboard-shortcuts-help-container"
|
||||
class="sheet"
|
||||
tabindex="-1"
|
||||
ref={escRef}
|
||||
>
|
||||
<Modal onClose={onClose}>
|
||||
<div id="keyboard-shortcuts-help-container" class="sheet" tabindex="-1">
|
||||
<button type="button" class="sheet-close" onClick={onClose}>
|
||||
<Icon icon="x" />
|
||||
</button>
|
||||
|
@ -85,6 +71,10 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
action: 'Load new posts',
|
||||
keys: <kbd>.</kbd>,
|
||||
},
|
||||
{
|
||||
action: 'Open post details',
|
||||
keys: (
|
||||
|
@ -94,7 +84,13 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
),
|
||||
},
|
||||
{
|
||||
action: 'Toggle expanded/collapsed thread',
|
||||
action: (
|
||||
<>
|
||||
Expand content warning or
|
||||
<br />
|
||||
toggle expanded/collapsed thread
|
||||
</>
|
||||
),
|
||||
keys: <kbd>x</kbd>,
|
||||
},
|
||||
{
|
||||
|
@ -117,6 +113,15 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
action: 'Compose new post',
|
||||
keys: <kbd>c</kbd>,
|
||||
},
|
||||
{
|
||||
action: 'Compose new post (new window)',
|
||||
className: 'insignificant',
|
||||
keys: (
|
||||
<>
|
||||
<kbd>Shift</kbd> + <kbd>c</kbd>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
action: 'Send post',
|
||||
keys: (
|
||||
|
@ -135,8 +140,21 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
keys: <kbd>r</kbd>,
|
||||
},
|
||||
{
|
||||
action: 'Favourite',
|
||||
keys: <kbd>f</kbd>,
|
||||
action: 'Reply (new window)',
|
||||
className: 'insignificant',
|
||||
keys: (
|
||||
<>
|
||||
<kbd>Shift</kbd> + <kbd>r</kbd>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
action: 'Like (favourite)',
|
||||
keys: (
|
||||
<>
|
||||
<kbd>l</kbd> or <kbd>f</kbd>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
action: 'Boost',
|
||||
|
@ -150,9 +168,17 @@ export default memo(function KeyboardShortcutsHelp() {
|
|||
action: 'Bookmark',
|
||||
keys: <kbd>d</kbd>,
|
||||
},
|
||||
].map(({ action, keys }) => (
|
||||
{
|
||||
action: 'Toggle Cloak mode',
|
||||
keys: (
|
||||
<>
|
||||
<kbd>Shift</kbd> + <kbd>Alt</kbd> + <kbd>k</kbd>
|
||||
</>
|
||||
),
|
||||
},
|
||||
].map(({ action, className, keys }) => (
|
||||
<tr key={action}>
|
||||
<th>{action}</th>
|
||||
<th class={className}>{action}</th>
|
||||
<td>{keys}</td>
|
||||
</tr>
|
||||
))}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Rendered but hidden. Only show when visible
|
||||
*/
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useInView } from 'react-intersection-observer';
|
||||
|
||||
// The sticky header, usually at the top
|
||||
const TOP = 48;
|
||||
|
||||
const shazamIDs = {};
|
||||
|
||||
export default function LazyShazam({ id, children }) {
|
||||
const containerRef = useRef();
|
||||
const hasID = !!shazamIDs[id];
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [visibleStart, setVisibleStart] = useState(hasID || false);
|
||||
|
||||
const { ref } = useInView({
|
||||
root: null,
|
||||
rootMargin: `-${TOP}px 0px 0px 0px`,
|
||||
trackVisibility: true,
|
||||
delay: 1000,
|
||||
onChange: (inView) => {
|
||||
if (inView) {
|
||||
setVisible(true);
|
||||
if (id) shazamIDs[id] = true;
|
||||
}
|
||||
},
|
||||
triggerOnce: true,
|
||||
skip: visibleStart || visible,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) return;
|
||||
const rect = containerRef.current.getBoundingClientRect();
|
||||
if (rect.bottom > TOP) {
|
||||
if (rect.top < window.innerHeight) {
|
||||
setVisible(true);
|
||||
} else {
|
||||
setVisibleStart(true);
|
||||
}
|
||||
if (id) shazamIDs[id] = true;
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (visibleStart) return children;
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
class="shazam-container no-animation"
|
||||
hidden={!visible}
|
||||
>
|
||||
<div ref={ref} class="shazam-container-inner">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -22,13 +22,15 @@ const Link = forwardRef((props, ref) => {
|
|||
|
||||
// Handle encodeURIComponent of searchParams values
|
||||
if (!!hash && hash !== '/' && hash.includes('?')) {
|
||||
const parsedHash = new URL(hash, location.origin); // Fake base URL
|
||||
if (parsedHash.searchParams.size) {
|
||||
const searchParamsStr = Array.from(parsedHash.searchParams.entries())
|
||||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
||||
.join('&');
|
||||
hash = parsedHash.pathname + '?' + searchParamsStr;
|
||||
}
|
||||
try {
|
||||
const parsedHash = new URL(hash, location.origin); // Fake base URL
|
||||
if (parsedHash.searchParams.size) {
|
||||
const searchParamsStr = Array.from(parsedHash.searchParams.entries())
|
||||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
||||
.join('&');
|
||||
hash = parsedHash.pathname + '?' + searchParamsStr;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
const isActive = hash === to || decodeURIComponent(hash) === to;
|
||||
|
|
|
@ -0,0 +1,196 @@
|
|||
.links-bar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
padding: 16px 16px 20px 16px;
|
||||
gap: 16px;
|
||||
overflow-x: auto;
|
||||
background-color: var(--bg-faded-color);
|
||||
mask-image: linear-gradient(
|
||||
to right,
|
||||
transparent,
|
||||
black 16px,
|
||||
black calc(100% - 16px),
|
||||
transparent
|
||||
);
|
||||
text-shadow: 0 1px var(--bg-blur-color);
|
||||
transition: opacity 0.3s ease-out;
|
||||
|
||||
#trending-page &:not(#columns &) {
|
||||
@media (min-width: 40em) {
|
||||
width: 95vw;
|
||||
max-width: calc(320px * 3.3);
|
||||
transform: translateX(calc(-50% + var(--main-width) / 2));
|
||||
}
|
||||
}
|
||||
|
||||
& > header {
|
||||
width: 1.2em;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
|
||||
h3 {
|
||||
font-size: 90%;
|
||||
font-style: italic;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-insignificant-color);
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 0;
|
||||
transform-origin: top left;
|
||||
transform: rotate(-90deg) translateX(-100%);
|
||||
user-select: none;
|
||||
background-image: linear-gradient(
|
||||
to left,
|
||||
var(--text-color),
|
||||
var(--link-color)
|
||||
);
|
||||
background-clip: text;
|
||||
text-fill-color: transparent;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
min-width: 240px;
|
||||
flex-grow: 1;
|
||||
max-width: 320px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
background-color: var(--accent-alpha-color);
|
||||
border: 4px solid transparent;
|
||||
box-shadow: 0 4px 8px -2px var(--drop-shadow-color);
|
||||
transition: all 0.15s ease-out;
|
||||
display: flex;
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--accent-color, var(--link-text-color)) -50%,
|
||||
transparent
|
||||
);
|
||||
background-clip: border-box;
|
||||
background-origin: border-box;
|
||||
min-height: 160px;
|
||||
height: 320px;
|
||||
max-height: 50vh;
|
||||
|
||||
&:not(:active):is(:hover, :focus-visible) {
|
||||
border-color: var(--accent-color, var(--link-light-color));
|
||||
box-shadow: 0 4px 8px var(--drop-shadow-color),
|
||||
0 8px 16px var(--drop-shadow-color);
|
||||
transform-origin: center bottom;
|
||||
transform: scale(1.02);
|
||||
|
||||
img {
|
||||
animation: position-object 5s ease-in-out 1s 5;
|
||||
}
|
||||
}
|
||||
|
||||
&:active {
|
||||
transition: none;
|
||||
transform: scale(1.015);
|
||||
filter: brightness(0.8);
|
||||
}
|
||||
|
||||
article {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
background-color: var(--bg-color);
|
||||
background-repeat: no-repeat;
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--accent-alpha-color) 70%,
|
||||
var(--bg-color) 100%
|
||||
);
|
||||
transition: background-position-y 0.15s ease-out;
|
||||
|
||||
figure {
|
||||
flex-grow: 1;
|
||||
margin: 0 0 -16px;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
|
||||
img {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
vertical-align: top;
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
hsl(0, 0%, 0%) 0%,
|
||||
hsla(0, 0%, 0%, 0.987) 14%,
|
||||
hsla(0, 0%, 0%, 0.951) 26.2%,
|
||||
hsla(0, 0%, 0%, 0.896) 36.8%,
|
||||
hsla(0, 0%, 0%, 0.825) 45.9%,
|
||||
hsla(0, 0%, 0%, 0.741) 53.7%,
|
||||
hsla(0, 0%, 0%, 0.648) 60.4%,
|
||||
hsla(0, 0%, 0%, 0.55) 66.2%,
|
||||
hsla(0, 0%, 0%, 0.45) 71.2%,
|
||||
hsla(0, 0%, 0%, 0.352) 75.6%,
|
||||
hsla(0, 0%, 0%, 0.259) 79.6%,
|
||||
hsla(0, 0%, 0%, 0.175) 83.4%,
|
||||
hsla(0, 0%, 0%, 0.104) 87.2%,
|
||||
hsla(0, 0%, 0%, 0.049) 91.1%,
|
||||
hsla(0, 0%, 0%, 0.013) 95.3%,
|
||||
hsla(0, 0%, 0%, 0) 100%
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:is(:hover, :focus-visible) article {
|
||||
background-position-y: -40px;
|
||||
}
|
||||
|
||||
.article-body {
|
||||
padding: 0 8px 8px;
|
||||
line-height: 1.3;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
color: var(--text-insignificant-color);
|
||||
font-size: 90%;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
&:hover .domain {
|
||||
color: var(--link-text-color);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: inherit;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-wrap: balance;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
p {
|
||||
color: var(--text-insignificant-color);
|
||||
margin: 0;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 4px 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
import { addListStore, deleteListStore, updateListStore } from '../utils/lists';
|
||||
import supports from '../utils/supports';
|
||||
|
||||
import Icon from './icon';
|
||||
|
@ -56,7 +57,7 @@ function ListAddEdit({ list, onClose }) {
|
|||
let listResult;
|
||||
|
||||
if (editMode) {
|
||||
listResult = await masto.v1.lists.update(list.id, {
|
||||
listResult = await masto.v1.lists.$select(list.id).update({
|
||||
title,
|
||||
replies_policy: repliesPolicy,
|
||||
exclusive,
|
||||
|
@ -75,6 +76,14 @@ function ListAddEdit({ list, onClose }) {
|
|||
state: 'success',
|
||||
list: listResult,
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
if (editMode) {
|
||||
updateListStore(listResult);
|
||||
} else {
|
||||
addListStore(listResult);
|
||||
}
|
||||
}, 1);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setUIState('error');
|
||||
|
@ -141,11 +150,14 @@ function ListAddEdit({ list, onClose }) {
|
|||
|
||||
(async () => {
|
||||
try {
|
||||
await masto.v1.lists.remove(list.id);
|
||||
await masto.v1.lists.$select(list.id).remove();
|
||||
setUIState('default');
|
||||
onClose?.({
|
||||
state: 'deleted',
|
||||
});
|
||||
setTimeout(() => {
|
||||
deleteListStore(list.id);
|
||||
}, 1);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setUIState('error');
|
||||
|
|
|
@ -2,14 +2,14 @@ import './loader.css';
|
|||
|
||||
function Loader({ abrupt, hidden, ...props }) {
|
||||
return (
|
||||
<div
|
||||
<span
|
||||
{...props}
|
||||
class={`loader-container ${abrupt ? 'abrupt' : ''} ${
|
||||
hidden ? 'hidden' : ''
|
||||
}`}
|
||||
>
|
||||
<div class="loader" />
|
||||
</div>
|
||||
<span class="loader" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,11 @@ import { useSnapshot } from 'valtio';
|
|||
|
||||
import getTranslateTargetLanguage from '../utils/get-translate-target-language';
|
||||
import localeMatch from '../utils/locale-match';
|
||||
import { speak, supportsTTS } from '../utils/speech';
|
||||
import states from '../utils/states';
|
||||
|
||||
import Icon from './icon';
|
||||
import Menu2 from './menu2';
|
||||
import TranslationBlock from './translation-block';
|
||||
|
||||
export default function MediaAltModal({ alt, lang, onClose }) {
|
||||
|
@ -24,7 +26,7 @@ export default function MediaAltModal({ alt, lang, onClose }) {
|
|||
);
|
||||
|
||||
return (
|
||||
<div class="sheet">
|
||||
<div class="sheet" tabindex="-1">
|
||||
{!!onClose && (
|
||||
<button type="button" class="sheet-close outer" onClick={onClose}>
|
||||
<Icon icon="x" />
|
||||
|
@ -33,7 +35,7 @@ export default function MediaAltModal({ alt, lang, onClose }) {
|
|||
<header class="header-grid">
|
||||
<h2>Media description</h2>
|
||||
<div class="header-side">
|
||||
<Menu
|
||||
<Menu2
|
||||
align="end"
|
||||
menuButton={
|
||||
<button type="button" class="plain4">
|
||||
|
@ -50,13 +52,24 @@ export default function MediaAltModal({ alt, lang, onClose }) {
|
|||
<Icon icon="translate" />
|
||||
<span>Translate</span>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
{supportsTTS && (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
speak(alt, lang);
|
||||
}}
|
||||
>
|
||||
<Icon icon="speak" />
|
||||
<span>Speak</span>
|
||||
</MenuItem>
|
||||
)}
|
||||
</Menu2>
|
||||
</div>
|
||||
</header>
|
||||
<main lang={lang} dir="auto">
|
||||
<p
|
||||
style={{
|
||||
whiteSpace: 'pre-wrap',
|
||||
textWrap: 'pretty',
|
||||
}}
|
||||
>
|
||||
{alt}
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
import { Menu } from '@szhsin/react-menu';
|
||||
import { MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
|
||||
import {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'preact/hooks';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
import { oklab2rgb, rgb2oklab } from '../utils/color-utils';
|
||||
import showToast from '../utils/show-toast';
|
||||
import states from '../utils/states';
|
||||
|
||||
import Icon from './icon';
|
||||
import Link from './link';
|
||||
import Media from './media';
|
||||
import MediaAltModal from './media-alt-modal';
|
||||
import Menu2 from './menu2';
|
||||
import MenuLink from './menu-link';
|
||||
import Modal from './modal';
|
||||
|
||||
const { PHANPY_IMG_ALT_API_URL: IMG_ALT_API_URL } = import.meta.env;
|
||||
|
||||
function MediaModal({
|
||||
mediaAttachments,
|
||||
|
@ -18,6 +29,7 @@ function MediaModal({
|
|||
index = 0,
|
||||
onClose = () => {},
|
||||
}) {
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const carouselRef = useRef(null);
|
||||
|
||||
const [currentIndex, setCurrentIndex] = useState(index);
|
||||
|
@ -64,9 +76,17 @@ function MediaModal({
|
|||
};
|
||||
}, []);
|
||||
|
||||
useHotkeys('esc', onClose, [onClose]);
|
||||
|
||||
const [showMediaAlt, setShowMediaAlt] = useState(false);
|
||||
useHotkeys(
|
||||
'esc',
|
||||
onClose,
|
||||
{
|
||||
ignoreEventWhen: (e) => {
|
||||
const hasModal = !!document.querySelector('#modal-container > *');
|
||||
return hasModal;
|
||||
},
|
||||
},
|
||||
[onClose],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
let handleScroll = () => {
|
||||
|
@ -93,8 +113,52 @@ function MediaModal({
|
|||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const mediaAccentColors = useMemo(() => {
|
||||
return mediaAttachments?.map((media) => {
|
||||
const { blurhash } = media;
|
||||
if (blurhash) {
|
||||
const averageColor = getBlurHashAverageColor(blurhash);
|
||||
const labAverageColor = rgb2oklab(averageColor);
|
||||
return oklab2rgb([0.6, labAverageColor[1], labAverageColor[2]]);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}, [mediaAttachments]);
|
||||
const mediaAccentGradient = useMemo(() => {
|
||||
const gap = 5;
|
||||
const range = 100 / mediaAccentColors.length;
|
||||
return (
|
||||
mediaAccentColors
|
||||
?.map((color, i) => {
|
||||
const start = i * range + gap;
|
||||
const end = (i + 1) * range - gap;
|
||||
if (color) {
|
||||
return `
|
||||
rgba(${color?.join(',')}, 0.4) ${start}%,
|
||||
rgba(${color?.join(',')}, 0.4) ${end}%
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
transparent ${start}%,
|
||||
transparent ${end}%
|
||||
`;
|
||||
})
|
||||
?.join(', ') || 'transparent'
|
||||
);
|
||||
}, [mediaAccentColors]);
|
||||
|
||||
let toastRef = useRef(null);
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
toastRef.current?.hideToast?.();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div class="media-modal-container">
|
||||
<div
|
||||
class={`media-modal-container media-modal-count-${mediaAttachments?.length}`}
|
||||
>
|
||||
<div
|
||||
ref={carouselRef}
|
||||
tabIndex="0"
|
||||
|
@ -109,26 +173,41 @@ function MediaModal({
|
|||
onClose();
|
||||
}
|
||||
}}
|
||||
style={
|
||||
mediaAttachments.length > 1
|
||||
? {
|
||||
backgroundAttachment: 'local',
|
||||
backgroundImage: `linear-gradient(
|
||||
to right, ${mediaAccentGradient})`,
|
||||
}
|
||||
: {}
|
||||
}
|
||||
>
|
||||
{mediaAttachments?.map((media, i) => {
|
||||
const { blurhash } = media;
|
||||
const rgbAverageColor = blurhash
|
||||
? getBlurHashAverageColor(blurhash)
|
||||
: null;
|
||||
const accentColor =
|
||||
mediaAttachments.length === 1 ? mediaAccentColors[i] : null;
|
||||
return (
|
||||
<div
|
||||
class="carousel-item"
|
||||
style={{
|
||||
'--average-color': `rgb(${rgbAverageColor?.join(',')})`,
|
||||
'--average-color-alpha': `rgba(${rgbAverageColor?.join(
|
||||
',',
|
||||
)}, .5)`,
|
||||
}}
|
||||
style={
|
||||
accentColor
|
||||
? {
|
||||
'--accent-color': `rgb(${accentColor?.join(',')})`,
|
||||
'--accent-alpha-color': `rgba(${accentColor?.join(
|
||||
',',
|
||||
)}, 0.4)`,
|
||||
}
|
||||
: {}
|
||||
}
|
||||
tabindex="0"
|
||||
key={media.id}
|
||||
ref={i === currentIndex ? carouselFocusItem : null}
|
||||
onClick={(e) => {
|
||||
if (e.target !== e.currentTarget) {
|
||||
// console.log(e);
|
||||
// if (e.target !== e.currentTarget) {
|
||||
// setShowControls(!showControls);
|
||||
// }
|
||||
if (!e.target.classList.contains('media')) {
|
||||
setShowControls(!showControls);
|
||||
}
|
||||
}}
|
||||
|
@ -139,10 +218,10 @@ function MediaModal({
|
|||
class="media-alt"
|
||||
hidden={!showControls}
|
||||
onClick={() => {
|
||||
setShowMediaAlt({
|
||||
states.showMediaAlt = {
|
||||
alt: media.description,
|
||||
lang,
|
||||
});
|
||||
};
|
||||
}}
|
||||
>
|
||||
<span class="alt-badge">ALT</span>
|
||||
|
@ -192,11 +271,10 @@ function MediaModal({
|
|||
<span />
|
||||
)}
|
||||
<span>
|
||||
<Menu
|
||||
<Menu2
|
||||
overflow="auto"
|
||||
align="end"
|
||||
position="anchor"
|
||||
boundingBoxPadding="8 8 8 8"
|
||||
gap={4}
|
||||
menuClassName="glass-menu"
|
||||
menuButton={
|
||||
|
@ -217,7 +295,48 @@ function MediaModal({
|
|||
<Icon icon="popout" />
|
||||
<span>Open original media</span>
|
||||
</MenuLink>
|
||||
</Menu>{' '}
|
||||
{import.meta.env.DEV && // Only dev for now
|
||||
!!states.settings.mediaAltGenerator &&
|
||||
!!IMG_ALT_API_URL &&
|
||||
!!mediaAttachments[currentIndex]?.url &&
|
||||
!mediaAttachments[currentIndex]?.description &&
|
||||
mediaAttachments[currentIndex]?.type === 'image' && (
|
||||
<>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
disabled={uiState === 'loading'}
|
||||
onClick={() => {
|
||||
setUIState('loading');
|
||||
toastRef.current = showToast({
|
||||
text: 'Attempting to describe image. Please wait...',
|
||||
duration: -1,
|
||||
});
|
||||
(async function () {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${IMG_ALT_API_URL}?image=${encodeURIComponent(
|
||||
mediaAttachments[currentIndex]?.url,
|
||||
)}`,
|
||||
).then((r) => r.json());
|
||||
states.showMediaAlt = {
|
||||
alt: response.description,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showToast('Failed to describe image');
|
||||
} finally {
|
||||
setUIState('default');
|
||||
toastRef.current?.hideToast?.();
|
||||
}
|
||||
})();
|
||||
}}
|
||||
>
|
||||
<Icon icon="sparkles2" />
|
||||
<span>Describe image…</span>
|
||||
</MenuItem>
|
||||
</>
|
||||
)}
|
||||
</Menu2>{' '}
|
||||
<Link
|
||||
to={`${instance ? `/${instance}` : ''}/s/${statusID}${
|
||||
window.matchMedia('(min-width: calc(40em + 350px))').matches
|
||||
|
@ -234,7 +353,7 @@ function MediaModal({
|
|||
// }
|
||||
// }}
|
||||
>
|
||||
<span class="button-label">See post </span>»
|
||||
<span class="button-label">View post </span>»
|
||||
</Link>
|
||||
</span>
|
||||
</div>
|
||||
|
@ -274,23 +393,6 @@ function MediaModal({
|
|||
</button>
|
||||
</div>
|
||||
)}
|
||||
{!!showMediaAlt && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
setShowMediaAlt(false);
|
||||
carouselRef.current.focus();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<MediaAltModal
|
||||
alt={showMediaAlt.alt || showMediaAlt}
|
||||
lang={showMediaAlt?.lang}
|
||||
onClose={() => setShowMediaAlt(false)}
|
||||
/>
|
||||
</Modal>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
.media-post {
|
||||
--item-radius: 16px;
|
||||
position: relative;
|
||||
animation: appear-smooth 1s ease-out;
|
||||
|
||||
&:is(.filtered, .has-spoiler:not(.show-media)) :is(img, video) {
|
||||
/* filter: blur(32px);
|
||||
image-rendering: crisp-edges;
|
||||
image-rendering: pixelated; */
|
||||
opacity: 0;
|
||||
animation: none !important;
|
||||
}
|
||||
|
||||
&.filtered[data-filtered-text]:before {
|
||||
content: attr(data-filtered-text);
|
||||
}
|
||||
&.has-spoiler[data-spoiler-text]:before {
|
||||
content: attr(data-spoiler-text);
|
||||
}
|
||||
|
||||
&.filtered[data-filtered-text]:before,
|
||||
&.has-spoiler[data-spoiler-text]:before {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
background-color: var(--bg-blur-color);
|
||||
margin: 8px;
|
||||
padding: 4px 6px;
|
||||
border-radius: calc(var(--item-radius) / 2);
|
||||
font-size: 90%;
|
||||
border: var(--hairline-width) dashed var(--bg-color);
|
||||
word-break: break-word;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
/* mix-blend-mode: luminosity; */
|
||||
-webkit-line-clamp: 3;
|
||||
line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
box-orient: vertical;
|
||||
display: -webkit-box;
|
||||
display: box;
|
||||
overflow: hidden;
|
||||
z-index: 2;
|
||||
|
||||
> * {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.has-spoiler.show-media[data-spoiler-text]:before {
|
||||
mix-blend-mode: normal;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.media {
|
||||
border-radius: var(--item-radius);
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
display: block;
|
||||
aspect-ratio: 1 !important;
|
||||
|
||||
&:before {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
content: '';
|
||||
border: 1px solid var(--outline-color);
|
||||
border-radius: inherit;
|
||||
}
|
||||
|
||||
&:not(.media-audio) {
|
||||
background-color: var(--average-color, var(--media-bg-color));
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
&:hover {
|
||||
--drop-shadow: var(--drop-shadow-color);
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
box-shadow: 0 8px 16px -4px var(--drop-shadow),
|
||||
0 4px 8px var(--drop-shadow);
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
--drop-shadow: var(--link-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:active:not(:has(button:active)) {
|
||||
box-shadow: none;
|
||||
filter: brightness(0.8);
|
||||
transform: scale(0.99);
|
||||
}
|
||||
|
||||
video,
|
||||
img,
|
||||
audio {
|
||||
border-radius: 16px;
|
||||
/* object-fit: scale-down; */
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
:not(.filtered, .has-spoiler) &:is(:hover, :focus) img {
|
||||
/* Less delay here to make it feel more responsive */
|
||||
animation: position-object 5s ease-in-out 0.1s 5;
|
||||
animation-duration: var(--anim-duration, 5s);
|
||||
}
|
||||
}
|
||||
|
||||
&.has-spoiler .media:not(.media-audio) {
|
||||
background-image: radial-gradient(
|
||||
circle at 50% 50%,
|
||||
var(--average-color, var(--bg-faded-color)),
|
||||
var(--bg-color) 20em
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
import './media-post.css';
|
||||
|
||||
import { memo } from 'preact/compat';
|
||||
import { useContext, useMemo } from 'preact/hooks';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
import FilterContext from '../utils/filter-context';
|
||||
import { isFiltered } from '../utils/filters';
|
||||
import states, { statusKey } from '../utils/states';
|
||||
import store from '../utils/store';
|
||||
import { getCurrentAccountID } from '../utils/store-utils';
|
||||
|
||||
import Media from './media';
|
||||
|
||||
function MediaPost({
|
||||
class: className,
|
||||
statusID,
|
||||
status,
|
||||
instance,
|
||||
parent,
|
||||
// allowFilters,
|
||||
onMediaClick,
|
||||
}) {
|
||||
let sKey = statusKey(statusID, instance);
|
||||
const snapStates = useSnapshot(states);
|
||||
if (!status) {
|
||||
status = snapStates.statuses[sKey] || snapStates.statuses[statusID];
|
||||
sKey = statusKey(status?.id, instance);
|
||||
}
|
||||
if (!status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
account: {
|
||||
acct,
|
||||
avatar,
|
||||
avatarStatic,
|
||||
id: accountId,
|
||||
url: accountURL,
|
||||
displayName,
|
||||
username,
|
||||
emojis: accountEmojis,
|
||||
bot,
|
||||
group,
|
||||
},
|
||||
id,
|
||||
repliesCount,
|
||||
reblogged,
|
||||
reblogsCount,
|
||||
favourited,
|
||||
favouritesCount,
|
||||
bookmarked,
|
||||
poll,
|
||||
muted,
|
||||
sensitive,
|
||||
spoilerText,
|
||||
visibility, // public, unlisted, private, direct
|
||||
language,
|
||||
editedAt,
|
||||
filtered,
|
||||
card,
|
||||
createdAt,
|
||||
inReplyToId,
|
||||
inReplyToAccountId,
|
||||
content,
|
||||
mentions,
|
||||
mediaAttachments,
|
||||
reblog,
|
||||
uri,
|
||||
url,
|
||||
emojis,
|
||||
// Non-API props
|
||||
_deleted,
|
||||
_pinned,
|
||||
// _filtered,
|
||||
} = status;
|
||||
|
||||
if (!mediaAttachments?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const debugHover = (e) => {
|
||||
if (e.shiftKey) {
|
||||
console.log({
|
||||
...status,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const currentAccount = useMemo(() => {
|
||||
return getCurrentAccountID();
|
||||
}, []);
|
||||
const isSelf = useMemo(() => {
|
||||
return currentAccount && currentAccount === accountId;
|
||||
}, [accountId, currentAccount]);
|
||||
|
||||
const filterContext = useContext(FilterContext);
|
||||
const filterInfo = !isSelf && isFiltered(filtered, filterContext);
|
||||
|
||||
if (filterInfo?.action === 'hide') {
|
||||
return null;
|
||||
}
|
||||
|
||||
console.debug('RENDER Media post', id, status?.account.displayName);
|
||||
|
||||
const hasSpoiler = sensitive;
|
||||
const readingExpandMedia = useMemo(() => {
|
||||
// default | show_all | hide_all
|
||||
const prefs = store.account.get('preferences') || {};
|
||||
return prefs['reading:expand:media'] || 'default';
|
||||
}, []);
|
||||
const showSpoilerMedia = readingExpandMedia === 'show_all';
|
||||
|
||||
const Parent = parent || 'div';
|
||||
|
||||
return mediaAttachments.map((media, i) => {
|
||||
const mediaKey = `${sKey}-${media.id}`;
|
||||
const filterTitleStr = filterInfo?.titlesStr;
|
||||
return (
|
||||
<Parent
|
||||
data-state-post-id={sKey}
|
||||
onMouseEnter={debugHover}
|
||||
key={mediaKey}
|
||||
data-spoiler-text={
|
||||
spoilerText || (sensitive ? 'Sensitive media' : undefined)
|
||||
}
|
||||
data-filtered-text={
|
||||
filterInfo
|
||||
? `Filtered${filterTitleStr ? `: ${filterTitleStr}` : ''}`
|
||||
: undefined
|
||||
}
|
||||
class={`
|
||||
media-post
|
||||
${filterInfo ? 'filtered' : ''}
|
||||
${hasSpoiler ? 'has-spoiler' : ''}
|
||||
${showSpoilerMedia ? 'show-media' : ''}
|
||||
`}
|
||||
>
|
||||
<Media
|
||||
class={className}
|
||||
media={media}
|
||||
lang={language}
|
||||
to={`/${instance}/s/${id}?media-only=${i + 1}`}
|
||||
onClick={
|
||||
onMediaClick ? (e) => onMediaClick(e, i, media, status) : undefined
|
||||
}
|
||||
/>
|
||||
</Parent>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export default memo(MediaPost);
|
|
@ -1,5 +1,4 @@
|
|||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
||||
import mem from 'mem';
|
||||
import { Fragment } from 'preact';
|
||||
import {
|
||||
useCallback,
|
||||
|
@ -10,11 +9,12 @@ import {
|
|||
} from 'preact/hooks';
|
||||
import QuickPinchZoom, { make3dTransformValue } from 'react-quick-pinch-zoom';
|
||||
|
||||
import formatDuration from '../utils/format-duration';
|
||||
import mem from '../utils/mem';
|
||||
import states from '../utils/states';
|
||||
|
||||
import Icon from './icon';
|
||||
import Link from './link';
|
||||
import { formatDuration } from './status';
|
||||
|
||||
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // https://stackoverflow.com/a/23522755
|
||||
|
||||
|
@ -54,6 +54,7 @@ const AltBadge = (props) => {
|
|||
};
|
||||
|
||||
const MEDIA_CAPTION_LIMIT = 140;
|
||||
const MEDIA_CAPTION_LIMIT_LONGER = 280;
|
||||
export const isMediaCaptionLong = mem((caption) =>
|
||||
caption?.length
|
||||
? caption.length > MEDIA_CAPTION_LIMIT ||
|
||||
|
@ -62,16 +63,18 @@ export const isMediaCaptionLong = mem((caption) =>
|
|||
);
|
||||
|
||||
function Media({
|
||||
class: className = '',
|
||||
media,
|
||||
to,
|
||||
lang,
|
||||
showOriginal,
|
||||
autoAnimate,
|
||||
showCaption,
|
||||
allowLongerCaption,
|
||||
altIndex,
|
||||
onClick = () => {},
|
||||
}) {
|
||||
const {
|
||||
let {
|
||||
blurhash,
|
||||
description,
|
||||
meta,
|
||||
|
@ -81,21 +84,33 @@ function Media({
|
|||
url,
|
||||
type,
|
||||
} = media;
|
||||
if (/no\-preview\./i.test(previewUrl)) {
|
||||
previewUrl = null;
|
||||
}
|
||||
const { original = {}, small, focus } = meta || {};
|
||||
|
||||
const width = showOriginal ? original?.width : small?.width;
|
||||
const height = showOriginal ? original?.height : small?.height;
|
||||
const width = showOriginal
|
||||
? original?.width
|
||||
: small?.width || original?.width;
|
||||
const height = showOriginal
|
||||
? original?.height
|
||||
: small?.height || original?.height;
|
||||
const mediaURL = showOriginal ? url : previewUrl || url;
|
||||
const remoteMediaURL = showOriginal
|
||||
? remoteUrl
|
||||
: previewRemoteUrl || remoteUrl;
|
||||
const orientation = width >= height ? 'landscape' : 'portrait';
|
||||
const hasDimensions = width && height;
|
||||
const orientation = hasDimensions
|
||||
? width > height
|
||||
? 'landscape'
|
||||
: 'portrait'
|
||||
: null;
|
||||
|
||||
const rgbAverageColor = blurhash ? getBlurHashAverageColor(blurhash) : null;
|
||||
|
||||
const videoRef = useRef();
|
||||
|
||||
let focalBackgroundPosition;
|
||||
let focalPosition;
|
||||
if (focus) {
|
||||
// Convert focal point to CSS background position
|
||||
// Formula from jquery-focuspoint
|
||||
|
@ -104,7 +119,7 @@ function Media({
|
|||
// x = 1, y = -1 => 100% 100%
|
||||
const x = ((focus.x + 1) / 2) * 100;
|
||||
const y = ((1 - focus.y) / 2) * 100;
|
||||
focalBackgroundPosition = `${x.toFixed(0)}% ${y.toFixed(0)}%`;
|
||||
focalPosition = `${x.toFixed(0)}% ${y.toFixed(0)}%`;
|
||||
}
|
||||
|
||||
const mediaRef = useRef();
|
||||
|
@ -130,6 +145,8 @@ function Media({
|
|||
enabled: pinchZoomEnabled,
|
||||
draggableUnZoomed: false,
|
||||
inertiaFriction: 0.9,
|
||||
tapZoomFactor: 2,
|
||||
doubleTapToggleZoom: true,
|
||||
containerProps: {
|
||||
className: 'media-zoom',
|
||||
style: {
|
||||
|
@ -149,11 +166,18 @@ function Media({
|
|||
[to],
|
||||
);
|
||||
|
||||
const remoteMediaURLObj = remoteMediaURL ? getURLObj(remoteMediaURL) : null;
|
||||
const isVideoMaybe =
|
||||
type === 'unknown' &&
|
||||
/\.(mp4|m4a|m4p|m4b|m4r|m4v|mov|webm)$/i.test(remoteMediaURL);
|
||||
remoteMediaURLObj &&
|
||||
/\.(mp4|m4r|m4v|mov|webm)$/i.test(remoteMediaURLObj.pathname);
|
||||
const isAudioMaybe =
|
||||
type === 'unknown' &&
|
||||
remoteMediaURLObj &&
|
||||
/\.(mp3|ogg|wav|m4a|m4p|m4b)$/i.test(remoteMediaURLObj.pathname);
|
||||
const isImage =
|
||||
type === 'image' || (type === 'unknown' && previewUrl && !isVideoMaybe);
|
||||
type === 'image' ||
|
||||
(type === 'unknown' && previewUrl && !isVideoMaybe && !isAudioMaybe);
|
||||
|
||||
const parentRef = useRef();
|
||||
const [imageSmallerThanParent, setImageSmallerThanParent] = useState(false);
|
||||
|
@ -169,19 +193,35 @@ function Media({
|
|||
const maxAspectHeight =
|
||||
window.innerHeight * (orientation === 'portrait' ? 0.45 : 0.33);
|
||||
const maxHeight = orientation === 'portrait' ? 0 : 160;
|
||||
const mediaStyles = {
|
||||
'--width': `${width}px`,
|
||||
'--height': `${height}px`,
|
||||
// Calculate '--aspectWidth' based on aspect ratio calculated from '--width' and '--height', max height has to be 160px
|
||||
'--aspectWidth': `${
|
||||
(width / height) * Math.max(maxHeight, maxAspectHeight)
|
||||
}px`,
|
||||
aspectRatio: `${width} / ${height}`,
|
||||
const averageColorStyle = {
|
||||
'--average-color': rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
||||
};
|
||||
const mediaStyles =
|
||||
width && height
|
||||
? {
|
||||
'--width': `${width}px`,
|
||||
'--height': `${height}px`,
|
||||
// Calculate '--aspectWidth' based on aspect ratio calculated from '--width' and '--height', max height has to be 160px
|
||||
'--aspectWidth': `${
|
||||
(width / height) * Math.max(maxHeight, maxAspectHeight)
|
||||
}px`,
|
||||
aspectRatio: `${width} / ${height}`,
|
||||
...averageColorStyle,
|
||||
}
|
||||
: {
|
||||
...averageColorStyle,
|
||||
};
|
||||
|
||||
const longDesc = isMediaCaptionLong(description);
|
||||
const showInlineDesc =
|
||||
let showInlineDesc =
|
||||
!!showCaption && !showOriginal && !!description && !longDesc;
|
||||
if (
|
||||
allowLongerCaption &&
|
||||
!showInlineDesc &&
|
||||
description?.length <= MEDIA_CAPTION_LIMIT_LONGER
|
||||
) {
|
||||
showInlineDesc = true;
|
||||
}
|
||||
const Figure = !showInlineDesc
|
||||
? Fragment
|
||||
: (props) => {
|
||||
|
@ -229,7 +269,7 @@ function Media({
|
|||
<Figure>
|
||||
<Parent
|
||||
ref={parentRef}
|
||||
class={`media media-image`}
|
||||
class={`media media-image ${className}`}
|
||||
onClick={onClick}
|
||||
data-orientation={orientation}
|
||||
data-has-alt={!showInlineDesc}
|
||||
|
@ -240,6 +280,7 @@ function Media({
|
|||
backgroundSize: imageSmallerThanParent
|
||||
? `${width}px ${height}px`
|
||||
: undefined,
|
||||
...averageColorStyle,
|
||||
}
|
||||
: mediaStyles
|
||||
}
|
||||
|
@ -262,7 +303,11 @@ function Media({
|
|||
}}
|
||||
onError={(e) => {
|
||||
const { src } = e.target;
|
||||
if (src === mediaURL) {
|
||||
if (
|
||||
src === mediaURL &&
|
||||
remoteMediaURL &&
|
||||
mediaURL !== remoteMediaURL
|
||||
) {
|
||||
e.target.src = remoteMediaURL;
|
||||
}
|
||||
}}
|
||||
|
@ -278,10 +323,11 @@ function Media({
|
|||
data-orientation={orientation}
|
||||
loading="lazy"
|
||||
style={{
|
||||
backgroundColor:
|
||||
rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
||||
backgroundPosition: focalBackgroundPosition || 'center',
|
||||
// backgroundColor:
|
||||
// rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
||||
// backgroundPosition: focalBackgroundPosition || 'center',
|
||||
// Duration based on width or height in pixels
|
||||
objectPosition: focalPosition || 'center',
|
||||
// 100px per second (rough estimate)
|
||||
// Clamp between 5s and 120s
|
||||
'--anim-duration': `${Math.min(
|
||||
|
@ -290,12 +336,61 @@ function Media({
|
|||
)}s`,
|
||||
}}
|
||||
onLoad={(e) => {
|
||||
e.target.closest('.media-image').style.backgroundImage = '';
|
||||
// e.target.closest('.media-image').style.backgroundImage = '';
|
||||
e.target.dataset.loaded = true;
|
||||
const $media = e.target.closest('.media');
|
||||
if (!hasDimensions && $media) {
|
||||
const { naturalWidth, naturalHeight } = e.target;
|
||||
$media.dataset.orientation =
|
||||
naturalWidth > naturalHeight ? 'landscape' : 'portrait';
|
||||
$media.style.setProperty('--width', `${naturalWidth}px`);
|
||||
$media.style.setProperty('--height', `${naturalHeight}px`);
|
||||
$media.style.aspectRatio = `${naturalWidth}/${naturalHeight}`;
|
||||
}
|
||||
|
||||
// Check natural aspect ratio vs display aspect ratio
|
||||
if ($media) {
|
||||
const {
|
||||
clientWidth,
|
||||
clientHeight,
|
||||
naturalWidth,
|
||||
naturalHeight,
|
||||
} = e.target;
|
||||
if (
|
||||
clientWidth &&
|
||||
clientHeight &&
|
||||
naturalWidth &&
|
||||
naturalHeight
|
||||
) {
|
||||
const minDimension = 88;
|
||||
if (
|
||||
naturalWidth < minDimension ||
|
||||
naturalHeight < minDimension
|
||||
) {
|
||||
$media.dataset.hasSmallDimension = true;
|
||||
} else {
|
||||
const naturalAspectRatio = (
|
||||
naturalWidth / naturalHeight
|
||||
).toFixed(2);
|
||||
const displayAspectRatio = (
|
||||
clientWidth / clientHeight
|
||||
).toFixed(2);
|
||||
const similarThreshold = 0.05;
|
||||
if (
|
||||
naturalAspectRatio === displayAspectRatio ||
|
||||
Math.abs(naturalAspectRatio - displayAspectRatio) <
|
||||
similarThreshold
|
||||
) {
|
||||
$media.dataset.hasNaturalAspectRatio = true;
|
||||
}
|
||||
// $media.dataset.aspectRatios = `${naturalAspectRatio} ${displayAspectRatio}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
onError={(e) => {
|
||||
const { src } = e.target;
|
||||
if (src === mediaURL) {
|
||||
if (src === mediaURL && mediaURL !== remoteMediaURL) {
|
||||
e.target.src = remoteMediaURL;
|
||||
}
|
||||
}}
|
||||
|
@ -309,6 +404,7 @@ function Media({
|
|||
</Figure>
|
||||
);
|
||||
} else if (type === 'gifv' || type === 'video' || isVideoMaybe) {
|
||||
const hasDuration = original.duration > 0;
|
||||
const shortDuration = original.duration < 31;
|
||||
const isGIF = type === 'gifv' && shortDuration;
|
||||
// If GIF is too long, treat it as a video
|
||||
|
@ -316,32 +412,55 @@ function Media({
|
|||
const formattedDuration = formatDuration(original.duration);
|
||||
const hoverAnimate = !showOriginal && !autoAnimate && isGIF;
|
||||
const autoGIFAnimate = !showOriginal && autoAnimate && isGIF;
|
||||
const showProgress = original.duration > 5;
|
||||
|
||||
// This string is only for autoplay + muted to work on Mobile Safari
|
||||
const gifHTML = `
|
||||
<video
|
||||
src="${url}"
|
||||
poster="${previewUrl}"
|
||||
width="${width}"
|
||||
height="${height}"
|
||||
data-orientation="${orientation}"
|
||||
preload="auto"
|
||||
autoplay
|
||||
muted
|
||||
playsinline
|
||||
${loopable ? 'loop' : ''}
|
||||
ondblclick="this.paused ? this.play() : this.pause()"
|
||||
${
|
||||
showProgress
|
||||
? "ontimeupdate=\"this.closest('.media-gif') && this.closest('.media-gif').style.setProperty('--progress', `${~~((this.currentTime / this.duration) * 100)}%`)\""
|
||||
: ''
|
||||
}
|
||||
></video>
|
||||
`;
|
||||
|
||||
const videoHTML = `
|
||||
<video
|
||||
src="${url}"
|
||||
poster="${previewUrl}"
|
||||
width="${width}"
|
||||
height="${height}"
|
||||
data-orientation="${orientation}"
|
||||
preload="auto"
|
||||
autoplay
|
||||
muted="${isGIF}"
|
||||
${isGIF ? '' : 'controls'}
|
||||
playsinline
|
||||
loop="${loopable}"
|
||||
${isGIF ? 'ondblclick="this.paused ? this.play() : this.pause()"' : ''}
|
||||
></video>
|
||||
`;
|
||||
<video
|
||||
src="${url}"
|
||||
poster="${previewUrl}"
|
||||
width="${width}"
|
||||
height="${height}"
|
||||
data-orientation="${orientation}"
|
||||
preload="auto"
|
||||
autoplay
|
||||
playsinline
|
||||
${loopable ? 'loop' : ''}
|
||||
controls
|
||||
></video>
|
||||
`;
|
||||
|
||||
return (
|
||||
<Figure>
|
||||
<Parent
|
||||
class={`media media-${isGIF ? 'gif' : 'video'} ${
|
||||
class={`media ${className} media-${isGIF ? 'gif' : 'video'} ${
|
||||
autoGIFAnimate ? 'media-contain' : ''
|
||||
}`}
|
||||
} ${hoverAnimate ? 'media-hover-animate' : ''}`}
|
||||
data-orientation={orientation}
|
||||
data-formatted-duration={formattedDuration}
|
||||
data-formatted-duration={
|
||||
!showOriginal ? formattedDuration : undefined
|
||||
}
|
||||
data-label={isGIF && !showOriginal && !autoGIFAnimate ? 'GIF' : ''}
|
||||
data-has-alt={!showInlineDesc}
|
||||
// style={{
|
||||
|
@ -392,17 +511,22 @@ function Media({
|
|||
<div
|
||||
ref={mediaRef}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: videoHTML,
|
||||
__html: gifHTML,
|
||||
}}
|
||||
/>
|
||||
</QuickPinchZoom>
|
||||
) : (
|
||||
) : isGIF ? (
|
||||
<div
|
||||
class="video-container"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: videoHTML,
|
||||
__html: gifHTML,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
class="video-container"
|
||||
dangerouslySetInnerHTML={{ __html: videoHTML }}
|
||||
/>
|
||||
)
|
||||
) : isGIF ? (
|
||||
<video
|
||||
|
@ -417,17 +541,80 @@ function Media({
|
|||
playsinline
|
||||
loop
|
||||
muted
|
||||
onTimeUpdate={
|
||||
showProgress
|
||||
? (e) => {
|
||||
const { target } = e;
|
||||
const container = target?.closest('.media-gif');
|
||||
if (container) {
|
||||
const percentage =
|
||||
(target.currentTime / target.duration) * 100;
|
||||
container.style.setProperty(
|
||||
'--progress',
|
||||
`${percentage}%`,
|
||||
);
|
||||
}
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<img
|
||||
src={previewUrl}
|
||||
alt={showInlineDesc ? '' : description}
|
||||
width={width}
|
||||
height={height}
|
||||
data-orientation={orientation}
|
||||
loading="lazy"
|
||||
/>
|
||||
{previewUrl ? (
|
||||
<img
|
||||
src={previewUrl}
|
||||
alt={showInlineDesc ? '' : description}
|
||||
width={width}
|
||||
height={height}
|
||||
data-orientation={orientation}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
onLoad={(e) => {
|
||||
if (!hasDimensions) {
|
||||
const $media = e.target.closest('.media');
|
||||
if ($media) {
|
||||
const { naturalHeight, naturalWidth } = e.target;
|
||||
$media.dataset.orientation =
|
||||
naturalWidth > naturalHeight
|
||||
? 'landscape'
|
||||
: 'portrait';
|
||||
$media.style.setProperty(
|
||||
'--width',
|
||||
`${naturalWidth}px`,
|
||||
);
|
||||
$media.style.setProperty(
|
||||
'--height',
|
||||
`${naturalHeight}px`,
|
||||
);
|
||||
$media.style.aspectRatio = `${naturalWidth}/${naturalHeight}`;
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<video
|
||||
src={url + '#t=0.1'} // Make Safari show 1st-frame preview
|
||||
width={width}
|
||||
height={height}
|
||||
data-orientation={orientation}
|
||||
preload="metadata"
|
||||
muted
|
||||
disablePictureInPicture
|
||||
onLoadedMetadata={(e) => {
|
||||
if (!hasDuration) {
|
||||
const { duration } = e.target;
|
||||
if (duration) {
|
||||
const formattedDuration = formatDuration(duration);
|
||||
const container = e.target.closest('.media-video');
|
||||
if (container) {
|
||||
container.dataset.formattedDuration =
|
||||
formattedDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<div class="media-play">
|
||||
<Icon icon="play" size="xl" />
|
||||
</div>
|
||||
|
@ -439,19 +626,21 @@ function Media({
|
|||
</Parent>
|
||||
</Figure>
|
||||
);
|
||||
} else if (type === 'audio') {
|
||||
} else if (type === 'audio' || isAudioMaybe) {
|
||||
const formattedDuration = formatDuration(original.duration);
|
||||
return (
|
||||
<Figure>
|
||||
<Parent
|
||||
class="media media-audio"
|
||||
data-formatted-duration={formattedDuration}
|
||||
class={`media media-audio ${className}`}
|
||||
data-formatted-duration={
|
||||
!showOriginal ? formattedDuration : undefined
|
||||
}
|
||||
data-has-alt={!showInlineDesc}
|
||||
onClick={onClick}
|
||||
style={!showOriginal && mediaStyles}
|
||||
>
|
||||
{showOriginal ? (
|
||||
<audio src={remoteUrl || url} preload="none" controls autoplay />
|
||||
<audio src={remoteUrl || url} preload="none" controls autoPlay />
|
||||
) : previewUrl ? (
|
||||
<img
|
||||
src={previewUrl}
|
||||
|
@ -460,6 +649,12 @@ function Media({
|
|||
height={height}
|
||||
data-orientation={orientation}
|
||||
loading="lazy"
|
||||
onError={(e) => {
|
||||
try {
|
||||
// Remove self if broken
|
||||
e.target?.remove?.();
|
||||
} catch (e) {}
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{!showOriginal && (
|
||||
|
@ -478,4 +673,13 @@ function Media({
|
|||
}
|
||||
}
|
||||
|
||||
function getURLObj(url) {
|
||||
try {
|
||||
// Fake base URL if url doesn't have https:// prefix
|
||||
return new URL(url, location.origin);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default Media;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { Menu, MenuItem, SubMenu } from '@szhsin/react-menu';
|
||||
import { MenuItem } from '@szhsin/react-menu';
|
||||
import { cloneElement } from 'preact';
|
||||
import { useRef } from 'preact/hooks';
|
||||
|
||||
import Menu2 from './menu2';
|
||||
import SubMenu2 from './submenu2';
|
||||
|
||||
function MenuConfirm({
|
||||
subMenu = false,
|
||||
|
@ -8,6 +10,7 @@ function MenuConfirm({
|
|||
confirmLabel,
|
||||
menuItemClassName,
|
||||
menuFooter,
|
||||
menuExtras,
|
||||
...props
|
||||
}) {
|
||||
const { children, onClick, ...restProps } = props;
|
||||
|
@ -20,11 +23,9 @@ function MenuConfirm({
|
|||
}
|
||||
return children;
|
||||
}
|
||||
const Parent = subMenu ? SubMenu : Menu;
|
||||
const menuRef = useRef();
|
||||
const Parent = subMenu ? SubMenu2 : Menu2;
|
||||
return (
|
||||
<Parent
|
||||
instanceRef={menuRef}
|
||||
openTrigger="clickOnly"
|
||||
direction="bottom"
|
||||
overflow="auto"
|
||||
|
@ -34,23 +35,11 @@ function MenuConfirm({
|
|||
{...restProps}
|
||||
menuButton={subMenu ? undefined : children}
|
||||
label={subMenu ? children : undefined}
|
||||
// Test fix for bug; submenus not opening on Android
|
||||
itemProps={{
|
||||
onPointerMove: (e) => {
|
||||
if (e.pointerType === 'touch') {
|
||||
menuRef.current?.openMenu?.();
|
||||
}
|
||||
},
|
||||
onPointerLeave: (e) => {
|
||||
if (e.pointerType === 'touch') {
|
||||
menuRef.current?.openMenu?.();
|
||||
}
|
||||
},
|
||||
}}
|
||||
>
|
||||
<MenuItem className={menuItemClassName} onClick={onClick}>
|
||||
{confirmLabel}
|
||||
</MenuItem>
|
||||
{menuExtras}
|
||||
{menuFooter}
|
||||
</Parent>
|
||||
);
|
||||
|
|
|
@ -3,11 +3,12 @@ import { FocusableItem } from '@szhsin/react-menu';
|
|||
import Link from './link';
|
||||
|
||||
function MenuLink(props) {
|
||||
const { className, disabled, ...restProps } = props;
|
||||
return (
|
||||
<FocusableItem>
|
||||
<FocusableItem className={className} disabled={disabled}>
|
||||
{({ ref, closeMenu }) => (
|
||||
<Link
|
||||
{...props}
|
||||
{...restProps}
|
||||
ref={ref}
|
||||
onClick={({ detail }) =>
|
||||
closeMenu(detail === 0 ? 'Enter' : undefined)
|
||||
|
|
|
@ -6,13 +6,15 @@ import safeBoundingBoxPadding from '../utils/safe-bounding-box-padding';
|
|||
|
||||
// It's like Menu but with sensible defaults, bug fixes and improvements.
|
||||
function Menu2(props) {
|
||||
const { containerProps } = props;
|
||||
const { containerProps, instanceRef: _instanceRef } = props;
|
||||
const size = useWindowSize();
|
||||
const instanceRef = useRef();
|
||||
const instanceRef = _instanceRef?.current ? _instanceRef : useRef();
|
||||
|
||||
return (
|
||||
<Menu
|
||||
boundingBoxPadding={safeBoundingBoxPadding()}
|
||||
repositionFlag={`${size.width}x${size.height}`}
|
||||
unmountOnClose
|
||||
{...props}
|
||||
instanceRef={instanceRef}
|
||||
containerProps={{
|
||||
|
|
|
@ -9,17 +9,57 @@
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: var(--backdrop-color);
|
||||
backdrop-filter: blur(24px);
|
||||
animation: appear 0.5s var(--timing-function) both;
|
||||
}
|
||||
#modal-container > div .sheet {
|
||||
transition: transform 0.3s var(--timing-function);
|
||||
transform-origin: center bottom;
|
||||
}
|
||||
#modal-container > div:has(~ div) .sheet {
|
||||
transform: scale(0.975);
|
||||
transition: all 0.5s var(--timing-function);
|
||||
|
||||
&.solid {
|
||||
background-color: var(--backdrop-solid-color);
|
||||
}
|
||||
|
||||
--compose-button-dimension: 56px;
|
||||
--compose-button-dimension-half: calc(var(--compose-button-dimension) / 2);
|
||||
--compose-button-dimension-margin: 16px;
|
||||
|
||||
&.min {
|
||||
/* Minimized */
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
overflow: hidden;
|
||||
transform: scale(0);
|
||||
--right: max(
|
||||
var(--compose-button-dimension-margin),
|
||||
env(safe-area-inset-right)
|
||||
);
|
||||
--bottom: max(
|
||||
var(--compose-button-dimension-margin),
|
||||
env(safe-area-inset-bottom)
|
||||
);
|
||||
--origin-right: calc(
|
||||
100% - var(--compose-button-dimension-half) - var(--right)
|
||||
);
|
||||
--origin-bottom: calc(
|
||||
100% - var(--compose-button-dimension-half) - var(--bottom)
|
||||
);
|
||||
transform-origin: var(--origin-right) var(--origin-bottom);
|
||||
}
|
||||
|
||||
.sheet {
|
||||
transition: transform 0.3s var(--timing-function);
|
||||
transform-origin: 80% 80%;
|
||||
}
|
||||
|
||||
&:has(~ div) .sheet {
|
||||
transform: scale(0.975);
|
||||
}
|
||||
}
|
||||
|
||||
#modal-container > .light {
|
||||
backdrop-filter: saturate(0.75);
|
||||
@media (max-width: calc(40em - 1px)) {
|
||||
#app[data-shortcuts-view-mode='tab-menu-bar'] ~ #modal-container > div.min {
|
||||
border: 2px solid red;
|
||||
|
||||
--bottom: calc(
|
||||
var(--compose-button-dimension-margin) + env(safe-area-inset-bottom) +
|
||||
52px
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import { createPortal } from 'preact/compat';
|
|||
import { useEffect, useRef } from 'preact/hooks';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
|
||||
import useCloseWatcher from '../utils/useCloseWatcher';
|
||||
|
||||
const $modalContainer = document.getElementById('modal-container');
|
||||
|
||||
function Modal({ children, onClose, onClick, class: className }) {
|
||||
function Modal({ children, onClose, onClick, class: className, minimized }) {
|
||||
if (!children) return null;
|
||||
|
||||
const modalRef = useRef();
|
||||
|
@ -20,9 +22,51 @@ function Modal({ children, onClose, onClick, class: className }) {
|
|||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const escRef = useHotkeys('esc', onClose, [onClose], {
|
||||
enabled: !!onClose,
|
||||
});
|
||||
const supportsCloseWatcher = window.CloseWatcher;
|
||||
const escRef = useHotkeys(
|
||||
'esc',
|
||||
() => {
|
||||
setTimeout(() => {
|
||||
onClose?.();
|
||||
}, 0);
|
||||
},
|
||||
{
|
||||
enabled: !supportsCloseWatcher && !!onClose,
|
||||
// Using keyup and setTimeout above
|
||||
// This will run "later" to prevent clash with esc handlers from other components
|
||||
keydown: false,
|
||||
keyup: true,
|
||||
},
|
||||
[onClose],
|
||||
);
|
||||
useCloseWatcher(onClose, [onClose]);
|
||||
|
||||
useEffect(() => {
|
||||
const $deckContainers = document.querySelectorAll('.deck-container');
|
||||
if (minimized) {
|
||||
// Similar to focusDeck in focus-deck.jsx
|
||||
// Focus last deck
|
||||
const page = $deckContainers[$deckContainers.length - 1]; // last one
|
||||
if (page && page.tabIndex === -1) {
|
||||
page.focus();
|
||||
}
|
||||
} else {
|
||||
if (children) {
|
||||
$deckContainers.forEach(($deckContainer) => {
|
||||
$deckContainer.setAttribute('inert', '');
|
||||
});
|
||||
} else {
|
||||
$deckContainers.forEach(($deckContainer) => {
|
||||
$deckContainer.removeAttribute('inert');
|
||||
});
|
||||
}
|
||||
}
|
||||
return () => {
|
||||
$deckContainers.forEach(($deckContainer) => {
|
||||
$deckContainer.removeAttribute('inert');
|
||||
});
|
||||
};
|
||||
}, [children, minimized]);
|
||||
|
||||
const Modal = (
|
||||
<div
|
||||
|
@ -37,10 +81,22 @@ function Modal({ children, onClose, onClick, class: className }) {
|
|||
onClose?.(e);
|
||||
}
|
||||
}}
|
||||
tabIndex="-1"
|
||||
tabIndex={minimized ? 0 : '-1'}
|
||||
inert={minimized}
|
||||
onFocus={(e) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
modalRef.current?.querySelector?.('[tabindex="-1"]')?.focus?.();
|
||||
try {
|
||||
if (e.target === e.currentTarget) {
|
||||
const focusElement =
|
||||
modalRef.current?.querySelector('[tabindex="-1"]');
|
||||
const isFocusable =
|
||||
!!focusElement &&
|
||||
getComputedStyle(focusElement)?.pointerEvents !== 'none';
|
||||
if (focusElement && isFocusable) {
|
||||
focusElement.focus();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { useEffect } from 'preact/hooks';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { subscribe, useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -8,12 +9,14 @@ import showToast from '../utils/show-toast';
|
|||
import states from '../utils/states';
|
||||
|
||||
import AccountSheet from './account-sheet';
|
||||
import Compose from './compose';
|
||||
import ComposeSuspense, { preload } from './compose-suspense';
|
||||
import Drafts from './drafts';
|
||||
import EmbedModal from './embed-modal';
|
||||
import GenericAccounts from './generic-accounts';
|
||||
import MediaAltModal from './media-alt-modal';
|
||||
import MediaModal from './media-modal';
|
||||
import Modal from './modal';
|
||||
import ReportModal from './report-modal';
|
||||
import ShortcutsSettings from './shortcuts-settings';
|
||||
|
||||
subscribe(states, (changes) => {
|
||||
|
@ -30,11 +33,18 @@ export default function Modals() {
|
|||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(preload, 1000);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{!!snapStates.showCompose && (
|
||||
<Modal>
|
||||
<Compose
|
||||
<Modal
|
||||
class={`solid ${snapStates.composerState.minimized ? 'min' : ''}`}
|
||||
minimized={!!snapStates.composerState.minimized}
|
||||
>
|
||||
<ComposeSuspense
|
||||
replyToStatus={
|
||||
typeof snapStates.showCompose !== 'boolean'
|
||||
? snapStates.showCompose.replyToStatus
|
||||
|
@ -107,7 +117,6 @@ export default function Modals() {
|
|||
)}
|
||||
{!!snapStates.showAccount && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClose={() => {
|
||||
states.showAccount = false;
|
||||
}}
|
||||
|
@ -117,9 +126,10 @@ export default function Modals() {
|
|||
instance={snapStates.showAccount?.instance}
|
||||
onClose={({ destination } = {}) => {
|
||||
states.showAccount = false;
|
||||
if (destination) {
|
||||
states.showAccounts = false;
|
||||
}
|
||||
// states.showGenericAccounts = false;
|
||||
// if (destination) {
|
||||
// states.showAccounts = false;
|
||||
// }
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
|
@ -157,7 +167,6 @@ export default function Modals() {
|
|||
)}
|
||||
{!!snapStates.showShortcutsSettings && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClose={() => {
|
||||
states.showShortcutsSettings = false;
|
||||
}}
|
||||
|
@ -169,23 +178,25 @@ export default function Modals() {
|
|||
)}
|
||||
{!!snapStates.showGenericAccounts && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClose={() => {
|
||||
states.showGenericAccounts = false;
|
||||
}}
|
||||
>
|
||||
<GenericAccounts
|
||||
instance={snapStates.showGenericAccounts.instance}
|
||||
excludeRelationshipAttrs={
|
||||
snapStates.showGenericAccounts.excludeRelationshipAttrs
|
||||
}
|
||||
postID={snapStates.showGenericAccounts.postID}
|
||||
onClose={() => (states.showGenericAccounts = false)}
|
||||
blankCopy={snapStates.showGenericAccounts.blankCopy}
|
||||
/>
|
||||
</Modal>
|
||||
)}
|
||||
{!!snapStates.showMediaAlt && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
states.showMediaAlt = false;
|
||||
}
|
||||
onClose={(e) => {
|
||||
states.showMediaAlt = false;
|
||||
}}
|
||||
>
|
||||
<MediaAltModal
|
||||
|
@ -197,6 +208,39 @@ export default function Modals() {
|
|||
/>
|
||||
</Modal>
|
||||
)}
|
||||
{!!snapStates.showEmbedModal && (
|
||||
<Modal
|
||||
class="solid"
|
||||
onClose={() => {
|
||||
states.showEmbedModal = false;
|
||||
}}
|
||||
>
|
||||
<EmbedModal
|
||||
html={snapStates.showEmbedModal.html}
|
||||
url={snapStates.showEmbedModal.url}
|
||||
width={snapStates.showEmbedModal.width}
|
||||
height={snapStates.showEmbedModal.height}
|
||||
onClose={() => {
|
||||
states.showEmbedModal = false;
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
)}
|
||||
{!!snapStates.showReportModal && (
|
||||
<Modal
|
||||
onClose={() => {
|
||||
states.showReportModal = false;
|
||||
}}
|
||||
>
|
||||
<ReportModal
|
||||
account={snapStates.showReportModal.account}
|
||||
post={snapStates.showReportModal.post}
|
||||
onClose={() => {
|
||||
states.showReportModal = false;
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,17 @@
|
|||
color: inherit;
|
||||
text-decoration: none;
|
||||
display: inline;
|
||||
unicode-bidi: isolate;
|
||||
|
||||
b {
|
||||
font-weight: 500;
|
||||
unicode-bidi: isolate;
|
||||
}
|
||||
|
||||
i {
|
||||
font-variant-numeric: slashed-zero;
|
||||
font-feature-settings: 'ss01';
|
||||
}
|
||||
}
|
||||
.name-text.show-acct {
|
||||
display: inline-block;
|
||||
|
|
|
@ -7,6 +7,10 @@ import states from '../utils/states';
|
|||
import Avatar from './avatar';
|
||||
import EmojiText from './emoji-text';
|
||||
|
||||
const nameCollator = new Intl.Collator('en', {
|
||||
sensitivity: 'base',
|
||||
});
|
||||
|
||||
function NameText({
|
||||
account,
|
||||
instance,
|
||||
|
@ -16,9 +20,17 @@ function NameText({
|
|||
external,
|
||||
onClick,
|
||||
}) {
|
||||
const { acct, avatar, avatarStatic, id, url, displayName, emojis, bot } =
|
||||
account;
|
||||
let { username } = account;
|
||||
const {
|
||||
acct,
|
||||
avatar,
|
||||
avatarStatic,
|
||||
id,
|
||||
url,
|
||||
displayName,
|
||||
emojis,
|
||||
bot,
|
||||
username,
|
||||
} = account;
|
||||
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
||||
|
||||
const trimmedUsername = username.toLowerCase().trim();
|
||||
|
@ -27,33 +39,39 @@ function NameText({
|
|||
.replace(/(\:(\w|\+|\-)+\:)(?=|[\!\.\?]|$)/g, '') // Remove shortcodes, regex from https://regex101.com/r/iE9uV0/1
|
||||
.replace(/\s+/g, ''); // E.g. "My name" === "myname"
|
||||
const shortenedAlphaNumericDisplayName = shortenedDisplayName.replace(
|
||||
/[^a-z0-9]/gi,
|
||||
/[^a-z0-9@\.]/gi,
|
||||
'',
|
||||
); // Remove non-alphanumeric characters
|
||||
|
||||
if (
|
||||
!short &&
|
||||
(trimmedUsername === trimmedDisplayName ||
|
||||
trimmedUsername === shortenedDisplayName ||
|
||||
trimmedUsername === shortenedAlphaNumericDisplayName ||
|
||||
trimmedUsername.localeCompare?.(shortenedDisplayName, 'en', {
|
||||
sensitivity: 'base',
|
||||
}) === 0)
|
||||
) {
|
||||
username = null;
|
||||
}
|
||||
const hideUsername =
|
||||
(!short &&
|
||||
(trimmedUsername === trimmedDisplayName ||
|
||||
trimmedUsername === shortenedDisplayName ||
|
||||
trimmedUsername === shortenedAlphaNumericDisplayName ||
|
||||
nameCollator.compare(trimmedUsername, shortenedDisplayName) === 0)) ||
|
||||
shortenedAlphaNumericDisplayName === acct.toLowerCase();
|
||||
|
||||
return (
|
||||
<a
|
||||
class={`name-text ${showAcct ? 'show-acct' : ''} ${short ? 'short' : ''}`}
|
||||
href={url}
|
||||
target={external ? '_blank' : null}
|
||||
title={`${displayName ? `${displayName} ` : ''}@${acct}`}
|
||||
title={
|
||||
displayName
|
||||
? `${displayName} (${acct2 ? '' : '@'}${acct})`
|
||||
: `${acct2 ? '' : '@'}${acct}`
|
||||
}
|
||||
onClick={(e) => {
|
||||
if (external) return;
|
||||
if (e.shiftKey) return; // Save link? 🤷♂️
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (onClick) return onClick(e);
|
||||
if (e.metaKey || e.ctrlKey || e.shiftKey || e.which === 2) {
|
||||
const internalURL = `#/${instance}/a/${id}`;
|
||||
window.open(internalURL, '_blank');
|
||||
return;
|
||||
}
|
||||
states.showAccount = {
|
||||
account,
|
||||
instance,
|
||||
|
@ -70,7 +88,7 @@ function NameText({
|
|||
<b>
|
||||
<EmojiText text={displayName} emojis={emojis} />
|
||||
</b>
|
||||
{!showAcct && username && (
|
||||
{!showAcct && !hideUsername && (
|
||||
<>
|
||||
{' '}
|
||||
<i>@{username}</i>
|
||||
|
@ -86,8 +104,9 @@ function NameText({
|
|||
<>
|
||||
<br />
|
||||
<i>
|
||||
@{acct1}
|
||||
<span class="ib">{acct2}</span>
|
||||
{acct2 ? '' : '@'}
|
||||
{acct1}
|
||||
{!!acct2 && <span class="ib">{acct2}</span>}
|
||||
</i>
|
||||
</>
|
||||
)}
|
||||
|
@ -95,4 +114,9 @@ function NameText({
|
|||
);
|
||||
}
|
||||
|
||||
export default memo(NameText);
|
||||
export default memo(NameText, (oldProps, newProps) => {
|
||||
// Only care about account.id, the other props usually don't change
|
||||
const { account } = oldProps;
|
||||
const { account: newAccount } = newProps;
|
||||
return account?.acct === newAccount?.acct;
|
||||
});
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
.nav-menu section:last-child {
|
||||
background-color: var(--bg-faded-color);
|
||||
margin-bottom: -8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
@media (min-width: 23em) {
|
||||
.nav-menu {
|
||||
display: grid;
|
||||
|
@ -8,6 +14,7 @@
|
|||
'left right';
|
||||
padding: 0;
|
||||
width: 22em;
|
||||
max-width: calc(100vw - 16px);
|
||||
}
|
||||
.nav-menu .top-menu {
|
||||
grid-area: top;
|
||||
|
@ -27,7 +34,6 @@
|
|||
}
|
||||
}
|
||||
.nav-menu section:last-child {
|
||||
background-color: var(--bg-faded-color);
|
||||
background-image: linear-gradient(
|
||||
to right,
|
||||
var(--divider-color) 1px,
|
||||
|
@ -45,6 +51,15 @@
|
|||
animation: phanpying 0.2s ease-in-out both;
|
||||
border-top-right-radius: inherit;
|
||||
border-bottom-right-radius: inherit;
|
||||
margin-bottom: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.divider-grow {
|
||||
flex-grow: 1;
|
||||
height: auto;
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
.nav-menu section:last-child > .szh-menu__divider:first-child {
|
||||
display: none;
|
||||
|
@ -73,3 +88,7 @@
|
|||
.sparkle-icon {
|
||||
animation: sparkle-icon 0.3s ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
.nav-submenu {
|
||||
max-width: 14em;
|
||||
}
|
||||
|
|
|
@ -1,33 +1,34 @@
|
|||
import './nav-menu.css';
|
||||
|
||||
import { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
||||
import { useLongPress } from 'use-long-press';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
import { getLists } from '../utils/lists';
|
||||
import safeBoundingBoxPadding from '../utils/safe-bounding-box-padding';
|
||||
import states from '../utils/states';
|
||||
import store from '../utils/store';
|
||||
import { getCurrentAccountID } from '../utils/store-utils';
|
||||
import supports from '../utils/supports';
|
||||
|
||||
import Avatar from './avatar';
|
||||
import Icon from './icon';
|
||||
import MenuLink from './menu-link';
|
||||
import SubMenu2 from './submenu2';
|
||||
|
||||
function NavMenu(props) {
|
||||
const snapStates = useSnapshot(states);
|
||||
const { masto, instance, authenticated } = api();
|
||||
|
||||
const [currentAccount, setCurrentAccount] = useState();
|
||||
const [moreThanOneAccount, setMoreThanOneAccount] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const [currentAccount, moreThanOneAccount] = useMemo(() => {
|
||||
const accounts = store.local.getJSON('accounts') || [];
|
||||
const acc = accounts.find(
|
||||
(account) => account.info.id === store.session.get('currentAccount'),
|
||||
);
|
||||
if (acc) setCurrentAccount(acc);
|
||||
setMoreThanOneAccount(accounts.length > 1);
|
||||
const acc =
|
||||
accounts.find((account) => account.info.id === getCurrentAccountID()) ||
|
||||
accounts[0];
|
||||
return [acc, accounts.length > 1];
|
||||
}, []);
|
||||
|
||||
// Home = Following
|
||||
|
@ -35,8 +36,9 @@ function NavMenu(props) {
|
|||
// User may choose pin or not to pin Following
|
||||
// If user doesn't pin Following, we show it in the menu
|
||||
const showFollowing =
|
||||
(snapStates.settings.shortcutsColumnsMode ||
|
||||
snapStates.settings.shortcutsViewMode === 'multi-column') &&
|
||||
(snapStates.settings.shortcutsViewMode === 'multi-column' ||
|
||||
(!snapStates.settings.shortcutsViewMode &&
|
||||
snapStates.settings.shortcutsColumnsMode)) &&
|
||||
!snapStates.shortcuts.find((pin) => pin.type === 'following');
|
||||
|
||||
const bindLongPress = useLongPress(
|
||||
|
@ -82,6 +84,16 @@ function NavMenu(props) {
|
|||
return results;
|
||||
}
|
||||
|
||||
const supportsLists = supports('@mastodon/lists');
|
||||
const [lists, setLists] = useState([]);
|
||||
useEffect(() => {
|
||||
if (!supportsLists) return;
|
||||
if (menuState === 'open') {
|
||||
getLists().then(setLists);
|
||||
}
|
||||
}, [menuState === 'open']);
|
||||
|
||||
const buttonClickTS = useRef();
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
|
@ -89,9 +101,10 @@ function NavMenu(props) {
|
|||
type="button"
|
||||
class={`button plain nav-menu-button ${
|
||||
moreThanOneAccount ? 'with-avatar' : ''
|
||||
} ${open ? 'active' : ''}`}
|
||||
} ${menuState === 'open' ? 'active' : ''}`}
|
||||
style={{ position: 'relative' }}
|
||||
onClick={() => {
|
||||
buttonClickTS.current = Date.now();
|
||||
setMenuState((state) => (!state ? 'open' : undefined));
|
||||
}}
|
||||
onContextMenu={(e) => {
|
||||
|
@ -123,7 +136,10 @@ function NavMenu(props) {
|
|||
zIndex: 10,
|
||||
},
|
||||
onClick: () => {
|
||||
setMenuState(undefined);
|
||||
if (Date.now() - buttonClickTS.current < 300) {
|
||||
return;
|
||||
}
|
||||
// setMenuState(undefined);
|
||||
},
|
||||
}}
|
||||
portal={{
|
||||
|
@ -162,16 +178,22 @@ function NavMenu(props) {
|
|||
<MenuLink to="/">
|
||||
<Icon icon="home" size="l" /> <span>Home</span>
|
||||
</MenuLink>
|
||||
{authenticated && (
|
||||
{authenticated ? (
|
||||
<>
|
||||
{showFollowing && (
|
||||
<MenuLink to="/following">
|
||||
<Icon icon="following" size="l" /> <span>Following</span>
|
||||
</MenuLink>
|
||||
)}
|
||||
<MenuLink to="/mentions">
|
||||
<Icon icon="at" size="l" /> <span>Mentions</span>
|
||||
<MenuLink to="/catchup">
|
||||
<Icon icon="history2" size="l" />
|
||||
<span>Catch-up</span>
|
||||
</MenuLink>
|
||||
{supports('@mastodon/mentions') && (
|
||||
<MenuLink to="/mentions">
|
||||
<Icon icon="at" size="l" /> <span>Mentions</span>
|
||||
</MenuLink>
|
||||
)}
|
||||
<MenuLink to="/notifications">
|
||||
<Icon icon="notification" size="l" /> <span>Notifications</span>
|
||||
{snapStates.notificationsShowNew && (
|
||||
|
@ -181,44 +203,103 @@ function NavMenu(props) {
|
|||
</sup>
|
||||
)}
|
||||
</MenuLink>
|
||||
<MenuDivider />
|
||||
<MenuLink to="/l">
|
||||
<Icon icon="list" size="l" /> <span>Lists</span>
|
||||
</MenuLink>
|
||||
<MenuLink to="/ft">
|
||||
<Icon icon="hashtag" size="l" /> <span>Followed Hashtags</span>
|
||||
</MenuLink>
|
||||
<MenuLink to="/b">
|
||||
<Icon icon="bookmark" size="l" /> <span>Bookmarks</span>
|
||||
</MenuLink>
|
||||
<MenuLink to="/f">
|
||||
<Icon icon="heart" size="l" /> <span>Favourites</span>
|
||||
</MenuLink>
|
||||
</>
|
||||
)}
|
||||
<MenuDivider />
|
||||
<MenuLink to={`/search`}>
|
||||
<Icon icon="search" size="l" /> <span>Search</span>
|
||||
</MenuLink>
|
||||
<MenuLink to={`/${instance}/p/l`}>
|
||||
<Icon icon="group" size="l" /> <span>Local</span>
|
||||
</MenuLink>
|
||||
<MenuLink to={`/${instance}/p`}>
|
||||
<Icon icon="earth" size="l" /> <span>Federated</span>
|
||||
</MenuLink>
|
||||
<MenuLink to={`/${instance}/trending`}>
|
||||
<Icon icon="chart" size="l" /> <span>Trending</span>
|
||||
</MenuLink>
|
||||
</section>
|
||||
<section>
|
||||
{authenticated ? (
|
||||
<>
|
||||
<MenuDivider />
|
||||
{currentAccount?.info?.id && (
|
||||
<MenuLink to={`/${instance}/a/${currentAccount.info.id}`}>
|
||||
<Icon icon="user" size="l" /> <span>Profile</span>
|
||||
</MenuLink>
|
||||
)}
|
||||
{lists?.length > 0 ? (
|
||||
<SubMenu2
|
||||
menuClassName="nav-submenu"
|
||||
overflow="auto"
|
||||
gap={-8}
|
||||
label={
|
||||
<>
|
||||
<Icon icon="list" size="l" />
|
||||
<span class="menu-grow">Lists</span>
|
||||
<Icon icon="chevron-right" />
|
||||
</>
|
||||
}
|
||||
>
|
||||
<MenuLink to="/l">
|
||||
<span>All Lists</span>
|
||||
</MenuLink>
|
||||
{lists?.length > 0 && (
|
||||
<>
|
||||
<MenuDivider />
|
||||
{lists.map((list) => (
|
||||
<MenuLink key={list.id} to={`/l/${list.id}`}>
|
||||
<span>{list.title}</span>
|
||||
</MenuLink>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</SubMenu2>
|
||||
) : (
|
||||
supportsLists && (
|
||||
<MenuLink to="/l">
|
||||
<Icon icon="list" size="l" />
|
||||
<span>Lists</span>
|
||||
</MenuLink>
|
||||
)
|
||||
)}
|
||||
<MenuLink to="/b">
|
||||
<Icon icon="bookmark" size="l" /> <span>Bookmarks</span>
|
||||
</MenuLink>
|
||||
<SubMenu2
|
||||
menuClassName="nav-submenu"
|
||||
overflow="auto"
|
||||
gap={-8}
|
||||
label={
|
||||
<>
|
||||
<Icon icon="more" size="l" />
|
||||
<span class="menu-grow">More…</span>
|
||||
<Icon icon="chevron-right" />
|
||||
</>
|
||||
}
|
||||
>
|
||||
<MenuLink to="/f">
|
||||
<Icon icon="heart" size="l" /> <span>Likes</span>
|
||||
</MenuLink>
|
||||
<MenuLink to="/fh">
|
||||
<Icon icon="hashtag" size="l" />{' '}
|
||||
<span>Followed Hashtags</span>
|
||||
</MenuLink>
|
||||
<MenuDivider />
|
||||
{supports('@mastodon/filters') && (
|
||||
<MenuLink to="/ft">
|
||||
<Icon icon="filters" size="l" />
|
||||
Filters
|
||||
</MenuLink>
|
||||
)}
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
states.showGenericAccounts = {
|
||||
id: 'mute',
|
||||
heading: 'Muted users',
|
||||
fetchAccounts: fetchMutes,
|
||||
excludeRelationshipAttrs: ['muting'],
|
||||
};
|
||||
}}
|
||||
>
|
||||
<Icon icon="mute" size="l" /> Muted users…
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
states.showGenericAccounts = {
|
||||
id: 'block',
|
||||
heading: 'Blocked users',
|
||||
fetchAccounts: fetchBlocks,
|
||||
excludeRelationshipAttrs: ['blocking'],
|
||||
};
|
||||
}}
|
||||
>
|
||||
<Icon icon="block" size="l" />
|
||||
Blocked users…
|
||||
</MenuItem>{' '}
|
||||
</SubMenu2>
|
||||
<MenuDivider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
states.showAccounts = true;
|
||||
|
@ -226,29 +307,33 @@ function NavMenu(props) {
|
|||
>
|
||||
<Icon icon="group" size="l" /> <span>Accounts…</span>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
states.showGenericAccounts = {
|
||||
id: 'mute',
|
||||
heading: 'Muted users',
|
||||
fetchAccounts: fetchMutes,
|
||||
};
|
||||
}}
|
||||
>
|
||||
<Icon icon="mute" size="l" /> Muted users…
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
states.showGenericAccounts = {
|
||||
id: 'block',
|
||||
heading: 'Blocked users',
|
||||
fetchAccounts: fetchBlocks,
|
||||
};
|
||||
}}
|
||||
>
|
||||
<Icon icon="block" size="l" />
|
||||
Blocked users…
|
||||
</MenuItem>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<MenuDivider />
|
||||
<MenuLink to="/login">
|
||||
<Icon icon="user" size="l" /> <span>Log in</span>
|
||||
</MenuLink>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
<section>
|
||||
<MenuDivider />
|
||||
<MenuLink to={`/search`}>
|
||||
<Icon icon="search" size="l" /> <span>Search</span>
|
||||
</MenuLink>
|
||||
<MenuLink to={`/${instance}/trending`}>
|
||||
<Icon icon="chart" size="l" /> <span>Trending</span>
|
||||
</MenuLink>
|
||||
<MenuLink to={`/${instance}/p/l`}>
|
||||
<Icon icon="building" size="l" /> <span>Local</span>
|
||||
</MenuLink>
|
||||
<MenuLink to={`/${instance}/p`}>
|
||||
<Icon icon="earth" size="l" /> <span>Federated</span>
|
||||
</MenuLink>
|
||||
{authenticated ? (
|
||||
<>
|
||||
<MenuDivider className="divider-grow" />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
states.showKeyboardShortcutsHelp = true;
|
||||
|
@ -263,7 +348,7 @@ function NavMenu(props) {
|
|||
}}
|
||||
>
|
||||
<Icon icon="shortcut" size="l" />{' '}
|
||||
<span>Shortcuts Settings…</span>
|
||||
<span>Shortcuts / Columns…</span>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
|
@ -276,9 +361,6 @@ function NavMenu(props) {
|
|||
) : (
|
||||
<>
|
||||
<MenuDivider />
|
||||
<MenuLink to="/login">
|
||||
<Icon icon="user" size="l" /> <span>Log in</span>
|
||||
</MenuLink>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
states.showSettings = true;
|
||||
|
@ -294,4 +376,4 @@ function NavMenu(props) {
|
|||
);
|
||||
}
|
||||
|
||||
export default NavMenu;
|
||||
export default memo(NavMenu);
|
||||
|
|
|
@ -15,6 +15,22 @@ import Link from './link';
|
|||
import Modal from './modal';
|
||||
import Notification from './notification';
|
||||
|
||||
{
|
||||
if ('serviceWorker' in navigator) {
|
||||
console.log('👂👂👂 Listen to message');
|
||||
navigator.serviceWorker.addEventListener('message', (event) => {
|
||||
console.log('💥💥💥 Message event', event);
|
||||
const { type, id, accessToken } = event?.data || {};
|
||||
if (type === 'notification') {
|
||||
states.routeNotification = {
|
||||
id,
|
||||
accessToken,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(function NotificationService() {
|
||||
if (!('serviceWorker' in navigator)) return null;
|
||||
|
||||
|
@ -38,7 +54,7 @@ export default memo(function NotificationService() {
|
|||
? getAccountByAccessToken(accessToken)
|
||||
: getCurrentAccount();
|
||||
(async () => {
|
||||
const notification = await masto.v1.notifications.fetch(id);
|
||||
const notification = await masto.v1.notifications.$select(id).fetch();
|
||||
if (notification && account) {
|
||||
console.log('🛎️ Notification', { id, notification, account });
|
||||
const accountInstance = account.instanceURL;
|
||||
|
@ -77,34 +93,30 @@ export default memo(function NotificationService() {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
'🛎️ Notification not found',
|
||||
notificationID,
|
||||
notificationAccessToken,
|
||||
);
|
||||
console.warn('🛎️ Notification not found', id);
|
||||
}
|
||||
})();
|
||||
}, [id, accessToken]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
// Listen to message from service worker
|
||||
const handleMessage = (event) => {
|
||||
console.log('💥💥💥 Message event', event);
|
||||
const { type, id, accessToken } = event?.data || {};
|
||||
if (type === 'notification') {
|
||||
states.routeNotification = {
|
||||
id,
|
||||
accessToken,
|
||||
};
|
||||
}
|
||||
};
|
||||
console.log('👂👂👂 Listen to message');
|
||||
navigator.serviceWorker.addEventListener('message', handleMessage);
|
||||
return () => {
|
||||
console.log('👂👂👂 Remove listen to message');
|
||||
navigator.serviceWorker.removeEventListener('message', handleMessage);
|
||||
};
|
||||
}, []);
|
||||
// useLayoutEffect(() => {
|
||||
// // Listen to message from service worker
|
||||
// const handleMessage = (event) => {
|
||||
// console.log('💥💥💥 Message event', event);
|
||||
// const { type, id, accessToken } = event?.data || {};
|
||||
// if (type === 'notification') {
|
||||
// states.routeNotification = {
|
||||
// id,
|
||||
// accessToken,
|
||||
// };
|
||||
// }
|
||||
// };
|
||||
// console.log('👂👂👂 Listen to message');
|
||||
// navigator.serviceWorker.addEventListener('message', handleMessage);
|
||||
// return () => {
|
||||
// console.log('👂👂👂 Remove listen to message');
|
||||
// navigator.serviceWorker.removeEventListener('message', handleMessage);
|
||||
// };
|
||||
// }, []);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (navigator?.clearAppBadge) {
|
||||
|
@ -132,7 +144,6 @@ export default memo(function NotificationService() {
|
|||
const { id, account, notification, sameInstance } = showNotificationSheet;
|
||||
return (
|
||||
<Modal
|
||||
class="light"
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
onClose();
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
import { Fragment } from 'preact';
|
||||
import { memo } from 'preact/compat';
|
||||
|
||||
import shortenNumber from '../utils/shorten-number';
|
||||
import states from '../utils/states';
|
||||
import states, { statusKey } from '../utils/states';
|
||||
import store from '../utils/store';
|
||||
import { getCurrentAccountID } from '../utils/store-utils';
|
||||
import useTruncated from '../utils/useTruncated';
|
||||
|
||||
import Avatar from './avatar';
|
||||
import CustomEmoji from './custom-emoji';
|
||||
import FollowRequestButtons from './follow-request-buttons';
|
||||
import Icon from './icon';
|
||||
import Link from './link';
|
||||
|
@ -22,6 +27,10 @@ const NOTIFICATION_ICONS = {
|
|||
update: 'pencil',
|
||||
'admin.signup': 'account-edit',
|
||||
'admin.report': 'account-warning',
|
||||
severed_relationships: 'heart-break',
|
||||
moderation_warning: 'alert',
|
||||
emoji_reaction: 'emoji2',
|
||||
'pleroma:emoji_reaction': 'emoji2',
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -37,8 +46,28 @@ poll = A poll you have voted in or created has ended
|
|||
update = A status you interacted with has been edited
|
||||
admin.sign_up = Someone signed up (optionally sent to admins)
|
||||
admin.report = A new report has been filed
|
||||
severed_relationships = Severed relationships
|
||||
moderation_warning = Moderation warning
|
||||
*/
|
||||
|
||||
function emojiText(emoji, emoji_url) {
|
||||
let url;
|
||||
let staticUrl;
|
||||
if (typeof emoji_url === 'string') {
|
||||
url = emoji_url;
|
||||
} else {
|
||||
url = emoji_url?.url;
|
||||
staticUrl = emoji_url?.staticUrl;
|
||||
}
|
||||
return url ? (
|
||||
<>
|
||||
reacted to your post with{' '}
|
||||
<CustomEmoji url={url} staticUrl={staticUrl} alt={emoji} />
|
||||
</>
|
||||
) : (
|
||||
`reacted to your post with ${emoji}.`
|
||||
);
|
||||
}
|
||||
const contentText = {
|
||||
mention: 'mentioned you in their post.',
|
||||
status: 'published a post.',
|
||||
|
@ -47,32 +76,87 @@ const contentText = {
|
|||
reblog_reply: 'boosted your reply.',
|
||||
follow: 'followed you.',
|
||||
follow_request: 'requested to follow you.',
|
||||
favourite: 'favourited your post.',
|
||||
'favourite+account': (count) => `favourited ${count} of your posts.`,
|
||||
favourite_reply: 'favourited your reply.',
|
||||
favourite: 'liked your post.',
|
||||
'favourite+account': (count) => `liked ${count} of your posts.`,
|
||||
favourite_reply: 'liked your reply.',
|
||||
poll: 'A poll you have voted in or created has ended.',
|
||||
'poll-self': 'A poll you have created has ended.',
|
||||
'poll-voted': 'A poll you have voted in has ended.',
|
||||
update: 'A post you interacted with has been edited.',
|
||||
'favourite+reblog': 'boosted & favourited your post.',
|
||||
'favourite+reblog': 'boosted & liked your post.',
|
||||
'favourite+reblog+account': (count) =>
|
||||
`boosted & favourited ${count} of your posts.`,
|
||||
'favourite+reblog_reply': 'boosted & favourited your reply.',
|
||||
'admin.signup': 'signed up.',
|
||||
'admin.report': 'reported a post.',
|
||||
`boosted & liked ${count} of your posts.`,
|
||||
'favourite+reblog_reply': 'boosted & liked your reply.',
|
||||
'admin.sign_up': 'signed up.',
|
||||
'admin.report': (targetAccount) => <>reported {targetAccount}</>,
|
||||
severed_relationships: (name) => (
|
||||
<>
|
||||
Lost connections with <i>{name}</i>.
|
||||
</>
|
||||
),
|
||||
moderation_warning: <b>Moderation warning</b>,
|
||||
emoji_reaction: emojiText,
|
||||
'pleroma:emoji_reaction': emojiText,
|
||||
};
|
||||
|
||||
const AVATARS_LIMIT = 50;
|
||||
// account_suspension, domain_block, user_domain_block
|
||||
const SEVERED_RELATIONSHIPS_TEXT = {
|
||||
account_suspension: ({ from, targetName }) => (
|
||||
<>
|
||||
An admin from <i>{from}</i> has suspended <i>{targetName}</i>, which means
|
||||
you can no longer receive updates from them or interact with them.
|
||||
</>
|
||||
),
|
||||
domain_block: ({ from, targetName, followersCount, followingCount }) => (
|
||||
<>
|
||||
An admin from <i>{from}</i> has blocked <i>{targetName}</i>. Affected
|
||||
followers: {followersCount}, followings: {followingCount}.
|
||||
</>
|
||||
),
|
||||
user_domain_block: ({ targetName, followersCount, followingCount }) => (
|
||||
<>
|
||||
You have blocked <i>{targetName}</i>. Removed followers: {followersCount},
|
||||
followings: {followingCount}.
|
||||
</>
|
||||
),
|
||||
};
|
||||
|
||||
function Notification({ notification, instance, reload, isStatic }) {
|
||||
const { id, status, account, _accounts, _statuses } = notification;
|
||||
const MODERATION_WARNING_TEXT = {
|
||||
none: 'Your account has received a moderation warning.',
|
||||
disable: 'Your account has been disabled.',
|
||||
mark_statuses_as_sensitive:
|
||||
'Some of your posts have been marked as sensitive.',
|
||||
delete_statuses: 'Some of your posts have been deleted.',
|
||||
sensitive: 'Your posts will be marked as sensitive from now on.',
|
||||
silence: 'Your account has been limited.',
|
||||
suspend: 'Your account has been suspended.',
|
||||
};
|
||||
|
||||
const AVATARS_LIMIT = 30;
|
||||
|
||||
function Notification({
|
||||
notification,
|
||||
instance,
|
||||
isStatic,
|
||||
disableContextMenu,
|
||||
}) {
|
||||
const {
|
||||
id,
|
||||
status,
|
||||
account,
|
||||
report,
|
||||
event,
|
||||
moderation_warning,
|
||||
_accounts,
|
||||
_statuses,
|
||||
} = notification;
|
||||
let { type } = notification;
|
||||
|
||||
// status = Attached when type of the notification is favourite, reblog, status, mention, poll, or update
|
||||
const actualStatus = status?.reblog || status;
|
||||
const actualStatusID = actualStatus?.id;
|
||||
|
||||
const currentAccount = store.session.get('currentAccount');
|
||||
const currentAccount = getCurrentAccountID();
|
||||
const isSelf = currentAccount === account?.id;
|
||||
const isVoted = status?.poll?.voted;
|
||||
const isReplyToOthers =
|
||||
|
@ -119,7 +203,32 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
}
|
||||
|
||||
if (typeof text === 'function') {
|
||||
text = text(_statuses?.length || _accounts?.length);
|
||||
const count = _statuses?.length || _accounts?.length;
|
||||
if (type === 'admin.report') {
|
||||
const targetAccount = report?.targetAccount;
|
||||
if (targetAccount) {
|
||||
text = text(<NameText account={targetAccount} showAvatar />);
|
||||
}
|
||||
} else if (type === 'severed_relationships') {
|
||||
const targetName = event?.targetName;
|
||||
if (targetName) {
|
||||
text = text(targetName);
|
||||
}
|
||||
} else if (
|
||||
(type === 'emoji_reaction' || type === 'pleroma:emoji_reaction') &&
|
||||
notification.emoji
|
||||
) {
|
||||
const emojiURL =
|
||||
notification.emoji_url || // This is string
|
||||
status?.emojis?.find?.(
|
||||
(emoji) =>
|
||||
emoji?.shortcode ===
|
||||
notification.emoji.replace(/^:/, '').replace(/:$/, ''),
|
||||
); // Emoji object instead of string
|
||||
text = text(notification.emoji, emojiURL);
|
||||
} else if (count) {
|
||||
text = text(count);
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'mention' && !status) {
|
||||
|
@ -132,8 +241,8 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
|
||||
const genericAccountsHeading =
|
||||
{
|
||||
'favourite+reblog': 'Boosted/Favourited by…',
|
||||
favourite: 'Favourited by…',
|
||||
'favourite+reblog': 'Boosted/Liked by…',
|
||||
favourite: 'Liked by…',
|
||||
reblog: 'Boosted by…',
|
||||
follow: 'Followed by…',
|
||||
}[type] || 'Accounts';
|
||||
|
@ -142,11 +251,19 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
heading: genericAccountsHeading,
|
||||
accounts: _accounts,
|
||||
showReactions: type === 'favourite+reblog',
|
||||
excludeRelationshipAttrs: type === 'follow' ? ['followedBy'] : [],
|
||||
postID: statusKey(actualStatusID, instance),
|
||||
};
|
||||
};
|
||||
|
||||
console.debug('RENDER Notification', notification.id);
|
||||
|
||||
return (
|
||||
<div class={`notification notification-${type}`} tabIndex="0">
|
||||
<div
|
||||
class={`notification notification-${type}`}
|
||||
data-notification-id={id}
|
||||
tabIndex="0"
|
||||
>
|
||||
<div
|
||||
class={`notification-type notification-${type}`}
|
||||
title={formattedCreatedAt}
|
||||
|
@ -180,9 +297,11 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
</b>{' '}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<NameText account={account} showAvatar />{' '}
|
||||
</>
|
||||
account && (
|
||||
<>
|
||||
<NameText account={account} showAvatar />{' '}
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
@ -199,20 +318,47 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
)}
|
||||
</p>
|
||||
{type === 'follow_request' && (
|
||||
<FollowRequestButtons
|
||||
accountID={account.id}
|
||||
onChange={() => {
|
||||
// reload();
|
||||
}}
|
||||
/>
|
||||
<FollowRequestButtons accountID={account.id} />
|
||||
)}
|
||||
{type === 'severed_relationships' && (
|
||||
<div>
|
||||
{SEVERED_RELATIONSHIPS_TEXT[event.type]({
|
||||
from: instance,
|
||||
...event,
|
||||
})}
|
||||
<br />
|
||||
<a
|
||||
href={`https://${instance}/severed_relationships`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn more <Icon icon="external" size="s" />
|
||||
</a>
|
||||
.
|
||||
</div>
|
||||
)}
|
||||
{type === 'moderation_warning' && !!moderation_warning && (
|
||||
<div>
|
||||
{MODERATION_WARNING_TEXT[moderation_warning.action]}
|
||||
<br />
|
||||
<a
|
||||
href={`/disputes/strikes/${moderation_warning.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn more <Icon icon="external" size="s" />
|
||||
</a>
|
||||
.
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{_accounts?.length > 1 && (
|
||||
<p class="avatars-stack">
|
||||
{_accounts.slice(0, AVATARS_LIMIT).map((account, i) => (
|
||||
<>
|
||||
{_accounts.slice(0, AVATARS_LIMIT).map((account) => (
|
||||
<Fragment key={account.id}>
|
||||
<a
|
||||
key={account.id}
|
||||
href={account.url}
|
||||
rel="noopener noreferrer"
|
||||
class="account-avatar-stack"
|
||||
|
@ -228,11 +374,7 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
? 'xxl'
|
||||
: _accounts.length < 20
|
||||
? 'xl'
|
||||
: _accounts.length < 30
|
||||
? 'l'
|
||||
: _accounts.length < 40
|
||||
? 'm'
|
||||
: 's' // My god, this person is popular!
|
||||
: 'l'
|
||||
}
|
||||
key={account.id}
|
||||
alt={`${account.displayName} @${account.acct}`}
|
||||
|
@ -250,7 +392,7 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
</div>
|
||||
)}
|
||||
</a>{' '}
|
||||
</>
|
||||
</Fragment>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
|
@ -273,7 +415,12 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
instance ? `/${instance}/s/${status.id}` : `/s/${status.id}`
|
||||
}
|
||||
>
|
||||
<Status status={status} size="s" />
|
||||
<Status
|
||||
status={status}
|
||||
size="s"
|
||||
previewMode
|
||||
allowContextMenu
|
||||
/>
|
||||
</TruncatedLink>
|
||||
</li>
|
||||
))}
|
||||
|
@ -287,25 +434,39 @@ function Notification({ notification, instance, reload, isStatic }) {
|
|||
? `/${instance}/s/${actualStatusID}`
|
||||
: `/s/${actualStatusID}`
|
||||
}
|
||||
onContextMenu={(e) => {
|
||||
const post = e.target.querySelector('.status');
|
||||
if (post) {
|
||||
// Fire a custom event to open the context menu
|
||||
if (e.metaKey) return;
|
||||
e.preventDefault();
|
||||
post.dispatchEvent(
|
||||
new MouseEvent('contextmenu', {
|
||||
clientX: e.clientX,
|
||||
clientY: e.clientY,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}}
|
||||
onContextMenu={
|
||||
!disableContextMenu
|
||||
? (e) => {
|
||||
const post = e.target.querySelector('.status');
|
||||
if (post) {
|
||||
// Fire a custom event to open the context menu
|
||||
if (e.metaKey) return;
|
||||
e.preventDefault();
|
||||
post.dispatchEvent(
|
||||
new MouseEvent('contextmenu', {
|
||||
clientX: e.clientX,
|
||||
clientY: e.clientY,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{isStatic ? (
|
||||
<Status status={actualStatus} size="s" />
|
||||
<Status
|
||||
status={actualStatus}
|
||||
size="s"
|
||||
readOnly
|
||||
allowContextMenu
|
||||
/>
|
||||
) : (
|
||||
<Status statusID={actualStatusID} size="s" />
|
||||
<Status
|
||||
statusID={actualStatusID}
|
||||
size="s"
|
||||
readOnly
|
||||
allowContextMenu
|
||||
/>
|
||||
)}
|
||||
</TruncatedLink>
|
||||
)}
|
||||
|
@ -319,4 +480,6 @@ function TruncatedLink(props) {
|
|||
return <Link {...props} data-read-more="Read more →" ref={ref} />;
|
||||
}
|
||||
|
||||
export default Notification;
|
||||
export default memo(Notification, (oldProps, newProps) => {
|
||||
return oldProps.notification?.id === newProps.notification?.id;
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ import dayjs from 'dayjs';
|
|||
import dayjsTwitter from 'dayjs-twitter';
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { useEffect, useMemo, useReducer } from 'preact/hooks';
|
||||
|
||||
dayjs.extend(dayjsTwitter);
|
||||
dayjs.extend(localizedFormat);
|
||||
|
@ -18,40 +18,54 @@ const dtf = new Intl.DateTimeFormat();
|
|||
|
||||
export default function RelativeTime({ datetime, format }) {
|
||||
if (!datetime) return null;
|
||||
const date = dayjs(datetime);
|
||||
const [dateStr, setDateStr] = useState('');
|
||||
const [renderCount, rerender] = useReducer((x) => x + 1, 0);
|
||||
const date = useMemo(() => dayjs(datetime), [datetime]);
|
||||
const [dateStr, dt, title] = useMemo(() => {
|
||||
if (!date.isValid()) return ['' + datetime, '', ''];
|
||||
let str;
|
||||
if (format === 'micro') {
|
||||
// If date <= 1 day ago or day is within this year
|
||||
const now = dayjs();
|
||||
const dayDiff = now.diff(date, 'day');
|
||||
if (dayDiff <= 1 || now.year() === date.year()) {
|
||||
str = date.twitter();
|
||||
} else {
|
||||
str = dtf.format(date.toDate());
|
||||
}
|
||||
}
|
||||
if (!str) str = date.fromNow();
|
||||
return [str, date.toISOString(), date.format('LLLL')];
|
||||
}, [date, format, renderCount]);
|
||||
|
||||
useEffect(() => {
|
||||
let timer, raf;
|
||||
const update = () => {
|
||||
if (!date.isValid()) return;
|
||||
let timeout;
|
||||
let raf;
|
||||
function rafRerender() {
|
||||
raf = requestAnimationFrame(() => {
|
||||
let str;
|
||||
if (format === 'micro') {
|
||||
// If date <= 1 day ago or day is within this year
|
||||
const now = dayjs();
|
||||
const dayDiff = now.diff(date, 'day');
|
||||
if (dayDiff <= 1 || now.year() === date.year()) {
|
||||
str = date.twitter();
|
||||
} else {
|
||||
str = dtf.format(date.toDate());
|
||||
}
|
||||
} else {
|
||||
str = date.fromNow();
|
||||
}
|
||||
setDateStr(str);
|
||||
|
||||
timer = setTimeout(update, 30_000);
|
||||
rerender();
|
||||
scheduleRerender();
|
||||
});
|
||||
};
|
||||
raf = requestAnimationFrame(update);
|
||||
}
|
||||
function scheduleRerender() {
|
||||
// If less than 1 minute, rerender every 10s
|
||||
// If less than 1 hour rerender every 1m
|
||||
// Else, don't need to rerender
|
||||
if (date.diff(dayjs(), 'minute', true) < 1) {
|
||||
timeout = setTimeout(rafRerender, 10_000);
|
||||
} else if (date.diff(dayjs(), 'hour', true) < 1) {
|
||||
timeout = setTimeout(rafRerender, 60_000);
|
||||
}
|
||||
}
|
||||
scheduleRerender();
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
clearTimeout(timeout);
|
||||
cancelAnimationFrame(raf);
|
||||
};
|
||||
}, [date]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<time datetime={date.toISOString()} title={date.format('LLLL')}>
|
||||
<time datetime={dt} title={title}>
|
||||
{dateStr}
|
||||
</time>
|
||||
);
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
.report-modal-container {
|
||||
width: 100%;
|
||||
max-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 40em;
|
||||
background-color: var(--bg-color);
|
||||
box-shadow: 0 16px 32px -8px var(--drop-shadow-color);
|
||||
overflow-y: auto;
|
||||
animation: slide-up-smooth 0.3s ease-in-out;
|
||||
position: relative;
|
||||
|
||||
@media (min-width: 40em) {
|
||||
max-height: calc(100% - 32px);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.top-controls {
|
||||
position: sticky;
|
||||
top: var(--sai-top, 0);
|
||||
z-index: 1;
|
||||
background-color: var(--bg-blur-color);
|
||||
backdrop-filter: blur(16px);
|
||||
padding: 16px;
|
||||
padding: calc(var(--sai-top, 0) + 16px) calc(var(--sai-right, 0) + 16px)
|
||||
16px calc(var(--sai-left, 0) + 16px);
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: space-between;
|
||||
pointer-events: auto;
|
||||
align-items: center;
|
||||
|
||||
h1 {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 0 16px 16px;
|
||||
padding: 0 calc(var(--sai-right, 0) + 16px)
|
||||
calc(var(--sai-bottom, 0) + 16px) calc(var(--sai-left, 0) + 16px);
|
||||
/* display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px; */
|
||||
}
|
||||
|
||||
form {
|
||||
/* display: flex; */
|
||||
/* flex-direction: column; */
|
||||
/* gap: 16px; */
|
||||
text-wrap: pretty;
|
||||
|
||||
input {
|
||||
margin-inline: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.report-preview {
|
||||
background-color: var(--bg-color);
|
||||
border-radius: 8px;
|
||||
border: 2px dashed var(--red-color);
|
||||
box-shadow: inset 0 0 16px -4px var(--red-bg-color);
|
||||
overflow: auto;
|
||||
max-height: 33vh;
|
||||
|
||||
.status {
|
||||
font-size: 90%;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-drag: none;
|
||||
filter: grayscale(0.5);
|
||||
}
|
||||
|
||||
.account-block {
|
||||
margin: 16px;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-drag: none;
|
||||
filter: grayscale(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
.rubber-stamp {
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
position: absolute;
|
||||
right: 32px;
|
||||
margin-top: -48px;
|
||||
animation: rubber-stamp 0.3s ease-in both;
|
||||
position: absolute;
|
||||
font-weight: bold;
|
||||
color: var(--red-color);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: -0.5px;
|
||||
font-size: 2em;
|
||||
line-height: 1;
|
||||
padding: 0.1em;
|
||||
border: 0.15em solid var(--red-color);
|
||||
border-radius: 0.3em;
|
||||
background-color: var(--bg-blur-color);
|
||||
text-align: center;
|
||||
/* Noise pattern - https://css-tricks.com/making-static-noise-from-a-weird-css-gradient-bug/ */
|
||||
mask-image: repeating-conic-gradient(
|
||||
#000 0 0.01%,
|
||||
rgba(0, 0, 0, 0.45) 0 0.02%
|
||||
);
|
||||
|
||||
small {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
margin-block: 0.5em;
|
||||
}
|
||||
|
||||
section {
|
||||
label {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
margin-bottom: 8px;
|
||||
|
||||
&:has(:checked) {
|
||||
.insignificant {
|
||||
color: var(--text-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
> label:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.report-categories {
|
||||
label {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.report-rules {
|
||||
margin-left: 1.75em;
|
||||
}
|
||||
}
|
||||
|
||||
.report-comment {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: flex-start;
|
||||
margin-top: 2em;
|
||||
flex-wrap: wrap;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
padding: 8px 0 0;
|
||||
flex-shrink: 0;
|
||||
|
||||
label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
textarea {
|
||||
flex-grow: 1;
|
||||
resize: vertical;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 2em;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
button {
|
||||
border-radius: 8px !important;
|
||||
align-self: stretch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes rubber-stamp {
|
||||
0% {
|
||||
transform: rotate(-20deg) scale(5);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
transform: rotate(-20deg) scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,298 @@
|
|||
import './report-modal.css';
|
||||
|
||||
import { Fragment } from 'preact';
|
||||
import { useMemo, useRef, useState } from 'preact/hooks';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
import showToast from '../utils/show-toast';
|
||||
import { getCurrentInstance } from '../utils/store-utils';
|
||||
|
||||
import AccountBlock from './account-block';
|
||||
import Icon from './icon';
|
||||
import Loader from './loader';
|
||||
import Status from './status';
|
||||
|
||||
// NOTE: `dislike` hidden for now, it's actually not used for reporting
|
||||
// Mastodon shows another screen for unfollowing, muting or blocking instead of reporting
|
||||
|
||||
const CATEGORIES = [, /*'dislike'*/ 'spam', 'legal', 'violation', 'other'];
|
||||
// `violation` will be set if there are `rule_ids[]`
|
||||
|
||||
const CATEGORIES_INFO = {
|
||||
// dislike: {
|
||||
// label: 'Dislike',
|
||||
// description: 'Not something you want to see',
|
||||
// },
|
||||
spam: {
|
||||
label: 'Spam',
|
||||
description: 'Malicious links, fake engagement, or repetitive replies',
|
||||
},
|
||||
legal: {
|
||||
label: 'Illegal',
|
||||
description: "Violates the law of your or the server's country",
|
||||
},
|
||||
violation: {
|
||||
label: 'Server rule violation',
|
||||
description: 'Breaks specific server rules',
|
||||
stampLabel: 'Violation',
|
||||
},
|
||||
other: {
|
||||
label: 'Other',
|
||||
description: "Issue doesn't fit other categories",
|
||||
excludeStamp: true,
|
||||
},
|
||||
};
|
||||
|
||||
function ReportModal({ account, post, onClose }) {
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [username, domain] = account.acct.split('@');
|
||||
|
||||
const [rules, currentDomain] = useMemo(() => {
|
||||
const { rules, domain } = getCurrentInstance();
|
||||
return [rules || [], domain];
|
||||
});
|
||||
|
||||
const [selectedCategory, setSelectedCategory] = useState(null);
|
||||
const [showRules, setShowRules] = useState(false);
|
||||
|
||||
const rulesRef = useRef(null);
|
||||
const [hasRules, setHasRules] = useState(false);
|
||||
|
||||
return (
|
||||
<div class="report-modal-container">
|
||||
<div class="top-controls">
|
||||
<h1>{post ? 'Report Post' : `Report @${username}`}</h1>
|
||||
<button
|
||||
type="button"
|
||||
class="plain4 small"
|
||||
disabled={uiState === 'loading'}
|
||||
onClick={() => onClose()}
|
||||
>
|
||||
<Icon icon="x" size="xl" />
|
||||
</button>
|
||||
</div>
|
||||
<main>
|
||||
<div class="report-preview">
|
||||
{post ? (
|
||||
<Status status={post} size="s" previewMode />
|
||||
) : (
|
||||
<AccountBlock
|
||||
account={account}
|
||||
avatarSize="xxl"
|
||||
useAvatarStatic
|
||||
showStats
|
||||
showActivity
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{!!selectedCategory &&
|
||||
!CATEGORIES_INFO[selectedCategory].excludeStamp && (
|
||||
<span
|
||||
class="rubber-stamp"
|
||||
key={selectedCategory}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{CATEGORIES_INFO[selectedCategory].stampLabel ||
|
||||
CATEGORIES_INFO[selectedCategory].label}
|
||||
<small>Pending review</small>
|
||||
</span>
|
||||
)}
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(e.target);
|
||||
const entries = Object.fromEntries(formData.entries());
|
||||
console.log('ENTRIES', entries);
|
||||
|
||||
let { category, comment, forward } = entries;
|
||||
if (!comment) comment = undefined;
|
||||
if (forward === 'on') forward = true;
|
||||
const ruleIds =
|
||||
category === 'violation'
|
||||
? Object.entries(entries)
|
||||
.filter(([key]) => key.startsWith('rule_ids'))
|
||||
.map(([key, value]) => value)
|
||||
: undefined;
|
||||
|
||||
const params = {
|
||||
category,
|
||||
comment,
|
||||
forward,
|
||||
ruleIds,
|
||||
};
|
||||
console.log('PARAMS', params);
|
||||
|
||||
setUIState('loading');
|
||||
(async () => {
|
||||
try {
|
||||
await masto.v1.reports.create({
|
||||
accountId: account.id,
|
||||
statusIds: post?.id ? [post.id] : undefined,
|
||||
category,
|
||||
comment,
|
||||
ruleIds,
|
||||
forward,
|
||||
});
|
||||
setUIState('success');
|
||||
showToast(post ? 'Post reported' : 'Profile reported');
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
setUIState('error');
|
||||
showToast(
|
||||
error?.message ||
|
||||
(post
|
||||
? 'Unable to report post'
|
||||
: 'Unable to report profile'),
|
||||
);
|
||||
}
|
||||
})();
|
||||
}}
|
||||
>
|
||||
<p>
|
||||
{post
|
||||
? `What's the issue with this post?`
|
||||
: `What's the issue with this profile?`}
|
||||
</p>
|
||||
<section class="report-categories">
|
||||
{CATEGORIES.map((category) =>
|
||||
category === 'violation' && !rules?.length ? null : (
|
||||
<Fragment key={category}>
|
||||
<label class="report-category">
|
||||
<input
|
||||
type="radio"
|
||||
name="category"
|
||||
value={category}
|
||||
required
|
||||
disabled={uiState === 'loading'}
|
||||
onChange={(e) => {
|
||||
setSelectedCategory(e.target.value);
|
||||
setShowRules(e.target.value === 'violation');
|
||||
}}
|
||||
/>
|
||||
<span>
|
||||
{CATEGORIES_INFO[category].label}
|
||||
<small class="ib insignificant">
|
||||
{CATEGORIES_INFO[category].description}
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
{category === 'violation' && !!rules?.length && (
|
||||
<div
|
||||
class="shazam-container no-animation"
|
||||
hidden={!showRules}
|
||||
>
|
||||
<div class="shazam-container-inner">
|
||||
<div class="report-rules" ref={rulesRef}>
|
||||
{rules.map((rule, i) => (
|
||||
<label class="report-rule" key={rule.id}>
|
||||
<input
|
||||
type="checkbox"
|
||||
name={`rule_ids[${i}]`}
|
||||
value={rule.id}
|
||||
required={showRules && !hasRules}
|
||||
disabled={uiState === 'loading'}
|
||||
onChange={(e) => {
|
||||
const { checked } = e.target;
|
||||
if (checked) {
|
||||
setHasRules(true);
|
||||
} else {
|
||||
const checkedInputs =
|
||||
rulesRef.current.querySelectorAll(
|
||||
'input:checked',
|
||||
);
|
||||
if (!checkedInputs.length) {
|
||||
setHasRules(false);
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<span>{rule.text}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Fragment>
|
||||
),
|
||||
)}
|
||||
</section>
|
||||
<section class="report-comment">
|
||||
<p>
|
||||
<label for="report-comment">Additional info</label>
|
||||
</p>
|
||||
<textarea
|
||||
maxlength="1000"
|
||||
rows="1"
|
||||
name="comment"
|
||||
id="report-comment"
|
||||
disabled={uiState === 'loading'}
|
||||
/>
|
||||
</section>
|
||||
{!!domain && domain !== currentDomain && (
|
||||
<section>
|
||||
<p>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
switch
|
||||
name="forward"
|
||||
disabled={uiState === 'loading'}
|
||||
/>{' '}
|
||||
<span>
|
||||
Forward to <i>{domain}</i>
|
||||
</span>
|
||||
</label>
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
<footer>
|
||||
<button type="submit" disabled={uiState === 'loading'}>
|
||||
Send Report
|
||||
</button>{' '}
|
||||
<button
|
||||
type="submit"
|
||||
class="plain2"
|
||||
disabled={uiState === 'loading'}
|
||||
onClick={async () => {
|
||||
try {
|
||||
await masto.v1.accounts.$select(account.id).mute(); // Infinite duration
|
||||
showToast(`Muted ${username}`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showToast(`Unable to mute ${username}`);
|
||||
}
|
||||
// onSubmit will still run
|
||||
}}
|
||||
>
|
||||
Send Report <small class="ib">+ Mute profile</small>
|
||||
</button>{' '}
|
||||
<button
|
||||
type="submit"
|
||||
class="plain2"
|
||||
disabled={uiState === 'loading'}
|
||||
onClick={async () => {
|
||||
try {
|
||||
await masto.v1.accounts.$select(account.id).block();
|
||||
showToast(`Blocked ${username}`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showToast(`Unable to block ${username}`);
|
||||
}
|
||||
// onSubmit will still run
|
||||
}}
|
||||
>
|
||||
Send Report <small class="ib">+ Block profile</small>
|
||||
</button>
|
||||
<Loader hidden={uiState !== 'loading'} />
|
||||
</footer>
|
||||
</form>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ReportModal;
|
|
@ -11,7 +11,7 @@ export default memo(function SearchCommand({ onClose = () => {} }) {
|
|||
const searchFormRef = useRef(null);
|
||||
|
||||
useHotkeys(
|
||||
'/',
|
||||
['Slash', '/'],
|
||||
(e) => {
|
||||
setShowSearch(true);
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -73,6 +73,7 @@ const SearchForm = forwardRef((props, ref) => {
|
|||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellCheck="false"
|
||||
onSearch={(e) => {
|
||||
if (!e.target.value) {
|
||||
setSearchParams({});
|
||||
|
@ -84,6 +85,9 @@ const SearchForm = forwardRef((props, ref) => {
|
|||
}}
|
||||
onFocus={() => {
|
||||
setSearchMenuOpen(true);
|
||||
formRef.current
|
||||
?.querySelector('.search-popover-item')
|
||||
?.classList.add('focus');
|
||||
}}
|
||||
onBlur={() => {
|
||||
setTimeout(() => {
|
||||
|
@ -178,8 +182,33 @@ const SearchForm = forwardRef((props, ref) => {
|
|||
}}
|
||||
/>
|
||||
<div class="search-popover" hidden={!searchMenuOpen || !query}>
|
||||
{/* {!!query && (
|
||||
<Link
|
||||
to={`/search?q=${encodeURIComponent(query)}`}
|
||||
class="search-popover-item focus"
|
||||
onClick={(e) => {
|
||||
props?.onSubmit?.(e);
|
||||
}}
|
||||
>
|
||||
<Icon icon="search" />
|
||||
<span>{query}</span>
|
||||
</Link>
|
||||
)} */}
|
||||
{!!query &&
|
||||
[
|
||||
{
|
||||
label: (
|
||||
<>
|
||||
{query}{' '}
|
||||
<small class="insignificant">
|
||||
‒ accounts, hashtags & posts
|
||||
</small>
|
||||
</>
|
||||
),
|
||||
to: `/search?q=${encodeURIComponent(query)}`,
|
||||
top: !type && !/\s/.test(query),
|
||||
hidden: !!type,
|
||||
},
|
||||
{
|
||||
label: (
|
||||
<>
|
||||
|
@ -188,6 +217,9 @@ const SearchForm = forwardRef((props, ref) => {
|
|||
),
|
||||
to: `/search?q=${encodeURIComponent(query)}&type=statuses`,
|
||||
hidden: /^https?:/.test(query),
|
||||
top: /\s/.test(query),
|
||||
icon: 'document',
|
||||
queryType: 'statuses',
|
||||
},
|
||||
{
|
||||
label: (
|
||||
|
@ -200,6 +232,8 @@ const SearchForm = forwardRef((props, ref) => {
|
|||
/^@/.test(query) || /^https?:/.test(query) || /\s/.test(query),
|
||||
top: /^#/.test(query),
|
||||
type: 'link',
|
||||
icon: 'hashtag',
|
||||
queryType: 'hashtags',
|
||||
},
|
||||
{
|
||||
label: (
|
||||
|
@ -219,24 +253,31 @@ const SearchForm = forwardRef((props, ref) => {
|
|||
</>
|
||||
),
|
||||
to: `/search?q=${encodeURIComponent(query)}&type=accounts`,
|
||||
icon: 'group',
|
||||
queryType: 'accounts',
|
||||
},
|
||||
]
|
||||
.sort((a, b) => {
|
||||
if (type) {
|
||||
if (a.queryType === type) return -1;
|
||||
if (b.queryType === type) return 1;
|
||||
}
|
||||
if (a.top && !b.top) return -1;
|
||||
if (!a.top && b.top) return 1;
|
||||
return 0;
|
||||
})
|
||||
.map(({ label, to, hidden, type }) => (
|
||||
.filter(({ hidden }) => !hidden)
|
||||
.map(({ label, to, icon, type }, i) => (
|
||||
<Link
|
||||
to={to}
|
||||
class="search-popover-item"
|
||||
hidden={hidden}
|
||||
class={`search-popover-item ${i === 0 ? 'focus' : ''}`}
|
||||
// hidden={hidden}
|
||||
onClick={(e) => {
|
||||
props?.onSubmit?.(e);
|
||||
}}
|
||||
>
|
||||
<Icon
|
||||
icon={type === 'link' ? 'arrow-right' : 'search'}
|
||||
icon={icon || (type === 'link' ? 'arrow-right' : 'search')}
|
||||
class="more-insignificant"
|
||||
/>
|
||||
<span>{label}</span>{' '}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#shortcuts-settings-container .shortcuts-view-mode {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: stretch;
|
||||
gap: 2px;
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
@ -52,6 +52,7 @@
|
|||
gap: 8px;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
#shortcuts-settings-container .shortcuts-view-mode label:first-child {
|
||||
border-top-left-radius: 16px;
|
||||
|
@ -85,8 +86,9 @@
|
|||
transform: scale(0.975);
|
||||
transition: all 0.2s ease-out;
|
||||
}
|
||||
#shortcuts-settings-container .shortcuts-view-mode label:has(input:checked) {
|
||||
box-shadow: inset 0 0 0 3px var(--link-color);
|
||||
#shortcuts-settings-container .shortcuts-view-mode label.checked {
|
||||
box-shadow: inset 0 0 0 3px var(--link-color),
|
||||
inset 0 0 32px var(--link-faded-color);
|
||||
}
|
||||
#shortcuts-settings-container
|
||||
.shortcuts-view-mode
|
||||
|
@ -122,6 +124,11 @@
|
|||
min-width: 0;
|
||||
max-width: 320px;
|
||||
}
|
||||
#shortcut-settings-form .form-note {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
}
|
||||
#shortcut-settings-form form footer {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
|
@ -146,6 +153,15 @@
|
|||
}
|
||||
#import-export-container section p {
|
||||
margin: 8px 0;
|
||||
|
||||
&.field-button {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
|
||||
button {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#import-export-container section details > summary {
|
||||
cursor: pointer;
|
||||
|
@ -175,3 +191,14 @@
|
|||
font-size: 90%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
#import-export-container {
|
||||
footer {
|
||||
font-size: 90%;
|
||||
color: var(--text-insignificant-color);
|
||||
|
||||
.icon {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import './shortcuts-settings.css';
|
||||
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/preact';
|
||||
import {
|
||||
compressToEncodedURIComponent,
|
||||
decompressFromEncodedURIComponent,
|
||||
} from 'lz-string';
|
||||
import mem from 'mem';
|
||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -13,15 +13,20 @@ import multiColumnUrl from '../assets/multi-column.svg';
|
|||
import tabMenuBarUrl from '../assets/tab-menu-bar.svg';
|
||||
|
||||
import { api } from '../utils/api';
|
||||
import { fetchFollowedTags } from '../utils/followed-tags';
|
||||
import { getLists, getListTitle } from '../utils/lists';
|
||||
import pmem from '../utils/pmem';
|
||||
import showToast from '../utils/show-toast';
|
||||
import states from '../utils/states';
|
||||
import store from '../utils/store';
|
||||
import { getCurrentAccountID } from '../utils/store-utils';
|
||||
|
||||
import AsyncText from './AsyncText';
|
||||
import Icon from './icon';
|
||||
import MenuConfirm from './menu-confirm';
|
||||
import Modal from './modal';
|
||||
|
||||
const SHORTCUTS_LIMIT = 9;
|
||||
export const SHORTCUTS_LIMIT = 9;
|
||||
|
||||
const TYPES = [
|
||||
'following',
|
||||
|
@ -30,22 +35,22 @@ const TYPES = [
|
|||
'list',
|
||||
'public',
|
||||
'trending',
|
||||
// NOTE: Hide for now
|
||||
// 'search', // Search on Mastodon ain't great
|
||||
// 'account-statuses', // Need @acct search first
|
||||
'search',
|
||||
'hashtag',
|
||||
'bookmarks',
|
||||
'favourites',
|
||||
// NOTE: Hide for now
|
||||
// 'account-statuses', // Need @acct search first
|
||||
];
|
||||
const TYPE_TEXT = {
|
||||
following: 'Home / Following',
|
||||
notifications: 'Notifications',
|
||||
list: 'List',
|
||||
list: 'Lists',
|
||||
public: 'Public (Local / Federated)',
|
||||
search: 'Search',
|
||||
'account-statuses': 'Account',
|
||||
bookmarks: 'Bookmarks',
|
||||
favourites: 'Favourites',
|
||||
favourites: 'Likes',
|
||||
hashtag: 'Hashtag',
|
||||
trending: 'Trending',
|
||||
mentions: 'Mentions',
|
||||
|
@ -55,6 +60,7 @@ const TYPE_PARAMS = {
|
|||
{
|
||||
text: 'List ID',
|
||||
name: 'id',
|
||||
notRequired: true,
|
||||
},
|
||||
],
|
||||
public: [
|
||||
|
@ -85,6 +91,8 @@ const TYPE_PARAMS = {
|
|||
text: 'Search term',
|
||||
name: 'query',
|
||||
type: 'text',
|
||||
placeholder: 'Optional, unless for multi-column mode',
|
||||
notRequired: true,
|
||||
},
|
||||
],
|
||||
'account-statuses': [
|
||||
|
@ -103,6 +111,11 @@ const TYPE_PARAMS = {
|
|||
placeholder: 'e.g. PixelArt (Max 5, space-separated)',
|
||||
pattern: '[^#]+',
|
||||
},
|
||||
{
|
||||
text: 'Media only',
|
||||
name: 'media',
|
||||
type: 'checkbox',
|
||||
},
|
||||
{
|
||||
text: 'Instance',
|
||||
name: 'instance',
|
||||
|
@ -112,6 +125,10 @@ const TYPE_PARAMS = {
|
|||
},
|
||||
],
|
||||
};
|
||||
const fetchAccountTitle = pmem(async ({ id }) => {
|
||||
const account = await api().masto.v1.accounts.$select(id).fetch();
|
||||
return account.username || account.acct || account.displayName;
|
||||
});
|
||||
export const SHORTCUTS_META = {
|
||||
following: {
|
||||
id: 'home',
|
||||
|
@ -132,25 +149,18 @@ export const SHORTCUTS_META = {
|
|||
icon: 'notification',
|
||||
},
|
||||
list: {
|
||||
id: 'list',
|
||||
title: mem(
|
||||
async ({ id }) => {
|
||||
const list = await api().masto.v1.lists.fetch(id);
|
||||
return list.title;
|
||||
},
|
||||
{
|
||||
cacheKey: ([{ id }]) => id,
|
||||
},
|
||||
),
|
||||
path: ({ id }) => `/l/${id}`,
|
||||
id: ({ id }) => (id ? 'list' : 'lists'),
|
||||
title: ({ id }) => (id ? getListTitle(id) : 'Lists'),
|
||||
path: ({ id }) => (id ? `/l/${id}` : '/l'),
|
||||
icon: 'list',
|
||||
excludeViewMode: ({ id }) => (!id ? ['multi-column'] : []),
|
||||
},
|
||||
public: {
|
||||
id: 'public',
|
||||
title: ({ local }) => (local ? 'Local' : 'Federated'),
|
||||
subtitle: ({ instance }) => instance || api().instance,
|
||||
path: ({ local, instance }) => `/${instance}/p${local ? '/l' : ''}`,
|
||||
icon: ({ local }) => (local ? 'group' : 'earth'),
|
||||
icon: ({ local }) => (local ? 'building' : 'earth'),
|
||||
},
|
||||
trending: {
|
||||
id: 'trending',
|
||||
|
@ -161,21 +171,17 @@ export const SHORTCUTS_META = {
|
|||
},
|
||||
search: {
|
||||
id: 'search',
|
||||
title: ({ query }) => query,
|
||||
path: ({ query }) => `/search?q=${query}`,
|
||||
title: ({ query }) => (query ? `“${query}”` : 'Search'),
|
||||
path: ({ query }) =>
|
||||
query
|
||||
? `/search?q=${encodeURIComponent(query)}&type=statuses`
|
||||
: '/search',
|
||||
icon: 'search',
|
||||
excludeViewMode: ({ query }) => (!query ? ['multi-column'] : []),
|
||||
},
|
||||
'account-statuses': {
|
||||
id: 'account-statuses',
|
||||
title: mem(
|
||||
async ({ id }) => {
|
||||
const account = await api().masto.v1.accounts.fetch(id);
|
||||
return account.username || account.acct || account.displayName;
|
||||
},
|
||||
{
|
||||
cacheKey: ([{ id }]) => id,
|
||||
},
|
||||
),
|
||||
title: fetchAccountTitle,
|
||||
path: ({ id }) => `/a/${id}`,
|
||||
icon: 'user',
|
||||
},
|
||||
|
@ -187,7 +193,7 @@ export const SHORTCUTS_META = {
|
|||
},
|
||||
favourites: {
|
||||
id: 'favourites',
|
||||
title: 'Favourites',
|
||||
title: 'Likes',
|
||||
path: '/f',
|
||||
icon: 'heart',
|
||||
},
|
||||
|
@ -195,47 +201,21 @@ export const SHORTCUTS_META = {
|
|||
id: 'hashtag',
|
||||
title: ({ hashtag }) => hashtag,
|
||||
subtitle: ({ instance }) => instance || api().instance,
|
||||
path: ({ hashtag, instance }) =>
|
||||
`${instance ? `/${instance}` : ''}/t/${hashtag.split(/\s+/).join('+')}`,
|
||||
path: ({ hashtag, instance, media }) =>
|
||||
`${instance ? `/${instance}` : ''}/t/${hashtag.split(/\s+/).join('+')}${
|
||||
media ? '?media=1' : ''
|
||||
}`,
|
||||
icon: 'hashtag',
|
||||
},
|
||||
};
|
||||
|
||||
function ShortcutsSettings({ onClose }) {
|
||||
const snapStates = useSnapshot(states);
|
||||
const { masto } = api();
|
||||
const { shortcuts } = snapStates;
|
||||
|
||||
const [lists, setLists] = useState([]);
|
||||
const [followedHashtags, setFollowedHashtags] = useState([]);
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [showImportExport, setShowImportExport] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const lists = await masto.v1.lists.list();
|
||||
setLists(lists);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const iterator = masto.v1.followedTags.list();
|
||||
const tags = [];
|
||||
do {
|
||||
const { value, done } = await iterator.next();
|
||||
if (done || value?.length === 0) break;
|
||||
tags.push(...value);
|
||||
} while (true);
|
||||
setFollowedHashtags(tags);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
const [shortcutsListParent] = useAutoAnimate();
|
||||
|
||||
return (
|
||||
<div id="shortcuts-settings-container" class="sheet" tabindex="-1">
|
||||
|
@ -259,36 +239,36 @@ function ShortcutsSettings({ onClose }) {
|
|||
</h2>
|
||||
</header>
|
||||
<main>
|
||||
<p>
|
||||
Specify a list of shortcuts that'll appear as:
|
||||
<div class="shortcuts-view-mode">
|
||||
{[
|
||||
{
|
||||
value: 'float-button',
|
||||
label: 'Floating button',
|
||||
imgURL: floatingButtonUrl,
|
||||
},
|
||||
{
|
||||
value: 'tab-menu-bar',
|
||||
label: 'Tab/Menu bar',
|
||||
imgURL: tabMenuBarUrl,
|
||||
},
|
||||
{
|
||||
value: 'multi-column',
|
||||
label: 'Multi-column',
|
||||
imgURL: multiColumnUrl,
|
||||
},
|
||||
].map(({ value, label, imgURL }) => (
|
||||
<label>
|
||||
<p>Specify a list of shortcuts that'll appear as:</p>
|
||||
<div class="shortcuts-view-mode">
|
||||
{[
|
||||
{
|
||||
value: 'float-button',
|
||||
label: 'Floating button',
|
||||
imgURL: floatingButtonUrl,
|
||||
},
|
||||
{
|
||||
value: 'tab-menu-bar',
|
||||
label: 'Tab/Menu bar',
|
||||
imgURL: tabMenuBarUrl,
|
||||
},
|
||||
{
|
||||
value: 'multi-column',
|
||||
label: 'Multi-column',
|
||||
imgURL: multiColumnUrl,
|
||||
},
|
||||
].map(({ value, label, imgURL }) => {
|
||||
const checked =
|
||||
snapStates.settings.shortcutsViewMode === value ||
|
||||
(value === 'float-button' &&
|
||||
!snapStates.settings.shortcutsViewMode);
|
||||
return (
|
||||
<label key={value} class={checked ? 'checked' : ''}>
|
||||
<input
|
||||
type="radio"
|
||||
name="shortcuts-view-mode"
|
||||
value={value}
|
||||
checked={
|
||||
snapStates.settings.shortcutsViewMode === value ||
|
||||
(value === 'float-button' &&
|
||||
!snapStates.settings.shortcutsViewMode)
|
||||
}
|
||||
checked={checked}
|
||||
onChange={(e) => {
|
||||
states.settings.shortcutsViewMode = e.target.value;
|
||||
}}
|
||||
|
@ -296,110 +276,97 @@ function ShortcutsSettings({ onClose }) {
|
|||
<img src={imgURL} alt="" width="80" height="58" />{' '}
|
||||
<span>{label}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
{/* <select
|
||||
value={snapStates.settings.shortcutsViewMode || 'float-button'}
|
||||
onChange={(e) => {
|
||||
states.settings.shortcutsViewMode = e.target.value;
|
||||
}}
|
||||
>
|
||||
<option value="float-button">Floating button</option>
|
||||
<option value="multi-column">Multi-column</option>
|
||||
<option value="tab-menu-bar">Tab/Menu bar </option>
|
||||
</select> */}
|
||||
</p>
|
||||
{/* <p>
|
||||
<details>
|
||||
<summary class="insignificant">
|
||||
Experimental Multi-column mode
|
||||
</summary>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={snapStates.settings.shortcutsColumnsMode}
|
||||
onChange={(e) => {
|
||||
states.settings.shortcutsColumnsMode = e.target.checked;
|
||||
}}
|
||||
/>{' '}
|
||||
Show shortcuts in multiple columns instead of the floating button.
|
||||
</label>
|
||||
</details>
|
||||
</p> */}
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{shortcuts.length > 0 ? (
|
||||
<ol class="shortcuts-list">
|
||||
{shortcuts.filter(Boolean).map((shortcut, i) => {
|
||||
const key = i + Object.values(shortcut);
|
||||
const { type } = shortcut;
|
||||
if (!SHORTCUTS_META[type]) return null;
|
||||
let { icon, title, subtitle } = SHORTCUTS_META[type];
|
||||
if (typeof title === 'function') {
|
||||
title = title(shortcut, i);
|
||||
}
|
||||
if (typeof subtitle === 'function') {
|
||||
subtitle = subtitle(shortcut, i);
|
||||
}
|
||||
if (typeof icon === 'function') {
|
||||
icon = icon(shortcut, i);
|
||||
}
|
||||
return (
|
||||
<li key={key}>
|
||||
<Icon icon={icon} />
|
||||
<span class="shortcut-text">
|
||||
<AsyncText>{title}</AsyncText>
|
||||
{subtitle && (
|
||||
<>
|
||||
{' '}
|
||||
<small class="ib insignificant">{subtitle}</small>
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
<span class="shortcut-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="plain small"
|
||||
disabled={i === 0}
|
||||
onClick={() => {
|
||||
const shortcutsArr = Array.from(states.shortcuts);
|
||||
if (i > 0) {
|
||||
const temp = states.shortcuts[i - 1];
|
||||
shortcutsArr[i - 1] = shortcut;
|
||||
shortcutsArr[i] = temp;
|
||||
states.shortcuts = shortcutsArr;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon icon="arrow-up" alt="Move up" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="plain small"
|
||||
disabled={i === shortcuts.length - 1}
|
||||
onClick={() => {
|
||||
const shortcutsArr = Array.from(states.shortcuts);
|
||||
if (i < states.shortcuts.length - 1) {
|
||||
const temp = states.shortcuts[i + 1];
|
||||
shortcutsArr[i + 1] = shortcut;
|
||||
shortcutsArr[i] = temp;
|
||||
states.shortcuts = shortcutsArr;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon icon="arrow-down" alt="Move down" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="plain small"
|
||||
onClick={() => {
|
||||
setShowForm({
|
||||
shortcut,
|
||||
shortcutIndex: i,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Icon icon="pencil" alt="Edit" />
|
||||
</button>
|
||||
{/* <button
|
||||
<>
|
||||
<ol class="shortcuts-list" ref={shortcutsListParent}>
|
||||
{shortcuts.filter(Boolean).map((shortcut, i) => {
|
||||
// const key = i + Object.values(shortcut);
|
||||
const key = Object.values(shortcut).join('-');
|
||||
const { type } = shortcut;
|
||||
if (!SHORTCUTS_META[type]) return null;
|
||||
let { icon, title, subtitle, excludeViewMode } =
|
||||
SHORTCUTS_META[type];
|
||||
if (typeof title === 'function') {
|
||||
title = title(shortcut, i);
|
||||
}
|
||||
if (typeof subtitle === 'function') {
|
||||
subtitle = subtitle(shortcut, i);
|
||||
}
|
||||
if (typeof icon === 'function') {
|
||||
icon = icon(shortcut, i);
|
||||
}
|
||||
if (typeof excludeViewMode === 'function') {
|
||||
excludeViewMode = excludeViewMode(shortcut, i);
|
||||
}
|
||||
const excludedViewMode = excludeViewMode?.includes(
|
||||
snapStates.settings.shortcutsViewMode,
|
||||
);
|
||||
return (
|
||||
<li key={key}>
|
||||
<Icon icon={icon} />
|
||||
<span class="shortcut-text">
|
||||
<AsyncText>{title}</AsyncText>
|
||||
{subtitle && (
|
||||
<>
|
||||
{' '}
|
||||
<small class="ib insignificant">{subtitle}</small>
|
||||
</>
|
||||
)}
|
||||
{excludedViewMode && (
|
||||
<span class="tag">
|
||||
Not available in current view mode
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span class="shortcut-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="plain small"
|
||||
disabled={i === 0}
|
||||
onClick={() => {
|
||||
const shortcutsArr = Array.from(states.shortcuts);
|
||||
if (i > 0) {
|
||||
const temp = states.shortcuts[i - 1];
|
||||
shortcutsArr[i - 1] = shortcut;
|
||||
shortcutsArr[i] = temp;
|
||||
states.shortcuts = shortcutsArr;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon icon="arrow-up" alt="Move up" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="plain small"
|
||||
disabled={i === shortcuts.length - 1}
|
||||
onClick={() => {
|
||||
const shortcutsArr = Array.from(states.shortcuts);
|
||||
if (i < states.shortcuts.length - 1) {
|
||||
const temp = states.shortcuts[i + 1];
|
||||
shortcutsArr[i + 1] = shortcut;
|
||||
shortcutsArr[i] = temp;
|
||||
states.shortcuts = shortcutsArr;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon icon="arrow-down" alt="Move down" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="plain small"
|
||||
onClick={() => {
|
||||
setShowForm({
|
||||
shortcut,
|
||||
shortcutIndex: i,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Icon icon="pencil" alt="Edit" />
|
||||
</button>
|
||||
{/* <button
|
||||
type="button"
|
||||
class="plain small"
|
||||
onClick={() => {
|
||||
|
@ -408,14 +375,28 @@ function ShortcutsSettings({ onClose }) {
|
|||
>
|
||||
<Icon icon="x" alt="Remove" />
|
||||
</button> */}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
{shortcuts.length === 1 &&
|
||||
snapStates.settings.shortcutsViewMode !== 'float-button' && (
|
||||
<div class="ui-state insignificant">
|
||||
<Icon icon="info" />{' '}
|
||||
<small>
|
||||
Add more than one shortcut/column to make this work.
|
||||
</small>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<div class="ui-state insignificant">
|
||||
<p>No shortcuts yet. Tap on the Add shortcut button.</p>
|
||||
<p>
|
||||
{snapStates.settings.shortcutsViewMode === 'multi-column'
|
||||
? 'No columns yet. Tap on the Add column button.'
|
||||
: 'No shortcuts yet. Tap on the Add shortcut button.'}
|
||||
</p>
|
||||
<p>
|
||||
Not sure what to add?
|
||||
<br />
|
||||
|
@ -442,7 +423,9 @@ function ShortcutsSettings({ onClose }) {
|
|||
)}
|
||||
<p class="insignificant">
|
||||
{shortcuts.length >= SHORTCUTS_LIMIT &&
|
||||
`Max ${SHORTCUTS_LIMIT} shortcuts`}
|
||||
(snapStates.settings.shortcutsViewMode === 'multi-column'
|
||||
? `Max ${SHORTCUTS_LIMIT} columns`
|
||||
: `Max ${SHORTCUTS_LIMIT} shortcuts`)}
|
||||
</p>
|
||||
<p
|
||||
style={{
|
||||
|
@ -463,13 +446,17 @@ function ShortcutsSettings({ onClose }) {
|
|||
disabled={shortcuts.length >= SHORTCUTS_LIMIT}
|
||||
onClick={() => setShowForm(true)}
|
||||
>
|
||||
<Icon icon="plus" /> <span>Add shortcut</span>
|
||||
<Icon icon="plus" />{' '}
|
||||
<span>
|
||||
{snapStates.settings.shortcutsViewMode === 'multi-column'
|
||||
? 'Add column…'
|
||||
: 'Add shortcut…'}
|
||||
</span>
|
||||
</button>
|
||||
</p>
|
||||
</main>
|
||||
{showForm && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
setShowForm(false);
|
||||
|
@ -479,8 +466,6 @@ function ShortcutsSettings({ onClose }) {
|
|||
<ShortcutForm
|
||||
shortcut={showForm.shortcut}
|
||||
shortcutIndex={showForm.shortcutIndex}
|
||||
lists={lists}
|
||||
followedHashtags={followedHashtags}
|
||||
onSubmit={({ result, mode }) => {
|
||||
console.log('onSubmit', result);
|
||||
if (mode === 'edit') {
|
||||
|
@ -495,7 +480,6 @@ function ShortcutsSettings({ onClose }) {
|
|||
)}
|
||||
{showImportExport && (
|
||||
<Modal
|
||||
class="light"
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
setShowImportExport(false);
|
||||
|
@ -512,9 +496,13 @@ function ShortcutsSettings({ onClose }) {
|
|||
);
|
||||
}
|
||||
|
||||
const FORM_NOTES = {
|
||||
list: `Specific list is optional. For multi-column mode, list is required, else the column will not be shown.`,
|
||||
search: `For multi-column mode, search term is required, else the column will not be shown.`,
|
||||
hashtag: 'Multiple hashtags are supported. Space-separated.',
|
||||
};
|
||||
|
||||
function ShortcutForm({
|
||||
lists,
|
||||
followedHashtags,
|
||||
onSubmit,
|
||||
disabled,
|
||||
shortcut,
|
||||
|
@ -524,6 +512,35 @@ function ShortcutForm({
|
|||
console.log('shortcut', shortcut);
|
||||
const editMode = !!shortcut;
|
||||
const [currentType, setCurrentType] = useState(shortcut?.type || null);
|
||||
const { masto } = api();
|
||||
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [lists, setLists] = useState([]);
|
||||
const [followedHashtags, setFollowedHashtags] = useState([]);
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (currentType !== 'list') return;
|
||||
try {
|
||||
setUIState('loading');
|
||||
const lists = await getLists();
|
||||
setLists(lists);
|
||||
setUIState('default');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setUIState('error');
|
||||
}
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
if (currentType !== 'hashtag') return;
|
||||
try {
|
||||
const tags = await fetchFollowedTags();
|
||||
setFollowedHashtags(tags);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
})();
|
||||
}, [currentType]);
|
||||
|
||||
const formRef = useRef();
|
||||
useEffect(() => {
|
||||
|
@ -613,8 +630,10 @@ function ShortcutForm({
|
|||
<select
|
||||
name="id"
|
||||
required={!notRequired}
|
||||
disabled={disabled}
|
||||
disabled={disabled || uiState === 'loading'}
|
||||
defaultValue={editMode ? shortcut.id : undefined}
|
||||
>
|
||||
<option value=""></option>
|
||||
{lists.map((list) => (
|
||||
<option value={list.id}>{list.title}</option>
|
||||
))}
|
||||
|
@ -630,6 +649,7 @@ function ShortcutForm({
|
|||
<span>{text}</span>{' '}
|
||||
<input
|
||||
type={type}
|
||||
switch={type === 'checkbox' || undefined}
|
||||
name={name}
|
||||
placeholder={placeholder}
|
||||
required={type === 'text' && !notRequired}
|
||||
|
@ -641,7 +661,7 @@ function ShortcutForm({
|
|||
}
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck={false}
|
||||
spellCheck={false}
|
||||
pattern={pattern}
|
||||
/>
|
||||
{currentType === 'hashtag' &&
|
||||
|
@ -657,8 +677,18 @@ function ShortcutForm({
|
|||
);
|
||||
},
|
||||
)}
|
||||
{!!FORM_NOTES[currentType] && (
|
||||
<p class="form-note insignificant">
|
||||
<Icon icon="info" />
|
||||
{FORM_NOTES[currentType]}
|
||||
</p>
|
||||
)}
|
||||
<footer>
|
||||
<button type="submit" class="block" disabled={disabled}>
|
||||
<button
|
||||
type="submit"
|
||||
class="block"
|
||||
disabled={disabled || uiState === 'loading'}
|
||||
>
|
||||
{editMode ? 'Save' : 'Add'}
|
||||
</button>
|
||||
{editMode && (
|
||||
|
@ -681,6 +711,7 @@ function ShortcutForm({
|
|||
}
|
||||
|
||||
function ImportExport({ shortcuts, onClose }) {
|
||||
const { masto } = api();
|
||||
const shortcutsStr = useMemo(() => {
|
||||
if (!shortcuts) return '';
|
||||
if (!shortcuts.filter(Boolean).length) return '';
|
||||
|
@ -719,6 +750,8 @@ function ImportExport({ shortcuts, onClose }) {
|
|||
}, [importShortcutStr]);
|
||||
const hasCurrentSettings = states.shortcuts.length > 0;
|
||||
|
||||
const shortcutsImportFieldRef = useRef();
|
||||
|
||||
return (
|
||||
<div id="import-export-container" class="sheet">
|
||||
{!!onClose && (
|
||||
|
@ -737,8 +770,9 @@ function ImportExport({ shortcuts, onClose }) {
|
|||
<Icon icon="arrow-down-circle" size="l" class="insignificant" />{' '}
|
||||
<span>Import</span>
|
||||
</h3>
|
||||
<p>
|
||||
<p class="field-button">
|
||||
<input
|
||||
ref={shortcutsImportFieldRef}
|
||||
type="text"
|
||||
name="import"
|
||||
placeholder="Paste shortcuts here"
|
||||
|
@ -747,6 +781,53 @@ function ImportExport({ shortcuts, onClose }) {
|
|||
setImportShortcutStr(e.target.value);
|
||||
}}
|
||||
/>
|
||||
{states.settings.shortcutSettingsCloudImportExport && (
|
||||
<button
|
||||
type="button"
|
||||
class="plain2 small"
|
||||
disabled={importUIState === 'cloud-downloading'}
|
||||
onClick={async () => {
|
||||
setImportUIState('cloud-downloading');
|
||||
const currentAccount = getCurrentAccountID();
|
||||
showToast(
|
||||
'Downloading saved shortcuts from instance server…',
|
||||
);
|
||||
try {
|
||||
const relationships =
|
||||
await masto.v1.accounts.relationships.fetch({
|
||||
id: [currentAccount],
|
||||
});
|
||||
const relationship = relationships[0];
|
||||
if (relationship) {
|
||||
const { note = '' } = relationship;
|
||||
if (
|
||||
/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/.test(
|
||||
note,
|
||||
)
|
||||
) {
|
||||
const settings = note.match(
|
||||
/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/,
|
||||
)[1];
|
||||
const { v, dt, data } = JSON.parse(settings);
|
||||
shortcutsImportFieldRef.current.value = data;
|
||||
shortcutsImportFieldRef.current.dispatchEvent(
|
||||
new Event('input'),
|
||||
);
|
||||
}
|
||||
}
|
||||
setImportUIState('default');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setImportUIState('error');
|
||||
showToast('Unable to download shortcuts');
|
||||
}
|
||||
}}
|
||||
title="Download shortcuts from instance server"
|
||||
>
|
||||
<Icon icon="cloud" />
|
||||
<Icon icon="arrow-down" />
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
{!!parsedImportShortcutStr &&
|
||||
Array.isArray(parsedImportShortcutStr) && (
|
||||
|
@ -956,8 +1037,64 @@ function ImportExport({ shortcuts, onClose }) {
|
|||
<Icon icon="share" /> <span>Share</span>
|
||||
</button>
|
||||
)}{' '}
|
||||
{states.settings.shortcutSettingsCloudImportExport && (
|
||||
<button
|
||||
type="button"
|
||||
class="plain2"
|
||||
disabled={importUIState === 'cloud-uploading'}
|
||||
onClick={async () => {
|
||||
setImportUIState('cloud-uploading');
|
||||
const currentAccount = getCurrentAccountID();
|
||||
try {
|
||||
const relationships =
|
||||
await masto.v1.accounts.relationships.fetch({
|
||||
id: [currentAccount],
|
||||
});
|
||||
const relationship = relationships[0];
|
||||
if (relationship) {
|
||||
const { note = '' } = relationship;
|
||||
// const newNote = `${note}\n\n\n$<phanpy-shortcuts-settings>{shortcutsStr}</phanpy-shortcuts-settings>`;
|
||||
let newNote = '';
|
||||
if (
|
||||
/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/.test(
|
||||
note,
|
||||
)
|
||||
) {
|
||||
const settingsJSON = JSON.stringify({
|
||||
v: '1', // version
|
||||
dt: Date.now(), // datetime stamp
|
||||
data: shortcutsStr, // shortcuts settings string
|
||||
});
|
||||
newNote = note.replace(
|
||||
/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/,
|
||||
`<phanpy-shortcuts-settings>${settingsJSON}</phanpy-shortcuts-settings>`,
|
||||
);
|
||||
} else {
|
||||
newNote = `${note}\n\n\n<phanpy-shortcuts-settings>${settingsJSON}</phanpy-shortcuts-settings>`;
|
||||
}
|
||||
showToast('Saving shortcuts to instance server…');
|
||||
await masto.v1.accounts
|
||||
.$select(currentAccount)
|
||||
.note.create({
|
||||
comment: newNote,
|
||||
});
|
||||
setImportUIState('default');
|
||||
showToast('Shortcuts saved');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setImportUIState('error');
|
||||
showToast('Unable to save shortcuts');
|
||||
}
|
||||
}}
|
||||
title="Sync to instance server"
|
||||
>
|
||||
<Icon icon="cloud" />
|
||||
<Icon icon="arrow-up" />
|
||||
</button>
|
||||
)}{' '}
|
||||
{shortcutsStr.length > 0 && (
|
||||
<small class="insignificant">
|
||||
<small class="insignificant ib">
|
||||
{shortcutsStr.length} characters
|
||||
</small>
|
||||
)}
|
||||
|
@ -973,6 +1110,14 @@ function ImportExport({ shortcuts, onClose }) {
|
|||
</details>
|
||||
)}
|
||||
</section>
|
||||
{states.settings.shortcutSettingsCloudImportExport && (
|
||||
<footer>
|
||||
<p>
|
||||
<Icon icon="cloud" /> Import/export settings from/to instance
|
||||
server (Very experimental)
|
||||
</p>
|
||||
</footer>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -59,8 +59,9 @@
|
|||
left: 0;
|
||||
right: 0;
|
||||
z-index: 100;
|
||||
background-color: var(--bg-blur-color);
|
||||
backdrop-filter: blur(16px) saturate(3);
|
||||
background-color: var(--bg-color);
|
||||
/* background-color: var(--bg-blur-color);
|
||||
backdrop-filter: blur(16px) saturate(3); */
|
||||
border-top: var(--hairline-width) solid var(--outline-color);
|
||||
box-shadow: 0 -8px 16px -8px var(--drop-shadow-color);
|
||||
overflow: auto;
|
||||
|
@ -99,8 +100,10 @@
|
|||
text-shadow: 0 var(--hairline-width) var(--bg-color);
|
||||
width: 100%;
|
||||
|
||||
&:is(:hover, :focus) {
|
||||
color: var(--text-color);
|
||||
@media (hover: hover) {
|
||||
&:is(:hover, :focus) {
|
||||
color: var(--text-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
#shortcuts .tab-bar li a:active {
|
||||
|
@ -150,7 +153,7 @@ shortcuts .tab-bar[hidden] {
|
|||
}
|
||||
}
|
||||
|
||||
@media (min-width: 40em) {
|
||||
@media (min-width: 40em) and (hover: hover) {
|
||||
#app[data-shortcuts-view-mode='tab-menu-bar'] .timeline-deck {
|
||||
margin-top: 44px;
|
||||
}
|
||||
|
@ -163,6 +166,7 @@ shortcuts .tab-bar[hidden] {
|
|||
padding: env(safe-area-inset-top) env(safe-area-inset-right) 0
|
||||
env(safe-area-inset-left);
|
||||
background-color: var(--bg-faded-blur-color);
|
||||
backdrop-filter: blur(16px);
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
border-bottom: var(--hairline-width) solid var(--bg-faded-color);
|
||||
|
|
|
@ -1,72 +1,83 @@
|
|||
import './shortcuts.css';
|
||||
|
||||
import { Menu, MenuItem } from '@szhsin/react-menu';
|
||||
import { useMemo, useRef } from 'preact/hooks';
|
||||
import { MenuDivider } from '@szhsin/react-menu';
|
||||
import { memo } from 'preact/compat';
|
||||
import { useRef, useState } from 'preact/hooks';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
import { SHORTCUTS_META } from '../components/shortcuts-settings';
|
||||
import { api } from '../utils/api';
|
||||
import { getLists } from '../utils/lists';
|
||||
import states from '../utils/states';
|
||||
|
||||
import AsyncText from './AsyncText';
|
||||
import Icon from './icon';
|
||||
import Link from './link';
|
||||
import Menu2 from './menu2';
|
||||
import MenuLink from './menu-link';
|
||||
import SubMenu2 from './submenu2';
|
||||
|
||||
function Shortcuts() {
|
||||
const { instance } = api();
|
||||
const snapStates = useSnapshot(states);
|
||||
const { shortcuts } = snapStates;
|
||||
const { shortcuts, settings } = snapStates;
|
||||
|
||||
if (!shortcuts.length) {
|
||||
return null;
|
||||
}
|
||||
if (
|
||||
settings.shortcutsViewMode === 'multi-column' ||
|
||||
(!settings.shortcutsViewMode && settings.shortcutsColumnsMode)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const menuRef = useRef();
|
||||
|
||||
const formattedShortcuts = useMemo(
|
||||
() =>
|
||||
shortcuts
|
||||
.map((pin, i) => {
|
||||
const { type, ...data } = pin;
|
||||
if (!SHORTCUTS_META[type]) return null;
|
||||
let { id, path, title, subtitle, icon } = SHORTCUTS_META[type];
|
||||
const hasLists = useRef(false);
|
||||
const formattedShortcuts = shortcuts
|
||||
.map((pin, i) => {
|
||||
const { type, ...data } = pin;
|
||||
if (!SHORTCUTS_META[type]) return null;
|
||||
let { id, path, title, subtitle, icon } = SHORTCUTS_META[type];
|
||||
|
||||
if (typeof id === 'function') {
|
||||
id = id(data, i);
|
||||
}
|
||||
if (typeof path === 'function') {
|
||||
path = path(
|
||||
{
|
||||
...data,
|
||||
instance: data.instance || instance,
|
||||
},
|
||||
i,
|
||||
);
|
||||
}
|
||||
if (typeof title === 'function') {
|
||||
title = title(data, i);
|
||||
}
|
||||
if (typeof subtitle === 'function') {
|
||||
subtitle = subtitle(data, i);
|
||||
}
|
||||
if (typeof icon === 'function') {
|
||||
icon = icon(data, i);
|
||||
}
|
||||
if (typeof id === 'function') {
|
||||
id = id(data, i);
|
||||
}
|
||||
if (typeof path === 'function') {
|
||||
path = path(
|
||||
{
|
||||
...data,
|
||||
instance: data.instance || instance,
|
||||
},
|
||||
i,
|
||||
);
|
||||
}
|
||||
if (typeof title === 'function') {
|
||||
title = title(data, i);
|
||||
}
|
||||
if (typeof subtitle === 'function') {
|
||||
subtitle = subtitle(data, i);
|
||||
}
|
||||
if (typeof icon === 'function') {
|
||||
icon = icon(data, i);
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
path,
|
||||
title,
|
||||
subtitle,
|
||||
icon,
|
||||
};
|
||||
})
|
||||
.filter(Boolean),
|
||||
[shortcuts],
|
||||
);
|
||||
if (id === 'lists') {
|
||||
hasLists.current = true;
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
path,
|
||||
title,
|
||||
subtitle,
|
||||
icon,
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
const navigate = useNavigate();
|
||||
useHotkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9'], (e, handler) => {
|
||||
|
@ -80,15 +91,23 @@ function Shortcuts() {
|
|||
}
|
||||
});
|
||||
|
||||
const [lists, setLists] = useState([]);
|
||||
|
||||
return (
|
||||
<div id="shortcuts">
|
||||
{snapStates.settings.shortcutsViewMode === 'tab-menu-bar' ? (
|
||||
<nav class="tab-bar">
|
||||
<nav
|
||||
class="tab-bar"
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
states.showShortcutsSettings = true;
|
||||
}}
|
||||
>
|
||||
<ul>
|
||||
{formattedShortcuts.map(
|
||||
({ id, path, title, subtitle, icon }, i) => {
|
||||
return (
|
||||
<li key={i + title}>
|
||||
<li key={`${i}-${id}-${title}-${subtitle}-${path}`}>
|
||||
<Link
|
||||
class={subtitle ? 'has-subtitle' : ''}
|
||||
to={path}
|
||||
|
@ -126,19 +145,27 @@ function Shortcuts() {
|
|||
</ul>
|
||||
</nav>
|
||||
) : (
|
||||
<Menu
|
||||
<Menu2
|
||||
instanceRef={menuRef}
|
||||
overflow="auto"
|
||||
viewScroll="close"
|
||||
boundingBoxPadding="8 8 8 8"
|
||||
menuClassName="glass-menu shortcuts-menu"
|
||||
gap={8}
|
||||
position="anchor"
|
||||
onMenuChange={(e) => {
|
||||
if (e.open && hasLists.current) {
|
||||
getLists().then(setLists);
|
||||
}
|
||||
}}
|
||||
menuButton={
|
||||
<button
|
||||
type="button"
|
||||
id="shortcuts-button"
|
||||
class="plain"
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
states.showShortcutsSettings = true;
|
||||
}}
|
||||
onTransitionStart={(e) => {
|
||||
// Close menu if the button disappears
|
||||
try {
|
||||
|
@ -153,9 +180,42 @@ function Shortcuts() {
|
|||
</button>
|
||||
}
|
||||
>
|
||||
{formattedShortcuts.map(({ path, title, subtitle, icon }, i) => {
|
||||
{formattedShortcuts.map(({ id, path, title, subtitle, icon }, i) => {
|
||||
if (id === 'lists') {
|
||||
return (
|
||||
<SubMenu2
|
||||
menuClassName="glass-menu"
|
||||
overflow="auto"
|
||||
gap={-8}
|
||||
label={
|
||||
<>
|
||||
<Icon icon={icon} size="l" />
|
||||
<span class="menu-grow">
|
||||
<AsyncText>{title}</AsyncText>
|
||||
</span>
|
||||
<Icon icon="chevron-right" />
|
||||
</>
|
||||
}
|
||||
>
|
||||
<MenuLink to="/l">
|
||||
<span>All Lists</span>
|
||||
</MenuLink>
|
||||
<MenuDivider />
|
||||
{lists?.map((list) => (
|
||||
<MenuLink key={list.id} to={`/l/${list.id}`}>
|
||||
<span>{list.title}</span>
|
||||
</MenuLink>
|
||||
))}
|
||||
</SubMenu2>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuLink to={path} key={i + title} class="glass-menu-item">
|
||||
<MenuLink
|
||||
to={path}
|
||||
key={`${i}-${id}-${title}-${subtitle}-${path}`}
|
||||
class="glass-menu-item"
|
||||
>
|
||||
<Icon icon={icon} size="l" />{' '}
|
||||
<span class="menu-grow">
|
||||
<span>
|
||||
|
@ -174,10 +234,10 @@ function Shortcuts() {
|
|||
</MenuLink>
|
||||
);
|
||||
})}
|
||||
</Menu>
|
||||
</Menu2>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Shortcuts;
|
||||
export default memo(Shortcuts);
|
||||
|
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,25 @@
|
|||
import { SubMenu } from '@szhsin/react-menu';
|
||||
import { useRef } from 'preact/hooks';
|
||||
|
||||
export default function SubMenu2(props) {
|
||||
const menuRef = useRef();
|
||||
return (
|
||||
<SubMenu
|
||||
{...props}
|
||||
instanceRef={menuRef}
|
||||
// Test fix for bug; submenus not opening on Android
|
||||
itemProps={{
|
||||
onPointerMove: (e) => {
|
||||
if (e.pointerType === 'touch') {
|
||||
menuRef.current?.openMenu?.();
|
||||
}
|
||||
},
|
||||
onPointerLeave: (e) => {
|
||||
if (e.pointerType === 'touch') {
|
||||
menuRef.current?.openMenu?.();
|
||||
}
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
Plik diff jest za duży
Load Diff
|
@ -83,6 +83,7 @@
|
|||
.status-translation-block .translated-block output {
|
||||
display: block;
|
||||
margin-top: 0.75em;
|
||||
text-wrap: pretty;
|
||||
}
|
||||
.status-translation-block
|
||||
.translated-block
|
||||
|
|
|
@ -7,25 +7,25 @@ import { useEffect, useRef, useState } from 'preact/hooks';
|
|||
import sourceLanguages from '../data/lingva-source-languages';
|
||||
import getTranslateTargetLanguage from '../utils/get-translate-target-language';
|
||||
import localeCode2Text from '../utils/localeCode2Text';
|
||||
import pmem from '../utils/pmem';
|
||||
|
||||
import Icon from './icon';
|
||||
import LazyShazam from './lazy-shazam';
|
||||
import Loader from './loader';
|
||||
|
||||
const { PHANPY_LINGVA_INSTANCES } = import.meta.env;
|
||||
const LINGVA_INSTANCES = PHANPY_LINGVA_INSTANCES
|
||||
? PHANPY_LINGVA_INSTANCES.split(/\s+/)
|
||||
: [];
|
||||
|
||||
const throttle = pThrottle({
|
||||
limit: 1,
|
||||
interval: 2000,
|
||||
});
|
||||
|
||||
// Using other API instances instead of lingva.ml because of this bug (slashes don't work):
|
||||
// https://github.com/thedaviddelta/lingva-translate/issues/68
|
||||
const LINGVA_INSTANCES = [
|
||||
'lingva.garudalinux.org',
|
||||
'lingva.lunar.icu',
|
||||
'translate.plausibility.cloud',
|
||||
];
|
||||
let currentLingvaInstance = 0;
|
||||
|
||||
function lingvaTranslate(text, source, target) {
|
||||
function _lingvaTranslate(text, source, target) {
|
||||
console.log('TRANSLATE', text, source, target);
|
||||
const fetchCall = () => {
|
||||
let instance = LINGVA_INSTANCES[currentLingvaInstance];
|
||||
|
@ -34,7 +34,10 @@ function lingvaTranslate(text, source, target) {
|
|||
text,
|
||||
)}`,
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error(res.statusText);
|
||||
return res.json();
|
||||
})
|
||||
.then((res) => {
|
||||
return {
|
||||
provider: 'lingva',
|
||||
|
@ -55,11 +58,18 @@ function lingvaTranslate(text, source, target) {
|
|||
);
|
||||
},
|
||||
});
|
||||
// return masto.v1.statuses.translate(id, {
|
||||
// return masto.v1.statuses.$select(id).translate({
|
||||
// lang: DEFAULT_LANG,
|
||||
// });
|
||||
}
|
||||
const throttledLingvaTranslate = throttle(lingvaTranslate);
|
||||
const TRANSLATED_MAX_AGE = 1000 * 60 * 60; // 1 hour
|
||||
const lingvaTranslate = pmem(_lingvaTranslate, {
|
||||
maxAge: TRANSLATED_MAX_AGE,
|
||||
});
|
||||
const throttledLingvaTranslate = pmem(throttle(lingvaTranslate), {
|
||||
// I know, this is double-layered memoization
|
||||
maxAge: TRANSLATED_MAX_AGE,
|
||||
});
|
||||
|
||||
function TranslationBlock({
|
||||
forceTranslate,
|
||||
|
@ -67,6 +77,7 @@ function TranslationBlock({
|
|||
onTranslate,
|
||||
text = '',
|
||||
mini,
|
||||
autoDetected,
|
||||
}) {
|
||||
const targetLang = getTranslateTargetLanguage(true);
|
||||
const [uiState, setUIState] = useState('default');
|
||||
|
@ -133,23 +144,21 @@ function TranslationBlock({
|
|||
detectedLang !== targetLangText
|
||||
) {
|
||||
return (
|
||||
<div class="shazam-container">
|
||||
<div class="shazam-container-inner">
|
||||
<div class="status-translation-block-mini">
|
||||
<Icon
|
||||
icon="translate"
|
||||
alt={`Auto-translated from ${sourceLangText}`}
|
||||
/>
|
||||
<output
|
||||
lang={targetLang}
|
||||
dir="auto"
|
||||
title={pronunciationContent || ''}
|
||||
>
|
||||
{translatedContent}
|
||||
</output>
|
||||
</div>
|
||||
<LazyShazam>
|
||||
<div class="status-translation-block-mini">
|
||||
<Icon
|
||||
icon="translate"
|
||||
alt={`Auto-translated from ${sourceLangText}`}
|
||||
/>
|
||||
<output
|
||||
lang={targetLang}
|
||||
dir="auto"
|
||||
title={pronunciationContent || ''}
|
||||
>
|
||||
{translatedContent}
|
||||
</output>
|
||||
</div>
|
||||
</div>
|
||||
</LazyShazam>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
@ -179,7 +188,9 @@ function TranslationBlock({
|
|||
{uiState === 'loading'
|
||||
? 'Translating…'
|
||||
: sourceLanguage && sourceLangText && !detectedLang
|
||||
? `Translate from ${sourceLangText}`
|
||||
? autoDetected
|
||||
? `Translate from ${sourceLangText} (auto-detected)`
|
||||
: `Translate from ${sourceLangText}`
|
||||
: `Translate`}
|
||||
</span>
|
||||
</button>
|
||||
|
@ -231,4 +242,4 @@ function TranslationBlock({
|
|||
);
|
||||
}
|
||||
|
||||
export default TranslationBlock;
|
||||
export default LINGVA_INSTANCES?.length ? TranslationBlock : () => null;
|
||||
|
|
|
@ -5,7 +5,8 @@ import './app.css';
|
|||
import { render } from 'preact';
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
|
||||
import Compose from './components/compose';
|
||||
import ComposeSuspense from './components/compose-suspense';
|
||||
import { initStates } from './utils/states';
|
||||
import useTitle from './utils/useTitle';
|
||||
|
||||
if (window.opener) {
|
||||
|
@ -27,6 +28,10 @@ function App() {
|
|||
: 'Compose',
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
initStates();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (uiState === 'closed') {
|
||||
try {
|
||||
|
@ -57,7 +62,7 @@ function App() {
|
|||
console.debug('OPEN COMPOSE');
|
||||
|
||||
return (
|
||||
<Compose
|
||||
<ComposeSuspense
|
||||
editStatus={editStatus}
|
||||
replyToStatus={replyToStatus}
|
||||
draftStatus={draftStatus}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"@mastodon/edit-media-attributes": ">=4.1",
|
||||
"@mastodon/list-exclusive": ">=4.2"
|
||||
"@mastodon/list-exclusive": ">=4.2",
|
||||
"@mastodon/filtered-notifications": "~4.3 || >=4.3",
|
||||
"@mastodon/fetch-multiple-statuses": "~4.3 || >=4.3"
|
||||
}
|
||||
|
|
|
@ -1,670 +1,384 @@
|
|||
[
|
||||
"mastodon.social",
|
||||
"pravda.me",
|
||||
"pawoo.net",
|
||||
"mstdn.jp",
|
||||
"mstdn.social",
|
||||
"mastodon.online",
|
||||
"mastodon.world",
|
||||
"mas.to",
|
||||
"mastodon.world",
|
||||
"infosec.exchange",
|
||||
"fedibird.com",
|
||||
"fosstodon.org",
|
||||
"hachyderm.io",
|
||||
"troet.cafe",
|
||||
"mastodon.uno",
|
||||
"m.cmx.im",
|
||||
"techhub.social",
|
||||
"piaille.fr",
|
||||
"planet.moe",
|
||||
"mastodon.gamedev.place",
|
||||
"mastodonapp.uk",
|
||||
"universeodon.com",
|
||||
"mastodon.uno",
|
||||
"chaos.social",
|
||||
"mastodon.art",
|
||||
"mastodon.nl",
|
||||
"mastodon.cloud",
|
||||
"social.vivaldi.net",
|
||||
"mastodon-japan.net",
|
||||
"mstdn.ca",
|
||||
"thu.closed.social",
|
||||
"universeodon.com",
|
||||
"mastodon.sdf.org",
|
||||
"noagendasocial.com",
|
||||
"kolektiva.social",
|
||||
"alive.bar",
|
||||
"c.im",
|
||||
"o3o.ca",
|
||||
"masto.ai",
|
||||
"tech.lgbt",
|
||||
"mstdn.ca",
|
||||
"kolektiva.social",
|
||||
"mastodon-japan.net",
|
||||
"norden.social",
|
||||
"o3o.ca",
|
||||
"sfba.social",
|
||||
"social.tchncs.de",
|
||||
"meow.social",
|
||||
"wxw.moe",
|
||||
"aus.social",
|
||||
"mastodon.scot",
|
||||
"nrw.social",
|
||||
"tech.lgbt",
|
||||
"mastodon.scot",
|
||||
"mstdn.party",
|
||||
"det.social",
|
||||
"aethy.com",
|
||||
"occm.cc",
|
||||
"newsie.social",
|
||||
"aus.social",
|
||||
"mathstodon.xyz",
|
||||
"toot.community",
|
||||
"ohai.social",
|
||||
"mastodon.top",
|
||||
"mastodon.ie",
|
||||
"mathstodon.xyz",
|
||||
"twingyeo.kr",
|
||||
"mamot.fr",
|
||||
"sueden.social",
|
||||
"dice.camp",
|
||||
"botsin.space",
|
||||
"mastodon.nu",
|
||||
"mastodon.ie",
|
||||
"mastodon.top",
|
||||
"mastodontech.de",
|
||||
"loforo.com",
|
||||
"mindly.social",
|
||||
"ro-mastodon.puyo.jp",
|
||||
"twit.social",
|
||||
"mastodon.nu",
|
||||
"masto.es",
|
||||
"freemasonry.social",
|
||||
"ioc.exchange",
|
||||
"mindly.social",
|
||||
"hessen.social",
|
||||
"defcon.social",
|
||||
"ruhr.social",
|
||||
"mastodon.au",
|
||||
"kind.social",
|
||||
"mastodon.green",
|
||||
"nerdculture.de",
|
||||
"social.cologne",
|
||||
"mastodon.nz",
|
||||
"fediscience.org",
|
||||
"mastouille.fr",
|
||||
"social.anoxinon.de",
|
||||
"muenchen.social",
|
||||
"qoto.org",
|
||||
"framapiaf.org",
|
||||
"akamdon.com",
|
||||
"indieweb.social",
|
||||
"defcon.social",
|
||||
"social.anoxinon.de",
|
||||
"mastodon.green",
|
||||
"mastouille.fr",
|
||||
"social.linux.pizza",
|
||||
"respublicae.eu",
|
||||
"me.dm",
|
||||
"eldritch.cafe",
|
||||
"wandering.shop",
|
||||
"mastodon.com.tr",
|
||||
"g0v.social",
|
||||
"mstdn.science",
|
||||
"sigmoid.social",
|
||||
"ecoevo.social",
|
||||
"ruby.social",
|
||||
"zirk.us",
|
||||
"mastodon.xyz",
|
||||
"mstdn.guru",
|
||||
"social.librem.one",
|
||||
"ravenation.club",
|
||||
"ieji.de",
|
||||
"social.cologne",
|
||||
"indieweb.social",
|
||||
"livellosegreto.it",
|
||||
"mastodont.cat",
|
||||
"cubhub.social",
|
||||
"bildung.social",
|
||||
"noc.social",
|
||||
"kinky.business",
|
||||
"mastodonczech.cz",
|
||||
"kemonodon.club",
|
||||
"toot.wales",
|
||||
"med-mastodon.com",
|
||||
"urbanists.social",
|
||||
"octodon.social",
|
||||
"kmy.blue",
|
||||
"digitalcourage.social",
|
||||
"masto.nu",
|
||||
"mastodontti.fi",
|
||||
"pouet.chapril.org",
|
||||
"ruby.social",
|
||||
"ieji.de",
|
||||
"mastodon.nz",
|
||||
"toot.io",
|
||||
"climatejustice.social",
|
||||
"mastodon.radio",
|
||||
"woof.group",
|
||||
"tkz.one",
|
||||
"mastodont.cat",
|
||||
"social.tchncs.de",
|
||||
"mastodon.com.tr",
|
||||
"noc.social",
|
||||
"sciences.social",
|
||||
"social.dev-wiki.de",
|
||||
"econtwitter.net",
|
||||
"toot.wales",
|
||||
"masto.nu",
|
||||
"phpc.social",
|
||||
"metalhead.club",
|
||||
"yiff.life",
|
||||
"berlin.social",
|
||||
"101010.pl",
|
||||
"mstdn.plus",
|
||||
"mastodon.fun",
|
||||
"rubber.social",
|
||||
"mastodon.iriseden.eu",
|
||||
"mastodon.bida.im",
|
||||
"mastodon.ml",
|
||||
"social.lol",
|
||||
"rollenspiel.social",
|
||||
"mstdn.games",
|
||||
"best-friends.chat",
|
||||
"equestria.social",
|
||||
"wien.rocks",
|
||||
"androiddev.social",
|
||||
"socel.net",
|
||||
"paquita.masto.host",
|
||||
"mastodon.me.uk",
|
||||
"genomic.social",
|
||||
"scholar.social",
|
||||
"snabelen.no",
|
||||
"social.dev-wiki.de",
|
||||
"cyberplace.social",
|
||||
"dresden.network",
|
||||
"swiss.social",
|
||||
"wobbl.xyz",
|
||||
"hostux.social",
|
||||
"ffxiv-mastodon.com",
|
||||
"masto.pt",
|
||||
"shakedown.social",
|
||||
"uri.life",
|
||||
"ursal.zone",
|
||||
"pol.social",
|
||||
"writing.exchange",
|
||||
"typo.social",
|
||||
"wetdry.world",
|
||||
"mast.lat",
|
||||
"todon.eu",
|
||||
"floss.social",
|
||||
"astrodon.social",
|
||||
"tabletop.social",
|
||||
"freiburg.social",
|
||||
"mastodon-belgium.be",
|
||||
"hci.social",
|
||||
"qdon.space",
|
||||
"openbiblio.social",
|
||||
"gulp.cafe",
|
||||
"mastodon.zaclys.com",
|
||||
"tooot.im",
|
||||
"stranger.social",
|
||||
"theblower.au",
|
||||
"furry.engineer",
|
||||
"mstdn.io",
|
||||
"toad.social",
|
||||
"abdl.link",
|
||||
"geekdom.social",
|
||||
"journa.host",
|
||||
"social.treehouse.systems",
|
||||
"hcommons.social",
|
||||
"mastoturk.org",
|
||||
"glasgow.social",
|
||||
"queer.party",
|
||||
"social.coop",
|
||||
"tooting.ch",
|
||||
"peoplemaking.games",
|
||||
"mastodonners.nl",
|
||||
"pawb.fun",
|
||||
"awscommunity.social",
|
||||
"muenster.im",
|
||||
"rivals.space",
|
||||
"union.place",
|
||||
"mastodontti.fi",
|
||||
"climatejustice.social",
|
||||
"urbanists.social",
|
||||
"mstdn.plus",
|
||||
"metalhead.club",
|
||||
"ravenation.club",
|
||||
"mastodon.ml",
|
||||
"fairy.id",
|
||||
"feuerwehr.social",
|
||||
"dresden.network",
|
||||
"stranger.social",
|
||||
"mastodon.iriseden.eu",
|
||||
"rollenspiel.social",
|
||||
"pol.social",
|
||||
"mstdn.business",
|
||||
"mstdn.games",
|
||||
"wien.rocks",
|
||||
"h4.io",
|
||||
"dju.social",
|
||||
"toot.aquilenet.fr",
|
||||
"vis.social",
|
||||
"blorbo.social",
|
||||
"otadon.com",
|
||||
"imastodon.net",
|
||||
"tilde.zone",
|
||||
"vmst.io",
|
||||
"lor.sh",
|
||||
"mstdn.maud.io",
|
||||
"ika.queloud.net",
|
||||
"bonn.social",
|
||||
"nofan.xyz",
|
||||
"socel.net",
|
||||
"mastodon.eus",
|
||||
"wehavecookies.social",
|
||||
"glasgow.social",
|
||||
"mastodon.me.uk",
|
||||
"uri.life",
|
||||
"hostux.social",
|
||||
"theblower.au",
|
||||
"mastodon-uk.net",
|
||||
"masto.pt",
|
||||
"awscommunity.social",
|
||||
"flipboard.social",
|
||||
"mast.lat",
|
||||
"freiburg.social",
|
||||
"snabelen.no",
|
||||
"mastodon.zaclys.com",
|
||||
"muenster.im",
|
||||
"mastodon-belgium.be",
|
||||
"geekdom.social",
|
||||
"hcommons.social",
|
||||
"tooot.im",
|
||||
"tooting.ch",
|
||||
"rheinneckar.social",
|
||||
"toot.cat",
|
||||
"discuss.systems",
|
||||
"types.pl",
|
||||
"vocalodon.net",
|
||||
"4bear.com",
|
||||
"girlcock.club",
|
||||
"sunny.garden",
|
||||
"mapstodon.space",
|
||||
"emacs.ch",
|
||||
"medibubble.org",
|
||||
"famichiki.jp",
|
||||
"blog.famichiki.jp",
|
||||
"bsd.network",
|
||||
"fandom.ink",
|
||||
"cybre.space",
|
||||
"persiansmastodon.com",
|
||||
"ludosphere.fr",
|
||||
"oldbytes.space",
|
||||
"toot.blue",
|
||||
"witches.live",
|
||||
"cupoftea.social",
|
||||
"photog.social",
|
||||
"historians.social",
|
||||
"weirder.earth",
|
||||
"graphics.social",
|
||||
"layer8.space",
|
||||
"mstdn.in.th",
|
||||
"pokemon.mastportal.info",
|
||||
"social.sciences.re",
|
||||
"vt.social",
|
||||
"iosdev.space",
|
||||
"todon.nl",
|
||||
"masto.bike",
|
||||
"gruene.social",
|
||||
"flipboard.social",
|
||||
"bolha.us",
|
||||
"douchi.space",
|
||||
"literatur.social",
|
||||
"freak.university",
|
||||
"jorts.horse",
|
||||
"neuromatch.social",
|
||||
"merveilles.town",
|
||||
"shelter.moe",
|
||||
"retro.pizza",
|
||||
"scicomm.xyz",
|
||||
"mastorol.es",
|
||||
"disabled.social",
|
||||
"trpg-o.xyz",
|
||||
"freeradical.zone",
|
||||
"mastodon.gal",
|
||||
"expressional.social",
|
||||
"h5q.net",
|
||||
"witter.cz",
|
||||
"mastodonbooks.net",
|
||||
"vkl.world",
|
||||
"toad.social",
|
||||
"lor.sh",
|
||||
"peoplemaking.games",
|
||||
"union.place",
|
||||
"bark.lgbt",
|
||||
"bonn.social",
|
||||
"tilde.zone",
|
||||
"vmst.io",
|
||||
"mastodon.berlin",
|
||||
"lile.cl",
|
||||
"chitter.xyz",
|
||||
"mona.do",
|
||||
"mast.dragon-fly.club",
|
||||
"spore.social",
|
||||
"liker.social",
|
||||
"furries.club",
|
||||
"neurodifferent.me",
|
||||
"mastodon.design",
|
||||
"macaw.social",
|
||||
"toot.lv",
|
||||
"linuxrocks.online",
|
||||
"bitbang.social",
|
||||
"mstdn.beer",
|
||||
"lgbtqia.space",
|
||||
"transfur.social",
|
||||
"climatejustice.rocks",
|
||||
"glammr.us",
|
||||
"mastodon.coffee",
|
||||
"vtdon.com",
|
||||
"gaypirates.club",
|
||||
"oslo.town",
|
||||
"mental.social",
|
||||
"post.lurk.org",
|
||||
"eupolicy.social",
|
||||
"parfait.day",
|
||||
"xoxo.zone",
|
||||
"graz.social",
|
||||
"emacs.ch",
|
||||
"blorbo.social",
|
||||
"furry.engineer",
|
||||
"rivals.space",
|
||||
"cupoftea.social",
|
||||
"qdon.space",
|
||||
"graphics.social",
|
||||
"veganism.social",
|
||||
"sciencemastodon.com",
|
||||
"be-lieve.hostdon.ne.jp",
|
||||
"kinkyelephant.com",
|
||||
"twiukraine.com",
|
||||
"ludosphere.fr",
|
||||
"4bear.com",
|
||||
"famichiki.jp",
|
||||
"expressional.social",
|
||||
"convo.casa",
|
||||
"artisan.chat",
|
||||
"pettingzoo.co",
|
||||
"sociale.network",
|
||||
"pkm.social",
|
||||
"masto.nobigtech.es",
|
||||
"urusai.social",
|
||||
"freeatlantis.com",
|
||||
"fairy.id",
|
||||
"blimps.xyz",
|
||||
"mastodon.la",
|
||||
"musician.social",
|
||||
"mustard.blog",
|
||||
"m.otter.homes",
|
||||
"mastodon.cat",
|
||||
"dizl.de",
|
||||
"mastodon.energy",
|
||||
"sself.co",
|
||||
"mastodon.arch-linux.cz",
|
||||
"kirche.social",
|
||||
"toot.cafe",
|
||||
"mastodon.org.uk",
|
||||
"mstdn.mx",
|
||||
"federatedfandom.net",
|
||||
"pnw.zone",
|
||||
"xarxa.cloud",
|
||||
"cr8r.gg",
|
||||
"darmstadt.social",
|
||||
"toot.funami.tech",
|
||||
"awoo.space",
|
||||
"mastodon.uy",
|
||||
"plush.city",
|
||||
"cztwitter.cz",
|
||||
"thecanadian.social",
|
||||
"thicc.horse",
|
||||
"digipres.club",
|
||||
"libretooth.gr",
|
||||
"trpg.cloud",
|
||||
"m.ai6yr.org",
|
||||
"ramen-fsm.eu.org",
|
||||
"jawns.club",
|
||||
"mastodon.in.th",
|
||||
"mao.mastodonhub.com",
|
||||
"romancelandia.club",
|
||||
"historians.social",
|
||||
"mastorol.es",
|
||||
"retro.pizza",
|
||||
"shelter.moe",
|
||||
"mast.dragon-fly.club",
|
||||
"sakurajima.moe",
|
||||
"mastodon.content.town",
|
||||
"esperanto.masto.host",
|
||||
"toot.bike",
|
||||
"mastodon.arch-linux.cz",
|
||||
"squawk.mytransponder.com",
|
||||
"mastodon.gal",
|
||||
"disabled.social",
|
||||
"vkl.world",
|
||||
"eupolicy.social",
|
||||
"fandom.ink",
|
||||
"toot.funami.tech",
|
||||
"mastodonbooks.net",
|
||||
"lgbtqia.space",
|
||||
"witter.cz",
|
||||
"planetearth.social",
|
||||
"oslo.town",
|
||||
"mastodon.com.pl",
|
||||
"pawb.fun",
|
||||
"darmstadt.social",
|
||||
"masto.nobigtech.es",
|
||||
"cr8r.gg",
|
||||
"pnw.zone",
|
||||
"hear-me.social",
|
||||
"furries.club",
|
||||
"gaygeek.social",
|
||||
"birdon.social",
|
||||
"mastodon.energy",
|
||||
"mastodon-swiss.org",
|
||||
"dizl.de",
|
||||
"libretooth.gr",
|
||||
"mustard.blog",
|
||||
"machteburch.social",
|
||||
"fulda.social",
|
||||
"worldkey.io",
|
||||
"nnia.space",
|
||||
"plural.cafe",
|
||||
"federated.press",
|
||||
"ani.work",
|
||||
"better.boston",
|
||||
"vulpine.club",
|
||||
"ichiji.social",
|
||||
"freemasonry.social",
|
||||
"iztasocial.site",
|
||||
"functional.cafe",
|
||||
"warhammer.social",
|
||||
"mastodo.fi",
|
||||
"mstdn.kemono-friends.info",
|
||||
"mastodon.acm.org",
|
||||
"dotnet.social",
|
||||
"mas.town",
|
||||
"liberdon.com",
|
||||
"muri.network",
|
||||
"babka.social",
|
||||
"social.bau-ha.us",
|
||||
"oc.todon.fr",
|
||||
"nafo.uk",
|
||||
"kirakiratter.com",
|
||||
"sleeping.town",
|
||||
"masto.nyc",
|
||||
"mastodon.hams.social",
|
||||
"donphan.social",
|
||||
"en.osm.town",
|
||||
"toot.portes-imaginaire.org",
|
||||
"biplus.date",
|
||||
"podcastindex.social",
|
||||
"mastodon.mim-libre.fr",
|
||||
"data-folks.masto.host",
|
||||
"sukebe.hostdon.ne.jp",
|
||||
"akademienl.social",
|
||||
"gearheads.social",
|
||||
"sauropods.win",
|
||||
"archaeo.social",
|
||||
"bear.community",
|
||||
"swiss-talk.net",
|
||||
"social.seattle.wa.us",
|
||||
"assemblag.es",
|
||||
"toot.kif.rocks",
|
||||
"mograph.social",
|
||||
"icosahedron.website",
|
||||
"kurry.social",
|
||||
"spacey.space",
|
||||
"is.nota.live",
|
||||
"cryptodon.lol",
|
||||
"bbq.snoot.com",
|
||||
"ai.wiki",
|
||||
"photodn.net",
|
||||
"im-in.space",
|
||||
"opalstack.social",
|
||||
"social.kyiv.dcomm.net.ua",
|
||||
"wargamers.social",
|
||||
"hometech.social",
|
||||
"mastodon.mnetwork.co.kr",
|
||||
"mstdn-bike.net",
|
||||
"toot.si",
|
||||
"gensokyo.town",
|
||||
"social.politicaconciencia.org",
|
||||
"tyrol.social",
|
||||
"col.social",
|
||||
"kopiti.am",
|
||||
"norcal.social",
|
||||
"toot.berlin",
|
||||
"bookwor.ms",
|
||||
"mastodon.uy",
|
||||
"xarxa.cloud",
|
||||
"corteximplant.com",
|
||||
"mastodon.london",
|
||||
"urusai.social",
|
||||
"thecanadian.social",
|
||||
"federated.press",
|
||||
"kanoa.de",
|
||||
"mstdn.dk",
|
||||
"h-net.social",
|
||||
"jasette.facil.services",
|
||||
"sunbeam.city",
|
||||
"eightpoint.app",
|
||||
"mstdn.tokyocameraclub.com",
|
||||
"dobbs.town",
|
||||
"est.social",
|
||||
"mastoot.fr",
|
||||
"epicure.social",
|
||||
"artsio.com",
|
||||
"social.edu.nl",
|
||||
"mstdn.id",
|
||||
"mstdn.fr",
|
||||
"mastodon.com.br",
|
||||
"seocommunity.social",
|
||||
"hello.2heng.xin",
|
||||
"arsenalfc.social",
|
||||
"computerfairi.es",
|
||||
"mastodon.hypnoguys.com",
|
||||
"beekeeping.ninja",
|
||||
"mastodon.tetaneutral.net",
|
||||
"kirishima.cloud",
|
||||
"tablegame.mstdn.cloud",
|
||||
"otogamer.me",
|
||||
"eigadon.net",
|
||||
"federate.social",
|
||||
"qubit-social.xyz",
|
||||
"pointless.chat",
|
||||
"mastodon.mit.edu",
|
||||
"tribe.net",
|
||||
"osna.social",
|
||||
"uwu.social",
|
||||
"blacktwitter.io",
|
||||
"toki.social",
|
||||
"gameliberty.club",
|
||||
"colearn.social",
|
||||
"esq.social",
|
||||
"blabber.lu-rp.net",
|
||||
"elekk.xyz",
|
||||
"xn--lofll-1sat.is",
|
||||
"flower.afn.social",
|
||||
"cloud-native.social",
|
||||
"burma.social",
|
||||
"loðfíll.is",
|
||||
"guitar.rodeo",
|
||||
"nederland.online",
|
||||
"mastodon.gougere.fr",
|
||||
"piano.masto.host",
|
||||
"mastodon.education",
|
||||
"moresci.sale",
|
||||
"social.veraciousnetwork.com",
|
||||
"hispagatos.space",
|
||||
"apobangpo.space",
|
||||
"mastodon.juggler.jp",
|
||||
"mastodon.bayern",
|
||||
"dingdash.com",
|
||||
"mastodon.hk",
|
||||
"outdoors.lgbt",
|
||||
"irsoluciones.social",
|
||||
"mastodon.vlaanderen",
|
||||
"9kb.me",
|
||||
"social.datalabour.com",
|
||||
"mastodon.partipirate.org",
|
||||
"oulipo.social",
|
||||
"yakyudon.net",
|
||||
"kfem.cat",
|
||||
"lounge.town",
|
||||
"eletusk.club",
|
||||
"lgbt.io",
|
||||
"lewacki.space",
|
||||
"oransns.com",
|
||||
"mastodon.triggerphra.se",
|
||||
"arvr.social",
|
||||
"digforfire.org",
|
||||
"maly.io",
|
||||
"good.news",
|
||||
"lou.lt",
|
||||
"anticapitalist.party",
|
||||
"mastodon.cc",
|
||||
"gardenstate.social",
|
||||
"mastorock.com",
|
||||
"birds.town",
|
||||
"kpop.social",
|
||||
"social.yesterweb.org",
|
||||
"earthstream.social",
|
||||
"gensokyo.social",
|
||||
"anarchism.space",
|
||||
"acg.mn",
|
||||
"deadinsi.de",
|
||||
"baraag.net",
|
||||
"mastodon.elte.hu",
|
||||
"mastodon.pirateparty.be",
|
||||
"social.chinwag.org",
|
||||
"mstdn.es",
|
||||
"metalverse.social",
|
||||
"mastodon-swiss.org",
|
||||
"mastodon.com.py",
|
||||
"mstdn.osaka",
|
||||
"social.slat.org",
|
||||
"opalstack.social",
|
||||
"bahn.social",
|
||||
"mograph.social",
|
||||
"dmv.community",
|
||||
"social.bau-ha.us",
|
||||
"mastodon.free-solutions.org",
|
||||
"macrofurs.social",
|
||||
"aleph.land",
|
||||
"mastodol.jp",
|
||||
"poweredbygay.social",
|
||||
"toots.social",
|
||||
"gametoots.de",
|
||||
"tenforward.social",
|
||||
"masto.nyc",
|
||||
"tyrol.social",
|
||||
"burma.social",
|
||||
"toot.kif.rocks",
|
||||
"donphan.social",
|
||||
"mast.hpc.social",
|
||||
"musicians.today",
|
||||
"drupal.community",
|
||||
"hometech.social",
|
||||
"norcal.social",
|
||||
"social.politicaconciencia.org",
|
||||
"social.seattle.wa.us",
|
||||
"is.nota.live",
|
||||
"genealysis.social",
|
||||
"wargamers.social",
|
||||
"guitar.rodeo",
|
||||
"bookstodon.com",
|
||||
"mstdn.dk",
|
||||
"elizur.me",
|
||||
"irsoluciones.social",
|
||||
"h-net.social",
|
||||
"mastoot.fr",
|
||||
"qaf.men",
|
||||
"est.social",
|
||||
"kurry.social",
|
||||
"mastodon.pnpde.social",
|
||||
"ani.work",
|
||||
"nederland.online",
|
||||
"epicure.social",
|
||||
"occitania.social",
|
||||
"rcsocial.net",
|
||||
"mastodon.cipherbliss.com",
|
||||
"mastodon.be",
|
||||
"otoya.space",
|
||||
"vocalounge.cafe",
|
||||
"anime.kona.moe",
|
||||
"toot.thoughtworks.com",
|
||||
"toot.pizza",
|
||||
"mastodon.cisti.org",
|
||||
"lgbt.io",
|
||||
"mountains.social",
|
||||
"persiansmastodon.com",
|
||||
"seocommunity.social",
|
||||
"cyberfurz.social",
|
||||
"fedi.at",
|
||||
"gamepad.club",
|
||||
"augsburg.social",
|
||||
"mastodon.education",
|
||||
"toot.re",
|
||||
"linux.social",
|
||||
"neovibe.app",
|
||||
"musician.social",
|
||||
"esq.social",
|
||||
"social.veraciousnetwork.com",
|
||||
"datasci.social",
|
||||
"tooters.org",
|
||||
"ciberlandia.pt",
|
||||
"cloud-native.social",
|
||||
"social.silicon.moe",
|
||||
"cosocial.ca",
|
||||
"arvr.social",
|
||||
"hispagatos.space",
|
||||
"friendsofdesoto.social",
|
||||
"musicworld.social",
|
||||
"aut.social",
|
||||
"masto.yttrx.com",
|
||||
"yttrx.com",
|
||||
"catdon.life",
|
||||
"mastodon.wien",
|
||||
"colorid.es",
|
||||
"arsenalfc.social",
|
||||
"allthingstech.social",
|
||||
"mastodon.vlaanderen",
|
||||
"mastodon.com.py",
|
||||
"tooter.social",
|
||||
"lounge.town",
|
||||
"puntarella.party",
|
||||
"earthstream.social",
|
||||
"apobangpo.space",
|
||||
"opencoaster.net",
|
||||
"frikiverse.zone",
|
||||
"airwaves.social",
|
||||
"toot.garden",
|
||||
"lewacki.space",
|
||||
"gardenstate.social",
|
||||
"theatl.social",
|
||||
"maly.io",
|
||||
"library.love",
|
||||
"kfem.cat",
|
||||
"ruhrpott.social",
|
||||
"techtoots.com",
|
||||
"furry.energy",
|
||||
"mastodon.pirateparty.be",
|
||||
"metalverse.social",
|
||||
"indieauthors.social",
|
||||
"tuiter.rocks",
|
||||
"mastodon.africa",
|
||||
"jvm.social",
|
||||
"poweredbygay.social",
|
||||
"fikaverse.club",
|
||||
"gametoots.de",
|
||||
"mastodon.cr",
|
||||
"hoosier.social",
|
||||
"khiar.net",
|
||||
"seo.chat",
|
||||
"drumstodon.net",
|
||||
"e.fo",
|
||||
"hub.mtf.party",
|
||||
"toot.turbo.chat",
|
||||
"raphus.social",
|
||||
"toots.nu",
|
||||
"k8s.social",
|
||||
"mastodon.holeyfox.co",
|
||||
"social.targaryen.house",
|
||||
"fribygda.no",
|
||||
"x0r.be",
|
||||
"fpl.social",
|
||||
"toot.pizza",
|
||||
"mastodon.cipherbliss.com",
|
||||
"burningboard.net",
|
||||
"synapse.cafe",
|
||||
"cultur.social",
|
||||
"vermont.masto.host",
|
||||
"mastodon.bot",
|
||||
"bologna.one",
|
||||
"pieville.net",
|
||||
"moe.cat",
|
||||
"toot.site",
|
||||
"lilymagic.com",
|
||||
"social.opendesktop.org",
|
||||
"bgme.me",
|
||||
"mastodon.li",
|
||||
"truthsocial.co.in",
|
||||
"mastodon.sg",
|
||||
"tchafia.be",
|
||||
"rail.chat",
|
||||
"mastodon.hosnet.fr",
|
||||
"leipzig.town",
|
||||
"wayne.social",
|
||||
"rheinhessen.social",
|
||||
"rap.social",
|
||||
"cwb.social",
|
||||
"mastodon.bachgau.social",
|
||||
"cville.online",
|
||||
"bzh.social",
|
||||
"mastodon.escepticos.es",
|
||||
"zenzone.social",
|
||||
"mastodon.ee",
|
||||
"lsbt.me",
|
||||
"neurodiversity-in.au",
|
||||
"fairmove.net",
|
||||
"stereodon.social",
|
||||
"mast.moe",
|
||||
"nojack.easydns.ca",
|
||||
"mcr.wtf",
|
||||
"mastodon.frl",
|
||||
"mikumikudance.cloud",
|
||||
"social.coletivos.org",
|
||||
"social.caa-ins.org",
|
||||
"m.rthome.me",
|
||||
"mastodon.oeru.org",
|
||||
"nasface.cz",
|
||||
"ephemeral.glitch.social",
|
||||
"www.mstddntfdn.online",
|
||||
"mastodon.librelabucm.org",
|
||||
"livester.net",
|
||||
"fetswing.org",
|
||||
"mastodon.cosmicanimal.jp",
|
||||
"summoners-riftodon.jp",
|
||||
"dev.brighteon.social",
|
||||
"todon.ploud.fr",
|
||||
"kinbaku.club",
|
||||
"animalliberation.social",
|
||||
"okla.social",
|
||||
"camp.smolnet.org",
|
||||
"ailbhean.co-shaoghal.net",
|
||||
"clj.social",
|
||||
"tu.social",
|
||||
"nomanssky.social",
|
||||
"mastodon.iow.social",
|
||||
"frontrange.co",
|
||||
"episcodon.net",
|
||||
"devianze.city",
|
||||
"paktodon.asia",
|
||||
"travelpandas.fr",
|
||||
"silversword.online",
|
||||
"nwb.social",
|
||||
"skastodon.com",
|
||||
"kcmo.social",
|
||||
"balkan.fedive.rs",
|
||||
"openedtech.social",
|
||||
"mastodon.ph",
|
||||
"enshittification.social",
|
||||
"spojnik.works",
|
||||
"mastodon.conquestuniverse.com",
|
||||
"nutmeg.social",
|
||||
"social.sndevs.com",
|
||||
"social.diva.exchange",
|
||||
"growers.social",
|
||||
"pdx.sh",
|
||||
"nfld.me",
|
||||
"cartersville.social",
|
||||
"voi.social",
|
||||
"mastodon.babb.no",
|
||||
"kzoo.to",
|
||||
"mastodon.vanlife.is",
|
||||
"toot.works",
|
||||
"sanjuans.life",
|
||||
"dariox.club",
|
||||
"xreality.social",
|
||||
"social.ferrocarril.net",
|
||||
"pool.social",
|
||||
"polsci.social",
|
||||
"mastodon.mg",
|
||||
"23.illuminati.org",
|
||||
"apotheke.social",
|
||||
"jaxbeach.social",
|
||||
"onmasto.com",
|
||||
"mastodon.gza.jp",
|
||||
"mastodon.firefly.land",
|
||||
"ostatus.ikeji.ma",
|
||||
"social.outsourcedmath.com",
|
||||
"tkz.one",
|
||||
"med-mammoth.com",
|
||||
"bark.lgbt",
|
||||
"moth.social",
|
||||
"icosahedron.kal-tsit.halcy.de",
|
||||
"id.cc",
|
||||
"crypt.lol",
|
||||
"freespeechextremist.com",
|
||||
"cawfee.club",
|
||||
"1234.as",
|
||||
"fedi.absturztau.be",
|
||||
"fsmi.social",
|
||||
"go5.dev",
|
||||
"poa.st",
|
||||
"patriot.online",
|
||||
"stereophonic.space",
|
||||
"kazv.moe",
|
||||
"seaofog.com",
|
||||
"libranet.de",
|
||||
"tea.codes",
|
||||
"pixelfed.social",
|
||||
"stop.voring.me",
|
||||
"shitposter.club",
|
||||
"squeet.me",
|
||||
"shared.graphics",
|
||||
"devs.live",
|
||||
"pxlmo.com",
|
||||
"pixel.tchncs.de",
|
||||
"pythondevs.social",
|
||||
"love.alicecomplex.com",
|
||||
"mastodon.london",
|
||||
"greenish.red",
|
||||
"pixelfed.sdf.org",
|
||||
"anar.chi.st",
|
||||
"gram.social",
|
||||
"friendica.eskimo.com",
|
||||
"dudu.best",
|
||||
"lolison.top",
|
||||
"fedisnap.com",
|
||||
"pix.diaspodon.fr",
|
||||
"shpposter.club",
|
||||
"pix.toot.wales",
|
||||
"pleroma.noellabo.jp",
|
||||
"fgc.network",
|
||||
"pixey.org",
|
||||
"fe.disroot.org",
|
||||
"pixelfed.tokyo",
|
||||
"mastodon.wien",
|
||||
"448c.net",
|
||||
"miraiverse.xyz",
|
||||
"freeframe.masto.host",
|
||||
"pixelfed.photos",
|
||||
"varishangout.net",
|
||||
"pixelfed.fr",
|
||||
"friendica.vrije-mens.org",
|
||||
"mastodon.tech",
|
||||
"bae.st",
|
||||
"brighteon.social",
|
||||
"pixelfed.nz",
|
||||
"hayu.sh",
|
||||
"pixelfed.uno",
|
||||
"pixelfed.au",
|
||||
"miniwa.moe",
|
||||
"bassam.social",
|
||||
"genserver.social",
|
||||
"spinster.xyz",
|
||||
"pixelfed.de",
|
||||
"metapixl.com",
|
||||
"neenster.org",
|
||||
"venera.social",
|
||||
"outerheaven.club",
|
||||
"gleasonator.com",
|
||||
"pixelfed.fi",
|
||||
"blob.cat",
|
||||
"kids.0px.io",
|
||||
"metu.life",
|
||||
"cybre.club",
|
||||
"snug.moe",
|
||||
"eter9.com",
|
||||
"infosec.town",
|
||||
"lethallava.land",
|
||||
"dvd.chat",
|
||||
"poast.org"
|
||||
"ceilidh.online",
|
||||
"netsphere.one",
|
||||
"biplus.social",
|
||||
"bvb.social",
|
||||
"ms.maritime.social",
|
||||
"darticulate.com",
|
||||
"persia.social",
|
||||
"streamerchat.social",
|
||||
"troet.fediverse.at",
|
||||
"publishing.social",
|
||||
"finsup.social",
|
||||
"kjas.no",
|
||||
"wxw.moe",
|
||||
"learningdisability.social",
|
||||
"mastodon.bida.im",
|
||||
"computerfairi.es",
|
||||
"tea.codes"
|
||||
]
|
|
@ -959,11 +959,6 @@
|
|||
"Kabyle",
|
||||
"Taqbaylit"
|
||||
],
|
||||
[
|
||||
"kmr",
|
||||
"Kurmanji (Kurdish)",
|
||||
"Kurmancî"
|
||||
],
|
||||
[
|
||||
"ldn",
|
||||
"Láadan",
|
||||
|
|
|
@ -16,9 +16,32 @@
|
|||
|
||||
--blue-color: royalblue;
|
||||
--purple-color: blueviolet;
|
||||
--purple-fg-color: color-mix(
|
||||
in srgb-linear,
|
||||
var(--purple-color) 60%,
|
||||
var(--text-color) 40%
|
||||
);
|
||||
--purple-bg-color: color-mix(in srgb, var(--purple-color) 10%, transparent);
|
||||
--green-color: darkgreen;
|
||||
--orange-color: darkorange;
|
||||
--orange-light-bg-color: color-mix(
|
||||
in srgb,
|
||||
var(--orange-color) 20%,
|
||||
transparent
|
||||
);
|
||||
--orange-fg-color: color-mix(
|
||||
in srgb-linear,
|
||||
var(--orange-color) 60%,
|
||||
var(--text-color) 40%
|
||||
);
|
||||
--orange-bg-color: color-mix(in srgb, var(--orange-color) 10%, transparent);
|
||||
--red-color: orangered;
|
||||
--red-text-color: color-mix(
|
||||
in srgb-linear,
|
||||
var(--red-color) 60%,
|
||||
var(--text-color) 40%
|
||||
);
|
||||
--red-bg-color: color-mix(in lch, var(--red-color) 40%, transparent);
|
||||
--bg-color: #fff;
|
||||
--bg-faded-color: #f0f2f5;
|
||||
--bg-blur-color: #fff9;
|
||||
|
@ -26,6 +49,7 @@
|
|||
--text-color: #1c1e21;
|
||||
--text-insignificant-color: #1c1e2199;
|
||||
--link-color: var(--blue-color);
|
||||
--link-bg-color: #4169e122;
|
||||
--link-light-color: #4169e199;
|
||||
--link-faded-color: #4169e155;
|
||||
--link-bg-hover-color: #f0f2f599;
|
||||
|
@ -48,12 +72,23 @@
|
|||
--reply-to-text-color: #b36200;
|
||||
--favourite-color: var(--red-color);
|
||||
--reply-to-faded-color: #ffa60020;
|
||||
--hashtag-color: LightSeaGreen;
|
||||
--hashtag-faded-color: color-mix(
|
||||
in srgb,
|
||||
var(--hashtag-color) 15%,
|
||||
transparent
|
||||
);
|
||||
--hashtag-text-color: color-mix(
|
||||
in lch,
|
||||
var(--hashtag-color) 40%,
|
||||
var(--text-color) 60%
|
||||
);
|
||||
--outline-color: rgba(128, 128, 128, 0.2);
|
||||
--outline-hover-color: rgba(128, 128, 128, 0.7);
|
||||
--divider-color: rgba(0, 0, 0, 0.1);
|
||||
--backdrop-color: rgba(0, 0, 0, 0.05);
|
||||
--backdrop-color: rgba(0, 0, 0, 0.1);
|
||||
--backdrop-darker-color: rgba(0, 0, 0, 0.25);
|
||||
--backdrop-solid-color: #ccc;
|
||||
--backdrop-solid-color: #eee;
|
||||
--img-bg-color: rgba(128, 128, 128, 0.2);
|
||||
--loader-color: #1c1e2199;
|
||||
--comment-line-color: #e5e5e5;
|
||||
|
@ -62,13 +97,19 @@
|
|||
--close-button-bg-active-color: rgba(0, 0, 0, 0.2);
|
||||
--close-button-color: rgba(0, 0, 0, 0.5);
|
||||
--close-button-hover-color: rgba(0, 0, 0, 1);
|
||||
--private-note-text-color: var(--text-color);
|
||||
--private-note-bg-color: color-mix(in srgb, yellow 20%, var(--bg-color));
|
||||
--private-note-border-color: rgba(0, 0, 0, 0.2);
|
||||
|
||||
/* Video colors won't change based on color scheme */
|
||||
/* Media colors won't change based on color scheme */
|
||||
--media-fg-color: #f0f2f5;
|
||||
--media-bg-color: #242526;
|
||||
--media-outline-color: color-mix(in lch, var(--media-fg-color), transparent);
|
||||
|
||||
--timing-function: cubic-bezier(0.3, 0.5, 0, 1);
|
||||
--spring-timing-funtion: cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
|
||||
--min-dimension: 88px;
|
||||
}
|
||||
|
||||
@media (min-resolution: 2dppx) {
|
||||
|
@ -103,7 +144,7 @@
|
|||
--divider-color: rgba(255, 255, 255, 0.1);
|
||||
--bg-blur-color: #24252699;
|
||||
--backdrop-color: rgba(0, 0, 0, 0.5);
|
||||
--backdrop-solid-color: #333;
|
||||
--backdrop-solid-color: #111;
|
||||
--loader-color: #f0f2f599;
|
||||
--comment-line-color: #565656;
|
||||
--drop-shadow-color: rgba(0, 0, 0, 0.5);
|
||||
|
@ -111,6 +152,7 @@
|
|||
--close-button-bg-active-color: rgba(255, 255, 255, 0.15);
|
||||
--close-button-color: rgba(255, 255, 255, 0.5);
|
||||
--close-button-hover-color: rgba(255, 255, 255, 1);
|
||||
--private-note-border-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,13 +237,16 @@ button,
|
|||
text-decoration: none;
|
||||
user-select: none;
|
||||
}
|
||||
button[hidden] {
|
||||
display: none;
|
||||
}
|
||||
:is(button, .button) > * {
|
||||
vertical-align: middle;
|
||||
pointer-events: none;
|
||||
}
|
||||
:is(button, .button):not(:disabled, .disabled):is(:hover, :focus) {
|
||||
cursor: pointer;
|
||||
filter: brightness(1.2);
|
||||
filter: brightness(1.05);
|
||||
}
|
||||
:is(button, .button):not(:disabled, .disabled):active {
|
||||
filter: brightness(0.8);
|
||||
|
@ -232,6 +277,23 @@ button,
|
|||
:is(button, .button).plain4:not(:disabled, .disabled):is(:hover, :focus) {
|
||||
color: var(--text-color);
|
||||
}
|
||||
:is(button, .button).plain5 {
|
||||
background-color: transparent;
|
||||
color: var(--link-color);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--link-faded-color);
|
||||
}
|
||||
:is(button, .button).plain5:not(:disabled, .disabled):is(:hover, :focus) {
|
||||
text-decoration: underline;
|
||||
}
|
||||
:is(button, .button).plain6 {
|
||||
background-color: var(--bg-blur-color);
|
||||
color: var(--link-color);
|
||||
border: 1px solid var(--link-color);
|
||||
}
|
||||
:is(button, .button).plain6:not(:disabled, .disabled):is(:hover, :focus) {
|
||||
background-color: var(--link-bg-color);
|
||||
}
|
||||
:is(button, .button).light {
|
||||
background-color: var(--bg-faded-color);
|
||||
color: var(--text-color);
|
||||
|
@ -285,6 +347,7 @@ button,
|
|||
}
|
||||
|
||||
input[type='text'],
|
||||
input[type='search'],
|
||||
textarea,
|
||||
select {
|
||||
color: var(--text-color);
|
||||
|
@ -294,6 +357,7 @@ select {
|
|||
border-radius: 4px;
|
||||
}
|
||||
input[type='text']:focus,
|
||||
input[type='search']:focus,
|
||||
textarea:focus,
|
||||
select:focus {
|
||||
border-color: var(--outline-color);
|
||||
|
@ -305,8 +369,11 @@ button.large {
|
|||
font-size: 125%;
|
||||
padding: 12px;
|
||||
}
|
||||
textarea:disabled {
|
||||
background-color: var(--bg-faded-color);
|
||||
}
|
||||
|
||||
:is(input[type='text'], textarea, select).block {
|
||||
:is(input[type='text'], input[type='search'], textarea, select).block {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -411,6 +478,17 @@ kbd {
|
|||
}
|
||||
}
|
||||
|
||||
@keyframes slide-up-smooth {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes position-object {
|
||||
0% {
|
||||
object-position: 50% 50%;
|
||||
|
@ -469,3 +547,9 @@ kbd {
|
|||
.shazam-container-horizontal[hidden] {
|
||||
grid-template-columns: 0fr;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
|
16
src/main.jsx
16
src/main.jsx
|
@ -2,6 +2,9 @@ import './index.css';
|
|||
|
||||
import './cloak-mode.css';
|
||||
|
||||
// Polyfill needed for Firefox < 122
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1423593
|
||||
// import '@formatjs/intl-segmenter/polyfill';
|
||||
import { render } from 'preact';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
|
||||
|
@ -11,6 +14,19 @@ if (import.meta.env.DEV) {
|
|||
import('preact/debug');
|
||||
}
|
||||
|
||||
// AbortSignal.timeout polyfill
|
||||
// Temporary fix from https://github.com/mo/abortcontroller-polyfill/issues/73#issuecomment-1541180943
|
||||
// Incorrect implementation, but should be good enough for now
|
||||
if ('AbortSignal' in window) {
|
||||
AbortSignal.timeout =
|
||||
AbortSignal.timeout ||
|
||||
((duration) => {
|
||||
const controller = new AbortController();
|
||||
setTimeout(() => controller.abort(), duration);
|
||||
return controller.signal;
|
||||
});
|
||||
}
|
||||
|
||||
render(
|
||||
<HashRouter>
|
||||
<App />
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
import { MenuItem } from '@szhsin/react-menu';
|
||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'preact/hooks';
|
||||
import punycode from 'punycode/';
|
||||
import { useParams, useSearchParams } from 'react-router-dom';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -10,35 +17,158 @@ import Link from '../components/link';
|
|||
import Menu2 from '../components/menu2';
|
||||
import Timeline from '../components/timeline';
|
||||
import { api } from '../utils/api';
|
||||
import pmem from '../utils/pmem';
|
||||
import showToast from '../utils/show-toast';
|
||||
import states from '../utils/states';
|
||||
import { saveStatus } from '../utils/states';
|
||||
import { isMediaFirstInstance } from '../utils/store-utils';
|
||||
import useTitle from '../utils/useTitle';
|
||||
|
||||
const LIMIT = 20;
|
||||
const MIN_YEAR = 1983;
|
||||
const MIN_YEAR_MONTH = `${MIN_YEAR}-01`; // Birth of the Internet
|
||||
|
||||
const supportsInputMonth = (() => {
|
||||
try {
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute('type', 'month');
|
||||
return input.type === 'month';
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
async function _isSearchEnabled(instance) {
|
||||
const { masto } = api({ instance });
|
||||
const results = await masto.v2.search.fetch({
|
||||
q: 'from:me',
|
||||
type: 'statuses',
|
||||
limit: 1,
|
||||
});
|
||||
return !!results?.statuses?.length;
|
||||
}
|
||||
const isSearchEnabled = pmem(_isSearchEnabled);
|
||||
|
||||
function AccountStatuses() {
|
||||
const snapStates = useSnapshot(states);
|
||||
const { id, ...params } = useParams();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const month = searchParams.get('month');
|
||||
const excludeReplies = !searchParams.get('replies');
|
||||
const excludeBoosts = !!searchParams.get('boosts');
|
||||
const tagged = searchParams.get('tagged');
|
||||
const media = !!searchParams.get('media');
|
||||
const { masto, instance, authenticated } = api({ instance: params.instance });
|
||||
const { masto: currentMasto, instance: currentInstance } = api();
|
||||
const accountStatusesIterator = useRef();
|
||||
|
||||
const allSearchParams = [month, excludeReplies, excludeBoosts, tagged, media];
|
||||
const [account, setAccount] = useState();
|
||||
const searchOffsetRef = useRef(0);
|
||||
useEffect(() => {
|
||||
searchOffsetRef.current = 0;
|
||||
}, allSearchParams);
|
||||
|
||||
const mediaFirst = useMemo(() => isMediaFirstInstance(), []);
|
||||
|
||||
const sameCurrentInstance = useMemo(
|
||||
() => instance === currentInstance,
|
||||
[instance, currentInstance],
|
||||
);
|
||||
const [searchEnabled, setSearchEnabled] = useState(false);
|
||||
useEffect(() => {
|
||||
// Only enable for current logged-in instance
|
||||
// Most remote instances don't allow unauthenticated searches
|
||||
if (!sameCurrentInstance) return;
|
||||
if (!account?.acct) return;
|
||||
(async () => {
|
||||
const enabled = await isSearchEnabled(instance);
|
||||
console.log({ enabled });
|
||||
setSearchEnabled(enabled);
|
||||
})();
|
||||
}, [instance, sameCurrentInstance, account?.acct]);
|
||||
|
||||
async function fetchAccountStatuses(firstLoad) {
|
||||
const results = [];
|
||||
const isValidMonth = /^\d{4}-[01]\d$/.test(month);
|
||||
const isValidYear = month?.split?.('-')?.[0] >= MIN_YEAR;
|
||||
if (isValidMonth && isValidYear) {
|
||||
if (!account) {
|
||||
return {
|
||||
value: [],
|
||||
done: true,
|
||||
};
|
||||
}
|
||||
const [_year, _month] = month.split('-');
|
||||
const monthIndex = parseInt(_month, 10) - 1;
|
||||
// YYYY-MM (no day)
|
||||
// Search options:
|
||||
// - from:account
|
||||
// - after:YYYY-MM-DD (non-inclusive)
|
||||
// - before:YYYY-MM-DD (non-inclusive)
|
||||
|
||||
// Last day of previous month
|
||||
const after = new Date(_year, monthIndex, 0);
|
||||
const afterStr = `${after.getFullYear()}-${(after.getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, '0')}-${after.getDate().toString().padStart(2, '0')}`;
|
||||
// First day of next month
|
||||
const before = new Date(_year, monthIndex + 1, 1);
|
||||
const beforeStr = `${before.getFullYear()}-${(before.getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, '0')}-${before.getDate().toString().padStart(2, '0')}`;
|
||||
console.log({
|
||||
month,
|
||||
_year,
|
||||
_month,
|
||||
monthIndex,
|
||||
after,
|
||||
before,
|
||||
afterStr,
|
||||
beforeStr,
|
||||
});
|
||||
|
||||
let limit;
|
||||
if (firstLoad) {
|
||||
limit = LIMIT + 1;
|
||||
searchOffsetRef.current = 0;
|
||||
} else {
|
||||
limit = LIMIT + searchOffsetRef.current + 1;
|
||||
searchOffsetRef.current += LIMIT;
|
||||
}
|
||||
|
||||
const searchResults = await masto.v2.search.fetch({
|
||||
q: `from:${account.acct} after:${afterStr} before:${beforeStr}`,
|
||||
type: 'statuses',
|
||||
limit,
|
||||
offset: searchOffsetRef.current,
|
||||
});
|
||||
if (searchResults?.statuses?.length) {
|
||||
const value = searchResults.statuses.slice(0, LIMIT);
|
||||
value.forEach((item) => {
|
||||
saveStatus(item, instance);
|
||||
});
|
||||
const done = searchResults.statuses.length <= LIMIT;
|
||||
return { value, done };
|
||||
} else {
|
||||
return { value: [], done: true };
|
||||
}
|
||||
}
|
||||
|
||||
let results = [];
|
||||
if (firstLoad) {
|
||||
const { value: pinnedStatuses } = await masto.v1.accounts
|
||||
.listStatuses(id, {
|
||||
const { value } = await masto.v1.accounts
|
||||
.$select(id)
|
||||
.statuses.list({
|
||||
pinned: true,
|
||||
})
|
||||
.next();
|
||||
if (pinnedStatuses?.length && !tagged && !media) {
|
||||
pinnedStatuses.forEach((status) => {
|
||||
status._pinned = true;
|
||||
if (value?.length && !tagged && !media) {
|
||||
const pinnedStatuses = value.map((status) => {
|
||||
saveStatus(status, instance);
|
||||
return {
|
||||
...status,
|
||||
_pinned: true,
|
||||
};
|
||||
});
|
||||
if (pinnedStatuses.length >= 3) {
|
||||
const pinnedStatusesIds = pinnedStatuses.map((status) => status.id);
|
||||
|
@ -53,16 +183,38 @@ function AccountStatuses() {
|
|||
}
|
||||
}
|
||||
if (firstLoad || !accountStatusesIterator.current) {
|
||||
accountStatusesIterator.current = masto.v1.accounts.listStatuses(id, {
|
||||
limit: LIMIT,
|
||||
exclude_replies: excludeReplies,
|
||||
exclude_reblogs: excludeBoosts,
|
||||
only_media: media,
|
||||
tagged,
|
||||
});
|
||||
accountStatusesIterator.current = masto.v1.accounts
|
||||
.$select(id)
|
||||
.statuses.list({
|
||||
limit: LIMIT,
|
||||
exclude_replies: excludeReplies,
|
||||
exclude_reblogs: excludeBoosts,
|
||||
only_media: media || undefined,
|
||||
tagged,
|
||||
});
|
||||
}
|
||||
const { value, done } = await accountStatusesIterator.current.next();
|
||||
if (value?.length) {
|
||||
// Check if value is same as pinned post (results)
|
||||
// If the index for every post is the same, means API might not support pinned posts
|
||||
if (results.length) {
|
||||
let pinnedStatusesIds = [];
|
||||
if (results[0]?.type === 'pinned') {
|
||||
pinnedStatusesIds = results[0].id;
|
||||
} else {
|
||||
pinnedStatusesIds = results
|
||||
.filter((status) => status._pinned)
|
||||
.map((status) => status.id);
|
||||
}
|
||||
const containsAllPinned = pinnedStatusesIds.every((postId) =>
|
||||
value.some((status) => status.id === postId),
|
||||
);
|
||||
if (containsAllPinned) {
|
||||
// Remove pinned posts
|
||||
results = [];
|
||||
}
|
||||
}
|
||||
|
||||
results.push(...value);
|
||||
|
||||
value.forEach((item) => {
|
||||
|
@ -75,129 +227,228 @@ function AccountStatuses() {
|
|||
};
|
||||
}
|
||||
|
||||
const [account, setAccount] = useState();
|
||||
const [featuredTags, setFeaturedTags] = useState([]);
|
||||
useTitle(
|
||||
`${account?.displayName ? account.displayName + ' ' : ''}@${
|
||||
account?.acct ? account.acct : 'Account posts'
|
||||
}`,
|
||||
account?.acct
|
||||
? `${
|
||||
account?.displayName
|
||||
? `${account.displayName} (${/@/.test(account.acct) ? '' : '@'}${
|
||||
account.acct
|
||||
})`
|
||||
: `${/@/.test(account.acct) ? '' : '@'}${account.acct}`
|
||||
}${
|
||||
!excludeReplies
|
||||
? ' (+ Replies)'
|
||||
: excludeBoosts
|
||||
? ' (- Boosts)'
|
||||
: tagged
|
||||
? ` (#${tagged})`
|
||||
: media
|
||||
? ' (Media)'
|
||||
: month
|
||||
? ` (${new Date(month).toLocaleString('default', {
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
})})`
|
||||
: ''
|
||||
}`
|
||||
: 'Account posts',
|
||||
'/:instance?/a/:id',
|
||||
);
|
||||
|
||||
const fetchAccountPromiseRef = useRef();
|
||||
const fetchAccount = useCallback(() => {
|
||||
const fetchPromise =
|
||||
fetchAccountPromiseRef.current || masto.v1.accounts.$select(id).fetch();
|
||||
fetchAccountPromiseRef.current = fetchPromise;
|
||||
return fetchPromise;
|
||||
}, [id, masto]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const acc = await masto.v1.accounts.fetch(id);
|
||||
const acc = await fetchAccount();
|
||||
console.log(acc);
|
||||
setAccount(acc);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
try {
|
||||
const featuredTags = await masto.v1.accounts.listFeaturedTags(id);
|
||||
console.log({ featuredTags });
|
||||
setFeaturedTags(featuredTags);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
// No need, because the whole filter bar is hidden
|
||||
// TODO: Revisit this
|
||||
if (!mediaFirst) {
|
||||
try {
|
||||
const featuredTags = await masto.v1.accounts
|
||||
.$select(id)
|
||||
.featuredTags.list();
|
||||
console.log({ featuredTags });
|
||||
setFeaturedTags(featuredTags);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, [id]);
|
||||
}, [id, mediaFirst]);
|
||||
|
||||
const { displayName, acct, emojis } = account || {};
|
||||
|
||||
const filterBarRef = useRef();
|
||||
const TimelineStart = useMemo(() => {
|
||||
const filtered =
|
||||
!excludeReplies || excludeBoosts || tagged || media || !!month;
|
||||
const cachedAccount = snapStates.accounts[`${id}@${instance}`];
|
||||
const filtered = !excludeReplies || excludeBoosts || tagged || media;
|
||||
|
||||
return (
|
||||
<>
|
||||
<AccountInfo
|
||||
instance={instance}
|
||||
account={cachedAccount || id}
|
||||
fetchAccount={() => masto.v1.accounts.fetch(id)}
|
||||
fetchAccount={fetchAccount}
|
||||
authenticated={authenticated}
|
||||
standalone
|
||||
/>
|
||||
<div class="filter-bar" ref={filterBarRef}>
|
||||
{filtered ? (
|
||||
{!mediaFirst && (
|
||||
<div
|
||||
class="filter-bar"
|
||||
ref={filterBarRef}
|
||||
style={{
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
{filtered ? (
|
||||
<Link
|
||||
to={`/${instance}/a/${id}`}
|
||||
class="insignificant filter-clear"
|
||||
title="Clear filters"
|
||||
key="clear-filters"
|
||||
>
|
||||
<Icon icon="x" size="l" />
|
||||
</Link>
|
||||
) : (
|
||||
<Icon icon="filter" class="insignificant" size="l" />
|
||||
)}
|
||||
<Link
|
||||
to={`/${instance}/a/${id}`}
|
||||
class="insignificant filter-clear"
|
||||
title="Clear filters"
|
||||
>
|
||||
<Icon icon="x" size="l" />
|
||||
</Link>
|
||||
) : (
|
||||
<Icon icon="filter" class="insignificant" size="l" />
|
||||
)}
|
||||
<Link
|
||||
to={`/${instance}/a/${id}${excludeReplies ? '?replies=1' : ''}`}
|
||||
onClick={() => {
|
||||
if (excludeReplies) {
|
||||
showToast('Showing post with replies');
|
||||
}
|
||||
}}
|
||||
class={excludeReplies ? '' : 'is-active'}
|
||||
>
|
||||
+ Replies
|
||||
</Link>
|
||||
<Link
|
||||
to={`/${instance}/a/${id}${excludeBoosts ? '' : '?boosts=0'}`}
|
||||
onClick={() => {
|
||||
if (!excludeBoosts) {
|
||||
showToast('Showing posts without boosts');
|
||||
}
|
||||
}}
|
||||
class={!excludeBoosts ? '' : 'is-active'}
|
||||
>
|
||||
- Boosts
|
||||
</Link>
|
||||
<Link
|
||||
to={`/${instance}/a/${id}${media ? '' : '?media=1'}`}
|
||||
onClick={() => {
|
||||
if (!media) {
|
||||
showToast('Showing posts with media');
|
||||
}
|
||||
}}
|
||||
class={media ? 'is-active' : ''}
|
||||
>
|
||||
Media
|
||||
</Link>
|
||||
{featuredTags.map((tag) => (
|
||||
<Link
|
||||
to={`/${instance}/a/${id}${
|
||||
tagged === tag.name
|
||||
? ''
|
||||
: `?tagged=${encodeURIComponent(tag.name)}`
|
||||
}`}
|
||||
to={`/${instance}/a/${id}${excludeReplies ? '?replies=1' : ''}`}
|
||||
onClick={() => {
|
||||
if (tagged !== tag.name) {
|
||||
showToast(`Showing posts tagged with #${tag.name}`);
|
||||
if (excludeReplies) {
|
||||
showToast('Showing post with replies');
|
||||
}
|
||||
}}
|
||||
class={tagged === tag.name ? 'is-active' : ''}
|
||||
class={excludeReplies ? '' : 'is-active'}
|
||||
>
|
||||
<span>
|
||||
<span class="more-insignificant">#</span>
|
||||
{tag.name}
|
||||
</span>
|
||||
{
|
||||
// The count differs based on instance 😅
|
||||
}
|
||||
{/* <span class="filter-count">{tag.statusesCount}</span> */}
|
||||
+ Replies
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
<Link
|
||||
to={`/${instance}/a/${id}${excludeBoosts ? '' : '?boosts=0'}`}
|
||||
onClick={() => {
|
||||
if (!excludeBoosts) {
|
||||
showToast('Showing posts without boosts');
|
||||
}
|
||||
}}
|
||||
class={!excludeBoosts ? '' : 'is-active'}
|
||||
>
|
||||
- Boosts
|
||||
</Link>
|
||||
<Link
|
||||
to={`/${instance}/a/${id}${media ? '' : '?media=1'}`}
|
||||
onClick={() => {
|
||||
if (!media) {
|
||||
showToast('Showing posts with media');
|
||||
}
|
||||
}}
|
||||
class={media ? 'is-active' : ''}
|
||||
>
|
||||
Media
|
||||
</Link>
|
||||
{featuredTags.map((tag) => (
|
||||
<Link
|
||||
key={tag.id}
|
||||
to={`/${instance}/a/${id}${
|
||||
tagged === tag.name
|
||||
? ''
|
||||
: `?tagged=${encodeURIComponent(tag.name)}`
|
||||
}`}
|
||||
onClick={() => {
|
||||
if (tagged !== tag.name) {
|
||||
showToast(`Showing posts tagged with #${tag.name}`);
|
||||
}
|
||||
}}
|
||||
class={tagged === tag.name ? 'is-active' : ''}
|
||||
>
|
||||
<span>
|
||||
<span class="more-insignificant">#</span>
|
||||
{tag.name}
|
||||
</span>
|
||||
{
|
||||
// The count differs based on instance 😅
|
||||
}
|
||||
{/* <span class="filter-count">{tag.statusesCount}</span> */}
|
||||
</Link>
|
||||
))}
|
||||
{searchEnabled &&
|
||||
(supportsInputMonth ? (
|
||||
<label class={`filter-field ${month ? 'is-active' : ''}`}>
|
||||
<Icon icon="month" size="l" />
|
||||
<input
|
||||
type="month"
|
||||
disabled={!account?.acct}
|
||||
value={month || ''}
|
||||
min={MIN_YEAR_MONTH}
|
||||
max={new Date().toISOString().slice(0, 7)}
|
||||
onInput={(e) => {
|
||||
const { value, validity } = e.currentTarget;
|
||||
if (!validity.valid) return;
|
||||
setSearchParams(
|
||||
value
|
||||
? {
|
||||
month: value,
|
||||
}
|
||||
: {},
|
||||
);
|
||||
const [year, month] = value.split('-');
|
||||
const monthIndex = parseInt(month, 10) - 1;
|
||||
const date = new Date(year, monthIndex);
|
||||
showToast(
|
||||
`Showing posts in ${date.toLocaleString('default', {
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
})}`,
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
) : (
|
||||
// Fallback to <select> for month and <input type="number"> for year
|
||||
<MonthPicker
|
||||
class={`filter-field ${month ? 'is-active' : ''}`}
|
||||
disabled={!account?.acct}
|
||||
value={month || ''}
|
||||
min={MIN_YEAR_MONTH}
|
||||
max={new Date().toISOString().slice(0, 7)}
|
||||
onInput={(e) => {
|
||||
const { value, validity } = e;
|
||||
if (!validity.valid) return;
|
||||
setSearchParams(
|
||||
value
|
||||
? {
|
||||
month: value,
|
||||
}
|
||||
: {},
|
||||
);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}, [
|
||||
id,
|
||||
instance,
|
||||
authenticated,
|
||||
excludeReplies,
|
||||
excludeBoosts,
|
||||
featuredTags,
|
||||
tagged,
|
||||
media,
|
||||
fetchAccount,
|
||||
searchEnabled,
|
||||
...allSearchParams,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -212,7 +463,7 @@ function AccountStatuses() {
|
|||
(filterBarRef.current.offsetWidth - active.offsetWidth) / 2,
|
||||
});
|
||||
}
|
||||
}, [featuredTags, tagged, media, excludeReplies, excludeBoosts]);
|
||||
}, [featuredTags, searchEnabled, ...allSearchParams]);
|
||||
|
||||
const accountInstance = useMemo(() => {
|
||||
if (!account?.url) return null;
|
||||
|
@ -228,7 +479,7 @@ function AccountStatuses() {
|
|||
title={`${account?.acct ? '@' + account.acct : 'Posts'}`}
|
||||
titleComponent={
|
||||
<h1
|
||||
class="header-account"
|
||||
class="header-double-lines header-account"
|
||||
// onClick={() => {
|
||||
// states.showAccount = {
|
||||
// account,
|
||||
|
@ -250,9 +501,16 @@ function AccountStatuses() {
|
|||
errorText="Unable to load posts"
|
||||
fetchItems={fetchAccountStatuses}
|
||||
useItemID
|
||||
view={media || mediaFirst ? 'media' : undefined}
|
||||
boostsCarousel={snapStates.settings.boostsCarousel}
|
||||
timelineStart={TimelineStart}
|
||||
refresh={excludeReplies + excludeBoosts + tagged + media}
|
||||
refresh={[
|
||||
excludeReplies,
|
||||
excludeBoosts,
|
||||
tagged,
|
||||
media,
|
||||
month + account?.acct,
|
||||
].toString()}
|
||||
headerEnd={
|
||||
<Menu2
|
||||
portal
|
||||
|
@ -288,13 +546,138 @@ function AccountStatuses() {
|
|||
>
|
||||
<Icon icon="transfer" />{' '}
|
||||
<small class="menu-double-lines">
|
||||
Switch to account's instance (<b>{accountInstance}</b>)
|
||||
Switch to account's instance{' '}
|
||||
{accountInstance ? (
|
||||
<>
|
||||
{' '}
|
||||
(<b>{punycode.toUnicode(accountInstance)}</b>)
|
||||
</>
|
||||
) : null}
|
||||
</small>
|
||||
</MenuItem>
|
||||
{!sameCurrentInstance && (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
(async () => {
|
||||
try {
|
||||
const acc = await currentMasto.v1.accounts.lookup({
|
||||
acct: account.acct + '@' + instance,
|
||||
});
|
||||
const { id } = acc;
|
||||
location.hash = `/${currentInstance}/a/${id}`;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('Unable to fetch account info');
|
||||
}
|
||||
})();
|
||||
}}
|
||||
>
|
||||
<Icon icon="transfer" />{' '}
|
||||
<small class="menu-double-lines">
|
||||
Switch to my instance (<b>{currentInstance}</b>)
|
||||
</small>
|
||||
</MenuItem>
|
||||
)}
|
||||
</Menu2>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function MonthPicker(props) {
|
||||
const {
|
||||
class: className,
|
||||
disabled,
|
||||
value,
|
||||
min,
|
||||
max,
|
||||
onInput = () => {},
|
||||
} = props;
|
||||
const [_year, _month] = value?.split('-') || [];
|
||||
const monthFieldRef = useRef();
|
||||
const yearFieldRef = useRef();
|
||||
|
||||
const checkValidity = (month, year) => {
|
||||
const [minYear, minMonth] = min?.split('-') || [];
|
||||
const [maxYear, maxMonth] = max?.split('-') || [];
|
||||
if (year < minYear) return false;
|
||||
if (year > maxYear) return false;
|
||||
if (year === minYear && month < minMonth) return false;
|
||||
if (year === maxYear && month > maxMonth) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
return (
|
||||
<div class={className}>
|
||||
<Icon icon="month" size="l" />
|
||||
<select
|
||||
ref={monthFieldRef}
|
||||
disabled={disabled}
|
||||
value={_month || ''}
|
||||
onInput={(e) => {
|
||||
const { value: month } = e.currentTarget;
|
||||
const year = yearFieldRef.current.value;
|
||||
if (!checkValidity(month, year))
|
||||
return {
|
||||
value: '',
|
||||
validity: {
|
||||
valid: false,
|
||||
},
|
||||
};
|
||||
onInput({
|
||||
value: month ? `${year}-${month}` : '',
|
||||
validity: {
|
||||
valid: true,
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<option value="">Month</option>
|
||||
<option disabled>-----</option>
|
||||
{Array.from({ length: 12 }, (_, i) => (
|
||||
<option
|
||||
value={
|
||||
// Month is 1-indexed
|
||||
(i + 1).toString().padStart(2, '0')
|
||||
}
|
||||
key={i}
|
||||
>
|
||||
{new Date(0, i).toLocaleString('default', {
|
||||
month: 'long',
|
||||
})}
|
||||
</option>
|
||||
))}
|
||||
</select>{' '}
|
||||
<input
|
||||
ref={yearFieldRef}
|
||||
type="number"
|
||||
disabled={disabled}
|
||||
value={_year || new Date().getFullYear()}
|
||||
min={min?.slice(0, 4) || MIN_YEAR}
|
||||
max={max?.slice(0, 4) || new Date().getFullYear()}
|
||||
onInput={(e) => {
|
||||
const { value: year, validity } = e.currentTarget;
|
||||
const month = monthFieldRef.current.value;
|
||||
if (!validity.valid || !checkValidity(month, year))
|
||||
return {
|
||||
value: '',
|
||||
validity: {
|
||||
valid: false,
|
||||
},
|
||||
};
|
||||
onInput({
|
||||
value: year ? `${year}-${month}` : '',
|
||||
validity: {
|
||||
valid: true,
|
||||
},
|
||||
});
|
||||
}}
|
||||
style={{
|
||||
width: '4.5em',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default AccountStatuses;
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
import './accounts.css';
|
||||
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/preact';
|
||||
import { Menu, MenuDivider, MenuItem } from '@szhsin/react-menu';
|
||||
import { useReducer, useState } from 'preact/hooks';
|
||||
import { useReducer } from 'preact/hooks';
|
||||
|
||||
import Avatar from '../components/avatar';
|
||||
import Icon from '../components/icon';
|
||||
import Link from '../components/link';
|
||||
import Menu2 from '../components/menu2';
|
||||
import MenuConfirm from '../components/menu-confirm';
|
||||
import NameText from '../components/name-text';
|
||||
import { api } from '../utils/api';
|
||||
import states from '../utils/states';
|
||||
import store from '../utils/store';
|
||||
import { getCurrentAccountID, setCurrentAccountID } from '../utils/store-utils';
|
||||
|
||||
function Accounts({ onClose }) {
|
||||
const { masto } = api();
|
||||
// Accounts
|
||||
const accounts = store.local.getJSON('accounts');
|
||||
const currentAccount = store.session.get('currentAccount');
|
||||
const currentAccount = getCurrentAccountID();
|
||||
const moreThanOneAccount = accounts.length > 1;
|
||||
const [currentDefault, setCurrentDefault] = useState(0);
|
||||
|
||||
const [_, reload] = useReducer((x) => x + 1, 0);
|
||||
const [accountsListParent] = useAutoAnimate();
|
||||
|
||||
return (
|
||||
<div id="accounts-container" class="sheet" tabIndex="-1">
|
||||
|
@ -34,12 +37,12 @@ function Accounts({ onClose }) {
|
|||
</header>
|
||||
<main>
|
||||
<section>
|
||||
<ul class="accounts-list">
|
||||
<ul class="accounts-list" ref={accountsListParent}>
|
||||
{accounts.map((account, i) => {
|
||||
const isCurrent = account.info.id === currentAccount;
|
||||
const isDefault = i === (currentDefault || 0);
|
||||
const isDefault = i === 0; // first account is always default
|
||||
return (
|
||||
<li key={i + account.id}>
|
||||
<li key={account.info.id}>
|
||||
<div>
|
||||
{moreThanOneAccount && (
|
||||
<span class={`current ${isCurrent ? 'is-current' : ''}`}>
|
||||
|
@ -52,9 +55,9 @@ function Accounts({ onClose }) {
|
|||
onDblClick={async () => {
|
||||
if (isCurrent) {
|
||||
try {
|
||||
const info = await masto.v1.accounts.fetch(
|
||||
account.info.id,
|
||||
);
|
||||
const info = await masto.v1.accounts
|
||||
.$select(account.info.id)
|
||||
.fetch();
|
||||
console.log('fetched account info', info);
|
||||
account.info = info;
|
||||
store.local.setJSON('accounts', accounts);
|
||||
|
@ -79,7 +82,7 @@ function Accounts({ onClose }) {
|
|||
if (isCurrent) {
|
||||
states.showAccount = `${account.info.username}@${account.instanceURL}`;
|
||||
} else {
|
||||
store.session.set('currentAccount', account.info.id);
|
||||
setCurrentAccountID(account.info.id);
|
||||
location.reload();
|
||||
}
|
||||
}}
|
||||
|
@ -91,7 +94,7 @@ function Accounts({ onClose }) {
|
|||
<span class="tag">Default</span>{' '}
|
||||
</>
|
||||
)}
|
||||
<Menu
|
||||
<Menu2
|
||||
align="end"
|
||||
menuButton={
|
||||
<button
|
||||
|
@ -120,7 +123,7 @@ function Accounts({ onClose }) {
|
|||
accounts.splice(i, 1);
|
||||
accounts.unshift(account);
|
||||
store.local.setJSON('accounts', accounts);
|
||||
setCurrentDefault(i);
|
||||
reload();
|
||||
}}
|
||||
>
|
||||
<Icon icon="check-circle" />
|
||||
|
@ -149,7 +152,7 @@ function Accounts({ onClose }) {
|
|||
<Icon icon="exit" />
|
||||
<span>Log out…</span>
|
||||
</MenuConfirm>
|
||||
</Menu>
|
||||
</Menu2>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
|
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
|
@ -7,7 +7,7 @@ import useTitle from '../utils/useTitle';
|
|||
const LIMIT = 20;
|
||||
|
||||
function Favourites() {
|
||||
useTitle('Favourites', '/f');
|
||||
useTitle('Likes', '/f');
|
||||
const { masto, instance } = api();
|
||||
const favouritesIterator = useRef();
|
||||
async function fetchFavourites(firstLoad) {
|
||||
|
@ -19,10 +19,10 @@ function Favourites() {
|
|||
|
||||
return (
|
||||
<Timeline
|
||||
title="Favourites"
|
||||
title="Likes"
|
||||
id="favourites"
|
||||
emptyText="No favourites yet. Go favourite something!"
|
||||
errorText="Unable to load favourites"
|
||||
emptyText="No likes yet. Go like something!"
|
||||
errorText="Unable to load likes"
|
||||
instance={instance}
|
||||
fetchItems={fetchFavourites}
|
||||
/>
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
#filters-page {
|
||||
.filters-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
li {
|
||||
padding: 8px 16px;
|
||||
border-bottom: var(--hairline-width) solid var(--outline-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#filters-add-edit-modal {
|
||||
.filter-form-row {
|
||||
margin-bottom: 16px;
|
||||
|
||||
+ .filter-form-row {
|
||||
margin-top: 16px;
|
||||
border-top: 1px solid var(--outline-color);
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
padding-top: 10px;
|
||||
line-height: 1.5;
|
||||
|
||||
p {
|
||||
margin-block: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.filter-form-keywords {
|
||||
margin: 0 -16px 16px;
|
||||
}
|
||||
|
||||
.filter-form-cols {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.filter-form-col {
|
||||
flex-basis: 160px;
|
||||
flex-grow: 1;
|
||||
|
||||
> *:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
> *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.filter-keywords {
|
||||
--gap: 16px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--gap);
|
||||
padding: var(--gap);
|
||||
overflow-y: auto;
|
||||
min-height: 80px;
|
||||
max-height: 25vh;
|
||||
background-color: var(--bg-faded-blur-color);
|
||||
counter-reset: index;
|
||||
scroll-behavior: smooth;
|
||||
|
||||
li {
|
||||
counter-increment: index;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&:not(:only-child):before {
|
||||
content: counter(index);
|
||||
font-size: 10px;
|
||||
color: var(--text-insignificant-color);
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
input[type='text'] {
|
||||
flex-basis: 160px;
|
||||
flex-grow: 100;
|
||||
}
|
||||
|
||||
.filter-keyword-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-grow: 1;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
label {
|
||||
font-size: 0.8em;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.filter-keywords-footer {
|
||||
padding: 8px 16px 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
input[type='text'] {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.filter-form-footer {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
> span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
button[type='submit'] {
|
||||
padding-inline: 24px;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,587 @@
|
|||
import './filters.css';
|
||||
|
||||
import { useEffect, useReducer, useRef, useState } from 'preact/hooks';
|
||||
|
||||
import Icon from '../components/icon';
|
||||
import Link from '../components/link';
|
||||
import Loader from '../components/loader';
|
||||
import MenuConfirm from '../components/menu-confirm';
|
||||
import Modal from '../components/modal';
|
||||
import NavMenu from '../components/nav-menu';
|
||||
import RelativeTime from '../components/relative-time';
|
||||
import { api } from '../utils/api';
|
||||
import useInterval from '../utils/useInterval';
|
||||
import useTitle from '../utils/useTitle';
|
||||
|
||||
const FILTER_CONTEXT = ['home', 'public', 'notifications', 'thread', 'account'];
|
||||
const FILTER_CONTEXT_UNIMPLEMENTED = ['notifications', 'thread', 'account'];
|
||||
const FILTER_CONTEXT_LABELS = {
|
||||
home: 'Home and lists',
|
||||
notifications: 'Notifications',
|
||||
public: 'Public timelines',
|
||||
thread: 'Conversations',
|
||||
account: 'Profiles',
|
||||
};
|
||||
|
||||
const EXPIRY_DURATIONS = [
|
||||
0, // forever
|
||||
30 * 60, // 30 minutes
|
||||
60 * 60, // 1 hour
|
||||
6 * 60 * 60, // 6 hours
|
||||
12 * 60 * 60, // 12 hours
|
||||
60 * 60 * 24, // 24 hours
|
||||
60 * 60 * 24 * 7, // 7 days
|
||||
60 * 60 * 24 * 30, // 30 days
|
||||
];
|
||||
const EXPIRY_DURATIONS_LABELS = {
|
||||
0: 'Never',
|
||||
1800: '30 minutes',
|
||||
3600: '1 hour',
|
||||
21600: '6 hours',
|
||||
43200: '12 hours',
|
||||
86_400: '24 hours',
|
||||
604_800: '7 days',
|
||||
2_592_000: '30 days',
|
||||
};
|
||||
|
||||
function Filters() {
|
||||
const { masto } = api();
|
||||
useTitle(`Filters`, `/ft`);
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const [showFiltersAddEditModal, setShowFiltersAddEditModal] = useState(false);
|
||||
|
||||
const [reloadCount, reload] = useReducer((c) => c + 1, 0);
|
||||
const [filters, setFilters] = useState([]);
|
||||
useEffect(() => {
|
||||
setUIState('loading');
|
||||
(async () => {
|
||||
try {
|
||||
const filters = await masto.v2.filters.list();
|
||||
filters.sort((a, b) => a.title.localeCompare(b.title));
|
||||
filters.forEach((filter) => {
|
||||
if (filter.keywords?.length) {
|
||||
filter.keywords.sort((a, b) => a.id - b.id);
|
||||
}
|
||||
});
|
||||
console.log(filters);
|
||||
setFilters(filters);
|
||||
setUIState('default');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setUIState('error');
|
||||
}
|
||||
})();
|
||||
}, [reloadCount]);
|
||||
|
||||
return (
|
||||
<div id="filters-page" class="deck-container" tabIndex="-1">
|
||||
<div class="timeline-deck deck">
|
||||
<header>
|
||||
<div class="header-grid">
|
||||
<div class="header-side">
|
||||
<NavMenu />
|
||||
<Link to="/" class="button plain">
|
||||
<Icon icon="home" size="l" />
|
||||
</Link>
|
||||
</div>
|
||||
<h1>Filters</h1>
|
||||
<div class="header-side">
|
||||
<button
|
||||
type="button"
|
||||
class="plain"
|
||||
onClick={() => {
|
||||
setShowFiltersAddEditModal(true);
|
||||
}}
|
||||
>
|
||||
<Icon icon="plus" size="l" alt="New filter" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
{filters.length > 0 ? (
|
||||
<>
|
||||
<ul class="filters-list">
|
||||
{filters.map((filter) => {
|
||||
const { id, title, expiresAt, keywords } = filter;
|
||||
return (
|
||||
<li key={id}>
|
||||
<div>
|
||||
<h2>{title}</h2>
|
||||
{keywords?.length > 0 && (
|
||||
<div>
|
||||
{keywords.map((k) => (
|
||||
<>
|
||||
<span class="tag collapsed insignificant">
|
||||
{k.wholeWord ? `“${k.keyword}”` : k.keyword}
|
||||
</span>{' '}
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<small class="insignificant">
|
||||
<ExpiryStatus expiresAt={expiresAt} />
|
||||
</small>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="plain"
|
||||
onClick={() => {
|
||||
setShowFiltersAddEditModal({
|
||||
filter,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Icon icon="pencil" size="l" alt="Edit filter" />
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{filters.length > 1 && (
|
||||
<footer class="ui-state">
|
||||
<small class="insignificant">
|
||||
{filters.length} filter
|
||||
{filters.length === 1 ? '' : 's'}
|
||||
</small>
|
||||
</footer>
|
||||
)}
|
||||
</>
|
||||
) : uiState === 'loading' ? (
|
||||
<p class="ui-state">
|
||||
<Loader />
|
||||
</p>
|
||||
) : uiState === 'error' ? (
|
||||
<p class="ui-state">Unable to load filters.</p>
|
||||
) : (
|
||||
<p class="ui-state">No filters yet.</p>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
{!!showFiltersAddEditModal && (
|
||||
<Modal
|
||||
title="Add filter"
|
||||
onClose={() => {
|
||||
setShowFiltersAddEditModal(false);
|
||||
}}
|
||||
>
|
||||
<FiltersAddEdit
|
||||
filter={showFiltersAddEditModal?.filter}
|
||||
onClose={(result) => {
|
||||
if (result.state === 'success') {
|
||||
reload();
|
||||
}
|
||||
setShowFiltersAddEditModal(false);
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
let _id = 1;
|
||||
const incID = () => _id++;
|
||||
function FiltersAddEdit({ filter, onClose }) {
|
||||
const { masto } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const editMode = !!filter;
|
||||
const { context, expiresAt, id, keywords, title, filterAction } =
|
||||
filter || {};
|
||||
const hasExpiry = !!expiresAt;
|
||||
const expiresAtDate = hasExpiry && new Date(expiresAt);
|
||||
const [editKeywords, setEditKeywords] = useState(keywords || []);
|
||||
const keywordsRef = useRef();
|
||||
|
||||
// Hacky way of handling removed keywords for both existing and new ones
|
||||
const [removedKeywordIDs, setRemovedKeywordIDs] = useState([]);
|
||||
const [removedKeyword_IDs, setRemovedKeyword_IDs] = useState([]);
|
||||
|
||||
const filteredEditKeywords = editKeywords.filter(
|
||||
(k) =>
|
||||
!removedKeywordIDs.includes(k.id) && !removedKeyword_IDs.includes(k._id),
|
||||
);
|
||||
|
||||
return (
|
||||
<div class="sheet" id="filters-add-edit-modal">
|
||||
{!!onClose && (
|
||||
<button type="button" class="sheet-close" onClick={onClose}>
|
||||
<Icon icon="x" />
|
||||
</button>
|
||||
)}
|
||||
<header>
|
||||
<h2>{editMode ? 'Edit filter' : 'New filter'}</h2>
|
||||
</header>
|
||||
<main>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.target);
|
||||
const title = formData.get('title');
|
||||
const keywordIDs = formData.getAll('keyword_attributes[][id]');
|
||||
const keywordKeywords = formData.getAll(
|
||||
'keyword_attributes[][keyword]',
|
||||
);
|
||||
// const keywordWholeWords = formData.getAll(
|
||||
// 'keyword_attributes[][whole_word]',
|
||||
// );
|
||||
// Not using getAll because it skips the empty checkboxes
|
||||
const keywordWholeWords = [
|
||||
...keywordsRef.current.querySelectorAll(
|
||||
'input[name="keyword_attributes[][whole_word]"]',
|
||||
),
|
||||
].map((i) => i.checked);
|
||||
const keywordsAttributes = keywordKeywords.map((k, i) => ({
|
||||
id: keywordIDs[i] || undefined,
|
||||
keyword: k,
|
||||
wholeWord: keywordWholeWords[i],
|
||||
}));
|
||||
// if (editMode && keywords?.length) {
|
||||
// // Find which one got deleted and add to keywordsAttributes
|
||||
// keywords.forEach((k) => {
|
||||
// if (!keywordsAttributes.find((ka) => ka.id === k.id)) {
|
||||
// keywordsAttributes.push({
|
||||
// ...k,
|
||||
// _destroy: true,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
if (editMode && removedKeywordIDs?.length) {
|
||||
removedKeywordIDs.forEach((id) => {
|
||||
keywordsAttributes.push({
|
||||
id,
|
||||
_destroy: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
const context = formData.getAll('context');
|
||||
let expiresIn = formData.get('expires_in');
|
||||
const filterAction = formData.get('filter_action');
|
||||
console.log({
|
||||
title,
|
||||
keywordIDs,
|
||||
keywords: keywordKeywords,
|
||||
wholeWords: keywordWholeWords,
|
||||
keywordsAttributes,
|
||||
context,
|
||||
expiresIn,
|
||||
filterAction,
|
||||
});
|
||||
|
||||
// Required fields
|
||||
if (!title || !context?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
setUIState('loading');
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
let filterResult;
|
||||
|
||||
if (editMode) {
|
||||
if (expiresIn === '' || expiresIn === null) {
|
||||
// No value
|
||||
// Preserve existing expiry if not specified
|
||||
// Seconds from now to expiresAtDate
|
||||
// Other clients don't do this
|
||||
if (hasExpiry) {
|
||||
expiresIn = Math.floor(
|
||||
(expiresAtDate - new Date()) / 1000,
|
||||
);
|
||||
} else {
|
||||
expiresIn = null;
|
||||
}
|
||||
} else if (expiresIn === '0' || expiresIn === 0) {
|
||||
// 0 = Never
|
||||
expiresIn = null;
|
||||
} else {
|
||||
expiresIn = +expiresIn;
|
||||
}
|
||||
filterResult = await masto.v2.filters.$select(id).update({
|
||||
title,
|
||||
context,
|
||||
expiresIn,
|
||||
keywordsAttributes,
|
||||
filterAction,
|
||||
});
|
||||
} else {
|
||||
expiresIn = +expiresIn || null;
|
||||
filterResult = await masto.v2.filters.create({
|
||||
title,
|
||||
context,
|
||||
expiresIn,
|
||||
keywordsAttributes,
|
||||
filterAction,
|
||||
});
|
||||
}
|
||||
console.log({ filterResult });
|
||||
setUIState('default');
|
||||
onClose?.({
|
||||
state: 'success',
|
||||
filter: filterResult,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
setUIState('error');
|
||||
alert(
|
||||
editMode
|
||||
? 'Unable to edit filter'
|
||||
: 'Unable to create filter',
|
||||
);
|
||||
}
|
||||
})();
|
||||
}}
|
||||
>
|
||||
<div class="filter-form-row">
|
||||
<label>
|
||||
<b>Title</b>
|
||||
<input
|
||||
type="text"
|
||||
name="title"
|
||||
defaultValue={title}
|
||||
disabled={uiState === 'loading'}
|
||||
dir="auto"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="filter-form-keywords" ref={keywordsRef}>
|
||||
{filteredEditKeywords.length ? (
|
||||
<ul class="filter-keywords">
|
||||
{filteredEditKeywords.map((k) => {
|
||||
const { id, keyword, wholeWord, _id } = k;
|
||||
return (
|
||||
<li key={`${id}-${_id}`}>
|
||||
<input
|
||||
type="hidden"
|
||||
name="keyword_attributes[][id]"
|
||||
value={id}
|
||||
/>
|
||||
<input
|
||||
name="keyword_attributes[][keyword]"
|
||||
type="text"
|
||||
defaultValue={keyword}
|
||||
disabled={uiState === 'loading'}
|
||||
required
|
||||
/>
|
||||
<div class="filter-keyword-actions">
|
||||
<label>
|
||||
<input
|
||||
name="keyword_attributes[][whole_word]"
|
||||
type="checkbox"
|
||||
value={id} // Hacky way to map checkbox boolean to the keyword id
|
||||
defaultChecked={wholeWord}
|
||||
disabled={uiState === 'loading'}
|
||||
/>{' '}
|
||||
Whole word
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="light danger small"
|
||||
disabled={uiState === 'loading'}
|
||||
onClick={() => {
|
||||
if (id) {
|
||||
removedKeywordIDs.push(id);
|
||||
setRemovedKeywordIDs([...removedKeywordIDs]);
|
||||
} else if (_id) {
|
||||
removedKeyword_IDs.push(_id);
|
||||
setRemovedKeyword_IDs([...removedKeyword_IDs]);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon icon="x" />
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
) : (
|
||||
<div class="filter-keywords">
|
||||
<div class="insignificant">No keywords. Add one.</div>
|
||||
</div>
|
||||
)}
|
||||
<footer class="filter-keywords-footer">
|
||||
<button
|
||||
type="button"
|
||||
class="light"
|
||||
onClick={() => {
|
||||
setEditKeywords([
|
||||
...editKeywords,
|
||||
{
|
||||
_id: incID(),
|
||||
keyword: '',
|
||||
wholeWord: true,
|
||||
},
|
||||
]);
|
||||
setTimeout(() => {
|
||||
// Focus last input
|
||||
const fields =
|
||||
keywordsRef.current.querySelectorAll(
|
||||
'input[type="text"]',
|
||||
);
|
||||
fields[fields.length - 1]?.focus?.();
|
||||
}, 10);
|
||||
}}
|
||||
>
|
||||
Add keyword
|
||||
</button>{' '}
|
||||
{filteredEditKeywords?.length > 1 && (
|
||||
<small class="insignificant">
|
||||
{filteredEditKeywords.length} keyword
|
||||
{filteredEditKeywords.length === 1 ? '' : 's'}
|
||||
</small>
|
||||
)}
|
||||
</footer>
|
||||
</div>
|
||||
<div class="filter-form-cols">
|
||||
<div class="filter-form-col">
|
||||
<div>
|
||||
<b>Filter from…</b>
|
||||
</div>
|
||||
{FILTER_CONTEXT.map((ctx) => (
|
||||
<div>
|
||||
<label
|
||||
class={
|
||||
FILTER_CONTEXT_UNIMPLEMENTED.includes(ctx)
|
||||
? 'insignificant'
|
||||
: ''
|
||||
}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="context"
|
||||
value={ctx}
|
||||
defaultChecked={!!context ? context.includes(ctx) : true}
|
||||
disabled={uiState === 'loading'}
|
||||
/>{' '}
|
||||
{FILTER_CONTEXT_LABELS[ctx]}
|
||||
{FILTER_CONTEXT_UNIMPLEMENTED.includes(ctx) ? '*' : ''}
|
||||
</label>{' '}
|
||||
</div>
|
||||
))}
|
||||
<p>
|
||||
<small class="insignificant">* Not implemented yet</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="filter-form-col">
|
||||
{editMode && (
|
||||
<>
|
||||
Status:{' '}
|
||||
<b>
|
||||
<ExpiryStatus expiresAt={expiresAt} showNeverExpires />
|
||||
</b>
|
||||
</>
|
||||
)}
|
||||
<div>
|
||||
<label for="filters-expires_in">
|
||||
{editMode ? 'Change expiry' : 'Expiry'}
|
||||
</label>
|
||||
<select
|
||||
id="filters-expires_in"
|
||||
name="expires_in"
|
||||
disabled={uiState === 'loading'}
|
||||
defaultValue={editMode ? undefined : 0}
|
||||
>
|
||||
{editMode && <option></option>}
|
||||
{EXPIRY_DURATIONS.map((v) => (
|
||||
<option value={v}>{EXPIRY_DURATIONS_LABELS[v]}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<p>
|
||||
Filtered post will be…
|
||||
<br />
|
||||
<label class="ib">
|
||||
<input
|
||||
type="radio"
|
||||
name="filter_action"
|
||||
value="warn"
|
||||
defaultChecked={filterAction === 'warn' || !editMode}
|
||||
disabled={uiState === 'loading'}
|
||||
/>{' '}
|
||||
minimized
|
||||
</label>{' '}
|
||||
<label class="ib">
|
||||
<input
|
||||
type="radio"
|
||||
name="filter_action"
|
||||
value="hide"
|
||||
defaultChecked={filterAction === 'hide'}
|
||||
disabled={uiState === 'loading'}
|
||||
/>{' '}
|
||||
hidden
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="filter-form-footer">
|
||||
<span>
|
||||
<button type="submit" disabled={uiState === 'loading'}>
|
||||
{editMode ? 'Save' : 'Create'}
|
||||
</button>{' '}
|
||||
<Loader abrupt hidden={uiState !== 'loading'} />
|
||||
</span>
|
||||
{editMode && (
|
||||
<MenuConfirm
|
||||
disabled={uiState === 'loading'}
|
||||
align="end"
|
||||
menuItemClassName="danger"
|
||||
confirmLabel="Delete this filter?"
|
||||
onClick={() => {
|
||||
setUIState('loading');
|
||||
(async () => {
|
||||
try {
|
||||
await masto.v2.filters.$select(id).remove();
|
||||
setUIState('default');
|
||||
onClose?.({
|
||||
state: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setUIState('error');
|
||||
alert('Unable to delete filter.');
|
||||
}
|
||||
})();
|
||||
}}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="light danger"
|
||||
onClick={() => {}}
|
||||
disabled={uiState === 'loading'}
|
||||
>
|
||||
Delete…
|
||||
</button>
|
||||
</MenuConfirm>
|
||||
)}
|
||||
</footer>
|
||||
</form>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ExpiryStatus({ expiresAt, showNeverExpires }) {
|
||||
const hasExpiry = !!expiresAt;
|
||||
const expiresAtDate = hasExpiry && new Date(expiresAt);
|
||||
const expired = hasExpiry && expiresAtDate <= new Date();
|
||||
|
||||
// If less than a minute left, re-render interval every second, else every minute
|
||||
const [_, rerender] = useReducer((c) => c + 1, 0);
|
||||
useInterval(rerender, expired || 30_000);
|
||||
|
||||
return expired ? (
|
||||
'Expired'
|
||||
) : hasExpiry ? (
|
||||
<>
|
||||
Expiring <RelativeTime datetime={expiresAtDate} />
|
||||
</>
|
||||
) : (
|
||||
showNeverExpires && 'Never expires'
|
||||
);
|
||||
}
|
||||
|
||||
export default Filters;
|
|
@ -5,13 +5,12 @@ import Link from '../components/link';
|
|||
import Loader from '../components/loader';
|
||||
import NavMenu from '../components/nav-menu';
|
||||
import { api } from '../utils/api';
|
||||
import { fetchFollowedTags } from '../utils/followed-tags';
|
||||
import useTitle from '../utils/useTitle';
|
||||
|
||||
const LIMIT = 200;
|
||||
|
||||
function FollowedHashtags() {
|
||||
const { masto, instance } = api();
|
||||
useTitle(`Followed Hashtags`, `/ft`);
|
||||
useTitle(`Followed Hashtags`, `/fh`);
|
||||
const [uiState, setUIState] = useState('default');
|
||||
|
||||
const [followedHashtags, setFollowedHashtags] = useState([]);
|
||||
|
@ -19,17 +18,7 @@ function FollowedHashtags() {
|
|||
setUIState('loading');
|
||||
(async () => {
|
||||
try {
|
||||
const iterator = masto.v1.followedTags.list({
|
||||
limit: LIMIT,
|
||||
});
|
||||
const tags = [];
|
||||
do {
|
||||
const { value, done } = await iterator.next();
|
||||
if (done || value?.length === 0) break;
|
||||
tags.push(...value);
|
||||
} while (true);
|
||||
tags.sort((a, b) => a.name.localeCompare(b.name));
|
||||
console.log(tags);
|
||||
const tags = await fetchFollowedTags();
|
||||
setFollowedHashtags(tags);
|
||||
setUIState('default');
|
||||
} catch (e) {
|
||||
|
@ -56,19 +45,31 @@ function FollowedHashtags() {
|
|||
</header>
|
||||
<main>
|
||||
{followedHashtags.length > 0 ? (
|
||||
<ul class="link-list">
|
||||
{followedHashtags.map((tag) => (
|
||||
<li>
|
||||
<Link
|
||||
to={
|
||||
instance ? `/${instance}/t/${tag.name}` : `/t/${tag.name}`
|
||||
}
|
||||
>
|
||||
<Icon icon="hashtag" /> <span>{tag.name}</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<>
|
||||
<ul class="link-list">
|
||||
{followedHashtags.map((tag) => (
|
||||
<li>
|
||||
<Link
|
||||
to={
|
||||
instance
|
||||
? `/${instance}/t/${tag.name}`
|
||||
: `/t/${tag.name}`
|
||||
}
|
||||
>
|
||||
<Icon icon="hashtag" /> <span>{tag.name}</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{followedHashtags.length > 1 && (
|
||||
<footer class="ui-state">
|
||||
<small class="insignificant">
|
||||
{followedHashtags.length} hashtag
|
||||
{followedHashtags.length === 1 ? '' : 's'}
|
||||
</small>
|
||||
</footer>
|
||||
)}
|
||||
</>
|
||||
) : uiState === 'loading' ? (
|
||||
<p class="ui-state">
|
||||
<Loader abrupt />
|
||||
|
|
|
@ -6,37 +6,56 @@ import { api } from '../utils/api';
|
|||
import { filteredItems } from '../utils/filters';
|
||||
import states from '../utils/states';
|
||||
import { getStatus, saveStatus } from '../utils/states';
|
||||
import { dedupeBoosts } from '../utils/timeline-utils';
|
||||
import supports from '../utils/supports';
|
||||
import {
|
||||
assignFollowedTags,
|
||||
clearFollowedTagsState,
|
||||
dedupeBoosts,
|
||||
} from '../utils/timeline-utils';
|
||||
import useTitle from '../utils/useTitle';
|
||||
|
||||
const LIMIT = 20;
|
||||
|
||||
function Following({ title, path, id, ...props }) {
|
||||
useTitle(title || 'Following', path || '/following');
|
||||
const { masto, instance } = api();
|
||||
const { masto, streaming, instance } = api();
|
||||
const snapStates = useSnapshot(states);
|
||||
const homeIterator = useRef();
|
||||
const latestItem = useRef();
|
||||
|
||||
console.debug('RENDER Following', title, id);
|
||||
const supportsPixelfed = supports('@pixelfed/home-include-reblogs');
|
||||
|
||||
async function fetchHome(firstLoad) {
|
||||
if (firstLoad || !homeIterator.current) {
|
||||
homeIterator.current = masto.v1.timelines.listHome({ limit: LIMIT });
|
||||
homeIterator.current = masto.v1.timelines.home.list({ limit: LIMIT });
|
||||
}
|
||||
if (supportsPixelfed && homeIterator.current?.nextParams) {
|
||||
if (typeof homeIterator.current.nextParams === 'string') {
|
||||
homeIterator.current.nextParams += '&include_reblogs=true';
|
||||
} else {
|
||||
homeIterator.current.nextParams.include_reblogs = true;
|
||||
}
|
||||
}
|
||||
const results = await homeIterator.current.next();
|
||||
let { value } = results;
|
||||
if (value?.length) {
|
||||
let latestItemChanged = false;
|
||||
if (firstLoad) {
|
||||
if (value[0].id !== latestItem.current) {
|
||||
latestItemChanged = true;
|
||||
}
|
||||
latestItem.current = value[0].id;
|
||||
console.log('First load', latestItem.current);
|
||||
}
|
||||
|
||||
value = filteredItems(value, 'home');
|
||||
// value = filteredItems(value, 'home');
|
||||
value.forEach((item) => {
|
||||
saveStatus(item, instance);
|
||||
});
|
||||
value = dedupeBoosts(value, instance);
|
||||
if (firstLoad && latestItemChanged) clearFollowedTagsState();
|
||||
assignFollowedTags(value, instance);
|
||||
|
||||
// ENFORCE sort by datetime (Latest first)
|
||||
value.sort((a, b) => {
|
||||
|
@ -53,15 +72,18 @@ function Following({ title, path, id, ...props }) {
|
|||
|
||||
async function checkForUpdates() {
|
||||
try {
|
||||
const results = await masto.v1.timelines
|
||||
.listHome({
|
||||
limit: 5,
|
||||
since_id: latestItem.current,
|
||||
})
|
||||
.next();
|
||||
const opts = {
|
||||
limit: 5,
|
||||
since_id: latestItem.current,
|
||||
};
|
||||
if (supports('@pixelfed/home-include-reblogs')) {
|
||||
opts.include_reblogs = true;
|
||||
}
|
||||
const results = await masto.v1.timelines.home.list(opts).next();
|
||||
let { value } = results;
|
||||
console.log('checkForUpdates', latestItem.current, value);
|
||||
if (value?.length) {
|
||||
const valueContainsLatestItem = value[0]?.id === latestItem.current; // since_id might not be supported
|
||||
if (value?.length && !valueContainsLatestItem) {
|
||||
latestItem.current = value[0].id;
|
||||
value = dedupeBoosts(value, instance);
|
||||
value = filteredItems(value, 'home');
|
||||
|
@ -75,52 +97,34 @@ function Following({ title, path, id, ...props }) {
|
|||
}
|
||||
}
|
||||
|
||||
const ws = useRef();
|
||||
const streamUser = async () => {
|
||||
console.log('🎏 Start streaming user', ws.current);
|
||||
if (
|
||||
ws.current &&
|
||||
(ws.current.readyState === WebSocket.CONNECTING ||
|
||||
ws.current.readyState === WebSocket.OPEN)
|
||||
) {
|
||||
console.log('🎏 Streaming user already open');
|
||||
return;
|
||||
}
|
||||
const stream = await masto.v1.stream.streamUser();
|
||||
ws.current = stream.ws;
|
||||
ws.current.__id = Math.random();
|
||||
console.log('🎏 Streaming user', ws.current);
|
||||
|
||||
stream.on('status.update', (status) => {
|
||||
console.log(`🔄 Status ${status.id} updated`);
|
||||
saveStatus(status, instance);
|
||||
});
|
||||
|
||||
stream.on('delete', (statusID) => {
|
||||
console.log(`❌ Status ${statusID} deleted`);
|
||||
// delete states.statuses[statusID];
|
||||
const s = getStatus(statusID, instance);
|
||||
if (s) s._deleted = true;
|
||||
});
|
||||
|
||||
stream.ws.onclose = () => {
|
||||
console.log('🎏 Streaming user closed');
|
||||
};
|
||||
|
||||
return stream;
|
||||
};
|
||||
useEffect(() => {
|
||||
let stream;
|
||||
let sub;
|
||||
(async () => {
|
||||
stream = await streamUser();
|
||||
if (streaming) {
|
||||
sub = streaming.user.subscribe();
|
||||
console.log('🎏 Streaming user', sub);
|
||||
for await (const entry of sub) {
|
||||
if (!sub) break;
|
||||
if (entry.event === 'status.update') {
|
||||
const status = entry.payload;
|
||||
console.log(`🔄 Status ${status.id} updated`);
|
||||
saveStatus(status, instance);
|
||||
} else if (entry.event === 'delete') {
|
||||
const statusID = entry.payload;
|
||||
console.log(`❌ Status ${statusID} deleted`);
|
||||
// delete states.statuses[statusID];
|
||||
const s = getStatus(statusID, instance);
|
||||
if (s) s._deleted = true;
|
||||
}
|
||||
}
|
||||
console.log('💥 Streaming user loop STOPPED');
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
if (stream) {
|
||||
stream.ws.close();
|
||||
ws.current = null;
|
||||
}
|
||||
sub?.unsubscribe?.();
|
||||
sub = null;
|
||||
};
|
||||
}, []);
|
||||
}, [streaming]);
|
||||
|
||||
return (
|
||||
<Timeline
|
||||
|
@ -134,7 +138,10 @@ function Following({ title, path, id, ...props }) {
|
|||
useItemID
|
||||
boostsCarousel={snapStates.settings.boostsCarousel}
|
||||
{...props}
|
||||
allowFilters
|
||||
// allowFilters
|
||||
filterContext="home"
|
||||
showFollowedTags
|
||||
showReplyParent
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,19 +2,23 @@ import {
|
|||
FocusableItem,
|
||||
MenuDivider,
|
||||
MenuGroup,
|
||||
MenuHeader,
|
||||
MenuItem,
|
||||
} from '@szhsin/react-menu';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
||||
|
||||
import Icon from '../components/icon';
|
||||
import Menu2 from '../components/menu2';
|
||||
import MenuConfirm from '../components/menu-confirm';
|
||||
import { SHORTCUTS_LIMIT } from '../components/shortcuts-settings';
|
||||
import Timeline from '../components/timeline';
|
||||
import { api } from '../utils/api';
|
||||
import { filteredItems } from '../utils/filters';
|
||||
import showToast from '../utils/show-toast';
|
||||
import states from '../utils/states';
|
||||
import { saveStatus } from '../utils/states';
|
||||
import { isMediaFirstInstance } from '../utils/store-utils';
|
||||
import useTitle from '../utils/useTitle';
|
||||
|
||||
const LIMIT = 20;
|
||||
|
@ -25,28 +29,40 @@ const LIMIT = 20;
|
|||
const TAGS_LIMIT_PER_MODE = 4;
|
||||
const TOTAL_TAGS_LIMIT = TAGS_LIMIT_PER_MODE + 1;
|
||||
|
||||
function Hashtags({ columnMode, ...props }) {
|
||||
function Hashtags({ media: mediaView, columnMode, ...props }) {
|
||||
// const navigate = useNavigate();
|
||||
let { hashtag, ...params } = columnMode ? {} : useParams();
|
||||
if (props.hashtag) hashtag = props.hashtag;
|
||||
let hashtags = hashtag.trim().split(/[\s+]+/);
|
||||
hashtags.sort();
|
||||
hashtag = hashtags[0];
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const media = mediaView || !!searchParams.get('media');
|
||||
const linkParams = media ? '?media=1' : '';
|
||||
|
||||
const { masto, instance, authenticated } = api({
|
||||
instance: props?.instance || params.instance,
|
||||
});
|
||||
const { authenticated: currentAuthenticated } = api();
|
||||
const {
|
||||
masto: currentMasto,
|
||||
instance: currentInstance,
|
||||
authenticated: currentAuthenticated,
|
||||
} = api();
|
||||
const hashtagTitle = hashtags.map((t) => `#${t}`).join(' ');
|
||||
const title = instance ? `${hashtagTitle} on ${instance}` : hashtagTitle;
|
||||
const hashtagPostTitle = media ? ` (Media only)` : '';
|
||||
const title = instance
|
||||
? `${hashtagTitle}${hashtagPostTitle} on ${instance}`
|
||||
: `${hashtagTitle}${hashtagPostTitle}`;
|
||||
useTitle(title, `/:instance?/t/:hashtag`);
|
||||
const latestItem = useRef();
|
||||
|
||||
const mediaFirst = useMemo(() => isMediaFirstInstance(), []);
|
||||
|
||||
// const hashtagsIterator = useRef();
|
||||
const maxID = useRef(undefined);
|
||||
async function fetchHashtags(firstLoad) {
|
||||
// if (firstLoad || !hashtagsIterator.current) {
|
||||
// hashtagsIterator.current = masto.v1.timelines.listHashtag(hashtag, {
|
||||
// hashtagsIterator.current = masto.v1.timelines.tag.$select(hashtag).list({
|
||||
// limit: LIMIT,
|
||||
// any: hashtags.slice(1),
|
||||
// });
|
||||
|
@ -54,21 +70,26 @@ function Hashtags({ columnMode, ...props }) {
|
|||
// const results = await hashtagsIterator.current.next();
|
||||
|
||||
// NOTE: Temporary fix for listHashtag not persisting `any` in subsequent calls.
|
||||
const results = await masto.v1.timelines
|
||||
.listHashtag(hashtag, {
|
||||
const results = await masto.v1.timelines.tag
|
||||
.$select(hashtag)
|
||||
.list({
|
||||
limit: LIMIT,
|
||||
any: hashtags.slice(1),
|
||||
maxId: firstLoad ? undefined : maxID.current,
|
||||
onlyMedia: media ? true : undefined,
|
||||
})
|
||||
.next();
|
||||
const { value } = results;
|
||||
let { value } = results;
|
||||
if (value?.length) {
|
||||
if (firstLoad) {
|
||||
latestItem.current = value[0].id;
|
||||
}
|
||||
|
||||
// value = filteredItems(value, 'public');
|
||||
value.forEach((item) => {
|
||||
saveStatus(item, instance);
|
||||
saveStatus(item, instance, {
|
||||
skipThreading: media || mediaFirst, // If media view, no need to form threads
|
||||
});
|
||||
});
|
||||
|
||||
maxID.current = value[value.length - 1].id;
|
||||
|
@ -81,15 +102,19 @@ function Hashtags({ columnMode, ...props }) {
|
|||
|
||||
async function checkForUpdates() {
|
||||
try {
|
||||
const results = await masto.v1.timelines
|
||||
.listHashtag(hashtag, {
|
||||
const results = await masto.v1.timelines.tag
|
||||
.$select(hashtag)
|
||||
.list({
|
||||
limit: 1,
|
||||
any: hashtags.slice(1),
|
||||
since_id: latestItem.current,
|
||||
onlyMedia: media,
|
||||
})
|
||||
.next();
|
||||
const { value } = results;
|
||||
if (value?.length) {
|
||||
let { value } = results;
|
||||
const valueContainsLatestItem = value[0]?.id === latestItem.current; // since_id might not be supported
|
||||
if (value?.length && !valueContainsLatestItem) {
|
||||
value = filteredItems(value, 'public');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -104,7 +129,7 @@ function Hashtags({ columnMode, ...props }) {
|
|||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const info = await masto.v1.tags.fetch(hashtag);
|
||||
const info = await masto.v1.tags.$select(hashtag).fetch();
|
||||
console.log(info);
|
||||
setInfo(info);
|
||||
} catch (e) {
|
||||
|
@ -121,7 +146,7 @@ function Hashtags({ columnMode, ...props }) {
|
|||
title={title}
|
||||
titleComponent={
|
||||
!!instance && (
|
||||
<h1 class="header-account">
|
||||
<h1 class="header-double-lines">
|
||||
<b>{hashtagTitle}</b>
|
||||
<div>{instance}</div>
|
||||
</h1>
|
||||
|
@ -134,12 +159,16 @@ function Hashtags({ columnMode, ...props }) {
|
|||
fetchItems={fetchHashtags}
|
||||
checkForUpdates={checkForUpdates}
|
||||
useItemID
|
||||
view={media || mediaFirst ? 'media' : undefined}
|
||||
refresh={media}
|
||||
// allowFilters
|
||||
filterContext="public"
|
||||
headerEnd={
|
||||
<Menu2
|
||||
portal
|
||||
setDownOverflow
|
||||
overflow="auto"
|
||||
viewScroll="close"
|
||||
// viewScroll="close"
|
||||
position="anchor"
|
||||
menuButton={
|
||||
<button type="button" class="plain">
|
||||
|
@ -163,7 +192,8 @@ function Hashtags({ columnMode, ...props }) {
|
|||
// return;
|
||||
// }
|
||||
masto.v1.tags
|
||||
.unfollow(hashtag)
|
||||
.$select(hashtag)
|
||||
.unfollow()
|
||||
.then(() => {
|
||||
setInfo({ ...info, following: false });
|
||||
showToast(`Unfollowed #${hashtag}`);
|
||||
|
@ -177,7 +207,8 @@ function Hashtags({ columnMode, ...props }) {
|
|||
});
|
||||
} else {
|
||||
masto.v1.tags
|
||||
.follow(hashtag)
|
||||
.$select(hashtag)
|
||||
.follow()
|
||||
.then(() => {
|
||||
setInfo({ ...info, following: true });
|
||||
showToast(`Followed #${hashtag}`);
|
||||
|
@ -205,6 +236,27 @@ function Hashtags({ columnMode, ...props }) {
|
|||
<MenuDivider />
|
||||
</>
|
||||
)}
|
||||
{!mediaFirst && (
|
||||
<>
|
||||
<MenuHeader className="plain">Filters</MenuHeader>
|
||||
<MenuItem
|
||||
type="checkbox"
|
||||
checked={!!media}
|
||||
onClick={() => {
|
||||
if (media) {
|
||||
searchParams.delete('media');
|
||||
} else {
|
||||
searchParams.set('media', '1');
|
||||
}
|
||||
setSearchParams(searchParams);
|
||||
}}
|
||||
>
|
||||
<Icon icon="check-circle" />{' '}
|
||||
<span class="menu-grow">Media only</span>
|
||||
</MenuItem>
|
||||
<MenuDivider />
|
||||
</>
|
||||
)}
|
||||
<FocusableItem className="menu-field" disabled={reachLimit}>
|
||||
{({ ref }) => (
|
||||
<form
|
||||
|
@ -227,7 +279,7 @@ function Hashtags({ columnMode, ...props }) {
|
|||
// );
|
||||
location.hash = instance
|
||||
? `/${instance}/t/${hashtags.join('+')}`
|
||||
: `/t/${hashtags.join('+')}`;
|
||||
: `/t/${hashtags.join('+')}${linkParams}`;
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
@ -241,7 +293,7 @@ function Hashtags({ columnMode, ...props }) {
|
|||
required
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck={false}
|
||||
spellCheck={false}
|
||||
// no spaces, no hashtags
|
||||
pattern="[^#][^\s#]+[^#]"
|
||||
disabled={reachLimit}
|
||||
|
@ -263,8 +315,8 @@ function Hashtags({ columnMode, ...props }) {
|
|||
// : `/t/${hashtags.join('+')}`,
|
||||
// );
|
||||
location.hash = instance
|
||||
? `/${instance}/t/${hashtags.join('+')}`
|
||||
: `/t/${hashtags.join('+')}`;
|
||||
? `/${instance}/t/${hashtags.join('+')}${linkParams}`
|
||||
: `/t/${hashtags.join('+')}${linkParams}`;
|
||||
}}
|
||||
>
|
||||
<Icon icon="x" alt="Remove hashtag" class="danger-icon" />
|
||||
|
@ -279,10 +331,17 @@ function Hashtags({ columnMode, ...props }) {
|
|||
<MenuItem
|
||||
disabled={!currentAuthenticated}
|
||||
onClick={() => {
|
||||
if (states.shortcuts.length >= SHORTCUTS_LIMIT) {
|
||||
alert(
|
||||
`Max ${SHORTCUTS_LIMIT} shortcuts reached. Unable to add shortcut.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const shortcut = {
|
||||
type: 'hashtag',
|
||||
hashtag: hashtags.join(' '),
|
||||
instance,
|
||||
media: media ? 'on' : undefined,
|
||||
};
|
||||
// Check if already exists
|
||||
const exists = states.shortcuts.some(
|
||||
|
@ -296,7 +355,8 @@ function Hashtags({ columnMode, ...props }) {
|
|||
.split(/[\s+]+/)
|
||||
.sort()
|
||||
.join(' ') &&
|
||||
(s.instance ? s.instance === shortcut.instance : true),
|
||||
(s.instance ? s.instance === shortcut.instance : true) &&
|
||||
(s.media ? !!s.media === !!shortcut.media : true),
|
||||
);
|
||||
if (exists) {
|
||||
alert('This shortcut already exists');
|
||||
|
@ -320,12 +380,28 @@ function Hashtags({ columnMode, ...props }) {
|
|||
if (newInstance) {
|
||||
newInstance = newInstance.toLowerCase().trim();
|
||||
// navigate(`/${newInstance}/t/${hashtags.join('+')}`);
|
||||
location.hash = `/${newInstance}/t/${hashtags.join('+')}`;
|
||||
location.hash = `/${newInstance}/t/${hashtags.join(
|
||||
'+',
|
||||
)}${linkParams}`;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon icon="bus" /> <span>Go to another instance…</span>
|
||||
</MenuItem>
|
||||
{currentInstance !== instance && (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
location.hash = `/${currentInstance}/t/${hashtags.join(
|
||||
'+',
|
||||
)}${linkParams}`;
|
||||
}}
|
||||
>
|
||||
<Icon icon="bus" />{' '}
|
||||
<small class="menu-double-lines">
|
||||
Go to my instance (<b>{currentInstance}</b>)
|
||||
</small>
|
||||
</MenuItem>
|
||||
)}
|
||||
</Menu2>
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -35,8 +35,9 @@ function Home() {
|
|||
|
||||
return (
|
||||
<>
|
||||
{(snapStates.settings.shortcutsColumnsMode ||
|
||||
snapStates.settings.shortcutsViewMode === 'multi-column') &&
|
||||
{(snapStates.settings.shortcutsViewMode === 'multi-column' ||
|
||||
(!snapStates.settings.shortcutsViewMode &&
|
||||
snapStates.settings.shortcutsColumnsMode)) &&
|
||||
!!snapStates.shortcuts?.length ? (
|
||||
<Columns />
|
||||
) : (
|
||||
|
@ -63,7 +64,7 @@ function NotificationsLink() {
|
|||
to="/notifications"
|
||||
class={`button plain notifications-button ${
|
||||
snapStates.notificationsShowNew ? 'has-badge' : ''
|
||||
} ${menuState}`}
|
||||
} ${menuState || ''}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (window.matchMedia('(min-width: calc(40em))').matches) {
|
||||
|
@ -83,7 +84,7 @@ function NotificationsLink() {
|
|||
);
|
||||
}
|
||||
|
||||
const NOTIFICATIONS_LIMIT = 30;
|
||||
const NOTIFICATIONS_LIMIT = 80;
|
||||
const NOTIFICATIONS_DISPLAY_LIMIT = 5;
|
||||
function NotificationsMenu({ anchorRef, state, onClose }) {
|
||||
const { masto, instance } = api();
|
||||
|
@ -178,6 +179,7 @@ function NotificationsMenu({ anchorRef, state, onClose }) {
|
|||
key={notification.id}
|
||||
instance={instance}
|
||||
notification={notification}
|
||||
disableContextMenu
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
|
|
|
@ -1,34 +1,76 @@
|
|||
import { useLayoutEffect } from 'preact/hooks';
|
||||
import { useLayoutEffect, useState } from 'preact/hooks';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
import Link from '../components/link';
|
||||
import getInstanceStatusURL from '../utils/get-instance-status-url';
|
||||
import Loader from '../components/loader';
|
||||
import { api } from '../utils/api';
|
||||
import getInstanceStatusURL, {
|
||||
getInstanceStatusObject,
|
||||
} from '../utils/get-instance-status-url';
|
||||
|
||||
export default function HttpRoute() {
|
||||
const location = useLocation();
|
||||
const url = location.pathname.replace(/^\//, '');
|
||||
const statusURL = getInstanceStatusURL(url);
|
||||
const statusObject = getInstanceStatusObject(url);
|
||||
// const statusURL = getInstanceStatusURL(url);
|
||||
const statusURL = statusObject?.instance
|
||||
? `/${statusObject.instance}/s/${statusObject.id}`
|
||||
: null;
|
||||
const [uiState, setUIState] = useState('loading');
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (statusURL) {
|
||||
setTimeout(() => {
|
||||
window.location.hash = statusURL + '?view=full';
|
||||
}, 300);
|
||||
}
|
||||
setUIState('loading');
|
||||
(async () => {
|
||||
// Check if status returns 200
|
||||
try {
|
||||
const { instance, id } = statusObject;
|
||||
const { masto } = api({ instance });
|
||||
const status = await masto.v1.statuses.$select(id).fetch();
|
||||
if (status) {
|
||||
window.location.hash = statusURL + '?view=full';
|
||||
return;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Fallback to search
|
||||
{
|
||||
const { masto: currentMasto, instance: currentInstance } = api();
|
||||
const result = await currentMasto.v2.search.fetch({
|
||||
q: url,
|
||||
limit: 1,
|
||||
resolve: true,
|
||||
});
|
||||
if (result.statuses.length) {
|
||||
const status = result.statuses[0];
|
||||
window.location.hash = `/${currentInstance}/s/${status.id}?view=full`;
|
||||
} else if (result.accounts.length) {
|
||||
const account = result.accounts[0];
|
||||
window.location.hash = `/${currentInstance}/a/${account.id}`;
|
||||
} else if (statusURL) {
|
||||
// Fallback to original URL, which will probably show error
|
||||
window.location.hash = statusURL + '?view=full';
|
||||
} else {
|
||||
setUIState('error');
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, [statusURL]);
|
||||
|
||||
return (
|
||||
<div class="ui-state" tabIndex="-1">
|
||||
{statusURL ? (
|
||||
{uiState === 'loading' ? (
|
||||
<>
|
||||
<h2>Redirecting…</h2>
|
||||
<Loader abrupt />
|
||||
<h2>Resolving…</h2>
|
||||
<p>
|
||||
<a href={`#${statusURL}?view=full`}>{statusURL}</a>
|
||||
<a href={url} target="_blank" rel="noopener noreferrer">
|
||||
{url}
|
||||
</a>
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h2>Unable to process URL</h2>
|
||||
<h2>Unable to resolve URL</h2>
|
||||
<p>
|
||||
<a href={url} target="_blank" rel="noopener noreferrer">
|
||||
{url}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Ładowanie…
Reference in New Issue