Merge commit 'b8444d9bb7885d75112a3cae74b6a5c711c7d547' into glitch-soc/merge-upstream

This commit is contained in:
Claire 2025-10-08 18:07:04 +02:00
commit f800057008
142 changed files with 2083 additions and 761 deletions

View File

@ -321,9 +321,6 @@ SESSION_RETENTION_PERIOD=31556952
# Fetch All Replies Behavior
# --------------------------
# When a user expands a post (DetailedStatus view), fetch all of its replies
# (default: false)
FETCH_REPLIES_ENABLED=false
# Period to wait between fetching replies (in minutes)
FETCH_REPLIES_COOLDOWN_MINUTES=15

View File

@ -1 +1 @@
3.4.6
3.4.7

26
Gemfile
View File

@ -106,19 +106,19 @@ gem 'opentelemetry-api', '~> 1.7.0'
group :opentelemetry do
gem 'opentelemetry-exporter-otlp', '~> 0.30.0', require: false
gem 'opentelemetry-instrumentation-active_job', '~> 0.8.0', require: false
gem 'opentelemetry-instrumentation-active_model_serializers', '~> 0.22.0', require: false
gem 'opentelemetry-instrumentation-concurrent_ruby', '~> 0.22.0', require: false
gem 'opentelemetry-instrumentation-excon', '~> 0.24.0', require: false
gem 'opentelemetry-instrumentation-faraday', '~> 0.28.0', require: false
gem 'opentelemetry-instrumentation-http', '~> 0.25.0', require: false
gem 'opentelemetry-instrumentation-http_client', '~> 0.24.0', require: false
gem 'opentelemetry-instrumentation-net_http', '~> 0.24.0', require: false
gem 'opentelemetry-instrumentation-pg', '~> 0.30.0', require: false
gem 'opentelemetry-instrumentation-rack', '~> 0.27.0', require: false
gem 'opentelemetry-instrumentation-rails', '~> 0.37.0', require: false
gem 'opentelemetry-instrumentation-redis', '~> 0.26.0', require: false
gem 'opentelemetry-instrumentation-sidekiq', '~> 0.26.0', require: false
gem 'opentelemetry-instrumentation-active_job', '~> 0.9.0', require: false
gem 'opentelemetry-instrumentation-active_model_serializers', '~> 0.23.0', require: false
gem 'opentelemetry-instrumentation-concurrent_ruby', '~> 0.23.0', require: false
gem 'opentelemetry-instrumentation-excon', '~> 0.25.0', require: false
gem 'opentelemetry-instrumentation-faraday', '~> 0.29.0', require: false
gem 'opentelemetry-instrumentation-http', '~> 0.26.0', require: false
gem 'opentelemetry-instrumentation-http_client', '~> 0.25.0', require: false
gem 'opentelemetry-instrumentation-net_http', '~> 0.25.0', require: false
gem 'opentelemetry-instrumentation-pg', '~> 0.31.0', require: false
gem 'opentelemetry-instrumentation-rack', '~> 0.28.0', require: false
gem 'opentelemetry-instrumentation-rails', '~> 0.38.0', require: false
gem 'opentelemetry-instrumentation-redis', '~> 0.27.0', require: false
gem 'opentelemetry-instrumentation-sidekiq', '~> 0.27.0', require: false
gem 'opentelemetry-sdk', '~> 1.4', require: false
end

View File

@ -96,7 +96,7 @@ GEM
ast (2.4.3)
attr_required (1.0.2)
aws-eventstream (1.4.0)
aws-partitions (1.1135.0)
aws-partitions (1.1168.0)
aws-sdk-core (3.215.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
@ -207,7 +207,7 @@ GEM
railties (>= 5)
dotenv (3.1.8)
drb (2.2.3)
dry-cli (1.2.0)
dry-cli (1.3.0)
elasticsearch (7.17.11)
elasticsearch-api (= 7.17.11)
elasticsearch-transport (= 7.17.11)
@ -226,18 +226,18 @@ GEM
activemodel
erb (5.0.2)
erubi (1.13.1)
et-orbi (1.2.11)
et-orbi (1.4.0)
tzinfo
excon (1.2.8)
excon (1.3.0)
logger
fabrication (3.0.0)
faker (3.5.2)
i18n (>= 1.8.11, < 2)
faraday (2.13.4)
faraday (2.14.0)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-follow_redirects (0.3.0)
faraday-follow_redirects (0.4.0)
faraday (>= 1, < 3)
faraday-httpclient (2.0.2)
httpclient (>= 2.2)
@ -266,18 +266,19 @@ GEM
fog-openstack (1.1.5)
fog-core (~> 2.1)
fog-json (>= 1.0)
formatador (1.1.1)
formatador (1.2.1)
reline
forwardable (1.3.3)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
fugit (1.12.0)
et-orbi (~> 1.4)
raabro (~> 1.4)
globalid (1.2.1)
globalid (1.3.0)
activesupport (>= 6.1)
google-protobuf (4.31.1)
google-protobuf (4.32.1)
bigdecimal
rake (>= 13)
googleapis-common-protos-types (1.20.0)
google-protobuf (>= 3.18, < 5.a)
googleapis-common-protos-types (1.21.0)
google-protobuf (~> 4.26)
haml (6.3.0)
temple (>= 0.8.2)
thor
@ -293,7 +294,7 @@ GEM
rainbow
rubocop (>= 1.0)
sysexits (~> 1.1)
hashdiff (1.2.0)
hashdiff (1.2.1)
hashie (5.0.0)
hcaptcha (7.1.0)
json
@ -309,7 +310,7 @@ GEM
http-cookie (~> 1.0)
http-form_data (~> 2.2)
llhttp-ffi (~> 0.5.0)
http-cookie (1.0.8)
http-cookie (1.1.0)
domain_name (~> 0.5)
http-form_data (2.3.0)
http_accept_language (2.1.1)
@ -345,9 +346,9 @@ GEM
azure-blob (~> 0.5.2)
hashie (~> 5.0)
jmespath (1.6.2)
json (2.15.0)
json (2.15.1)
json-canonicalization (1.0.0)
json-jwt (1.16.7)
json-jwt (1.17.0)
activesupport (>= 4.2)
aes_key_wrap
base64
@ -438,7 +439,7 @@ GEM
mime-types (3.7.0)
logger
mime-types-data (~> 3.2025, >= 3.2025.0507)
mime-types-data (3.2025.0916)
mime-types-data (3.2025.0924)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.25.5)
@ -447,7 +448,7 @@ GEM
mutex_m (0.3.0)
net-http (0.6.0)
uri
net-imap (0.5.10)
net-imap (0.5.12)
date
net-protocol
net-ldap (0.20.0)
@ -497,7 +498,7 @@ GEM
tzinfo
validate_url
webfinger (~> 2.0)
openssl (3.3.0)
openssl (3.3.1)
openssl-signature_algorithm (1.3.0)
openssl (> 2.0)
opentelemetry-api (1.7.0)
@ -510,86 +511,61 @@ GEM
opentelemetry-common (~> 0.20)
opentelemetry-sdk (~> 1.2)
opentelemetry-semantic_conventions
opentelemetry-helpers-sql (0.1.1)
opentelemetry-api (~> 1.0)
opentelemetry-helpers-sql (0.2.0)
opentelemetry-api (~> 1.7)
opentelemetry-helpers-sql-obfuscation (0.3.0)
opentelemetry-common (~> 0.21)
opentelemetry-instrumentation-action_mailer (0.4.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-action_mailer (0.5.0)
opentelemetry-instrumentation-active_support (~> 0.7)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-action_pack (0.13.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-action_pack (0.14.1)
opentelemetry-instrumentation-rack (~> 0.21)
opentelemetry-instrumentation-action_view (0.9.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-action_view (0.10.0)
opentelemetry-instrumentation-active_support (~> 0.7)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-active_job (0.8.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-active_model_serializers (0.22.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-active_job (0.9.2)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-active_model_serializers (0.23.0)
opentelemetry-instrumentation-active_support (>= 0.7.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-active_record (0.9.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-active_storage (0.1.1)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-active_record (0.10.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-active_storage (0.2.0)
opentelemetry-instrumentation-active_support (~> 0.7)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-active_support (0.8.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-base (0.23.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-active_support (0.9.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-base (0.24.0)
opentelemetry-api (~> 1.7)
opentelemetry-common (~> 0.21)
opentelemetry-registry (~> 0.1)
opentelemetry-instrumentation-concurrent_ruby (0.22.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-excon (0.24.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-faraday (0.28.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-http (0.25.1)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-http_client (0.24.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-net_http (0.24.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-pg (0.30.1)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-concurrent_ruby (0.23.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-excon (0.25.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-faraday (0.29.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-http (0.26.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-http_client (0.25.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-net_http (0.25.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-pg (0.31.1)
opentelemetry-helpers-sql
opentelemetry-helpers-sql-obfuscation
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-rack (0.27.1)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-rails (0.37.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-action_mailer (~> 0.4.0)
opentelemetry-instrumentation-action_pack (~> 0.13.0)
opentelemetry-instrumentation-action_view (~> 0.9.0)
opentelemetry-instrumentation-active_job (~> 0.8.0)
opentelemetry-instrumentation-active_record (~> 0.9.0)
opentelemetry-instrumentation-active_storage (~> 0.1.0)
opentelemetry-instrumentation-active_support (~> 0.8.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-concurrent_ruby (~> 0.22.0)
opentelemetry-instrumentation-redis (0.26.1)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-sidekiq (0.26.1)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.23.0)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-rack (0.28.2)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-rails (0.38.0)
opentelemetry-instrumentation-action_mailer (~> 0.4)
opentelemetry-instrumentation-action_pack (~> 0.13)
opentelemetry-instrumentation-action_view (~> 0.9)
opentelemetry-instrumentation-active_job (~> 0.8)
opentelemetry-instrumentation-active_record (~> 0.9)
opentelemetry-instrumentation-active_storage (~> 0.1)
opentelemetry-instrumentation-active_support (~> 0.8)
opentelemetry-instrumentation-concurrent_ruby (~> 0.22)
opentelemetry-instrumentation-redis (0.27.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-instrumentation-sidekiq (0.27.1)
opentelemetry-instrumentation-base (~> 0.24)
opentelemetry-registry (0.4.0)
opentelemetry-api (~> 1.1)
opentelemetry-sdk (1.9.0)
@ -616,7 +592,7 @@ GEM
playwright-ruby-client (1.55.0)
concurrent-ruby (>= 1.1.6)
mime-types (>= 3.0)
pp (0.6.2)
pp (0.6.3)
prettyprint
premailer (1.27.0)
addressable
@ -644,7 +620,7 @@ GEM
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.1)
rack (3.2.1)
rack (3.2.2)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-cors (3.0.0)
@ -714,9 +690,10 @@ GEM
readline (~> 0.0)
rdf-normalize (0.7.0)
rdf (~> 3.3)
rdoc (6.14.2)
rdoc (6.15.0)
erb
psych (>= 4.0.0)
tsort
readline (0.0.4)
reline
redcarpet (3.6.1)
@ -733,7 +710,7 @@ GEM
railties (>= 5.2)
rexml (3.4.4)
rotp (6.3.0)
rouge (4.6.0)
rouge (4.6.1)
rpam2 (4.0.2)
rqrcode (3.1.0)
chunky_png (~> 1.0)
@ -766,7 +743,7 @@ GEM
rspec-expectations (~> 3.0)
rspec-mocks (~> 3.0)
sidekiq (>= 5, < 9)
rspec-support (3.13.4)
rspec-support (3.13.6)
rubocop (1.81.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
@ -827,7 +804,7 @@ GEM
securerandom (0.4.1)
shoulda-matchers (6.5.0)
activesupport (>= 5.2.0)
sidekiq (8.0.7)
sidekiq (8.0.8)
connection_pool (>= 2.5.0)
json (>= 2.9.0)
logger (>= 1.6.2)
@ -905,7 +882,7 @@ GEM
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.1.0)
uri (1.0.3)
uri (1.0.4)
useragent (0.16.11)
validate_url (1.0.15)
activemodel (>= 3.0.0)
@ -1032,19 +1009,19 @@ DEPENDENCIES
omniauth_openid_connect (~> 0.8.0)
opentelemetry-api (~> 1.7.0)
opentelemetry-exporter-otlp (~> 0.30.0)
opentelemetry-instrumentation-active_job (~> 0.8.0)
opentelemetry-instrumentation-active_model_serializers (~> 0.22.0)
opentelemetry-instrumentation-concurrent_ruby (~> 0.22.0)
opentelemetry-instrumentation-excon (~> 0.24.0)
opentelemetry-instrumentation-faraday (~> 0.28.0)
opentelemetry-instrumentation-http (~> 0.25.0)
opentelemetry-instrumentation-http_client (~> 0.24.0)
opentelemetry-instrumentation-net_http (~> 0.24.0)
opentelemetry-instrumentation-pg (~> 0.30.0)
opentelemetry-instrumentation-rack (~> 0.27.0)
opentelemetry-instrumentation-rails (~> 0.37.0)
opentelemetry-instrumentation-redis (~> 0.26.0)
opentelemetry-instrumentation-sidekiq (~> 0.26.0)
opentelemetry-instrumentation-active_job (~> 0.9.0)
opentelemetry-instrumentation-active_model_serializers (~> 0.23.0)
opentelemetry-instrumentation-concurrent_ruby (~> 0.23.0)
opentelemetry-instrumentation-excon (~> 0.25.0)
opentelemetry-instrumentation-faraday (~> 0.29.0)
opentelemetry-instrumentation-http (~> 0.26.0)
opentelemetry-instrumentation-http_client (~> 0.25.0)
opentelemetry-instrumentation-net_http (~> 0.25.0)
opentelemetry-instrumentation-pg (~> 0.31.0)
opentelemetry-instrumentation-rack (~> 0.28.0)
opentelemetry-instrumentation-rails (~> 0.38.0)
opentelemetry-instrumentation-redis (~> 0.27.0)
opentelemetry-instrumentation-sidekiq (~> 0.27.0)
opentelemetry-sdk (~> 1.4)
ox (~> 2.14)
parslet
@ -1110,4 +1087,4 @@ RUBY VERSION
ruby 3.4.1p0
BUNDLED WITH
2.7.1
2.7.2

View File

@ -21,7 +21,13 @@ module HomeHelper
end
end
else
link_to(path || ActivityPub::TagManager.instance.url_for(account), class: 'account__display-name') do
account_url = if account.suspended?
ActivityPub::TagManager.instance.url_for(account)
else
web_url("@#{account.pretty_acct}")
end
link_to(path || account_url, class: 'account__display-name') do
content_tag(:div, class: 'account__avatar-wrapper') do
image_tag(full_asset_url(current_account&.user&.setting_auto_play_gif ? account.avatar_original_url : account.avatar_static_url), class: 'account__avatar', width: 46, height: 46)
end +

View File

@ -70,7 +70,7 @@ function loaded() {
};
document.querySelectorAll('.emojify').forEach((content) => {
content.innerHTML = emojify(content.innerHTML);
content.innerHTML = emojify(content.innerHTML, {}, true); // Force emojify as public doesn't load the new emoji system.
});
document

View File

@ -4,6 +4,7 @@ import { createAction } from '@reduxjs/toolkit';
import type { List as ImmutableList, Map as ImmutableMap } from 'immutable';
import { apiUpdateMedia } from 'mastodon/api/compose';
import { apiGetSearch } from 'mastodon/api/search';
import type { ApiMediaAttachmentJSON } from 'mastodon/api_types/media_attachments';
import type { MediaAttachment } from 'mastodon/models/media_attachment';
import {
@ -16,6 +17,7 @@ import type { Status } from '../models/status';
import { showAlert } from './alerts';
import { focusCompose } from './compose';
import { importFetchedStatuses } from './importer';
import { openModal } from './modal';
const messages = defineMessages({
@ -165,6 +167,41 @@ export const quoteComposeById = createAppThunk(
},
);
export const pasteLinkCompose = createDataLoadingThunk(
'compose/pasteLink',
async ({ url }: { url: string }) => {
return await apiGetSearch({
q: url,
type: 'statuses',
resolve: true,
limit: 2,
});
},
(data, { dispatch, getState }) => {
const composeState = getState().compose;
if (
composeState.get('quoted_status_id') ||
composeState.get('is_submitting') ||
composeState.get('poll') ||
composeState.get('is_uploading')
)
return;
dispatch(importFetchedStatuses(data.statuses));
if (
data.statuses.length === 1 &&
data.statuses[0] &&
['automatic', 'manual'].includes(
data.statuses[0].quote_approval?.current_user ?? 'denied',
)
) {
dispatch(quoteComposeById(data.statuses[0].id));
}
},
);
export const quoteComposeCancel = createAction('compose/quoteComposeCancel');
export const setComposeQuotePolicy = createAction<ApiQuotePolicy>(

View File

@ -9,8 +9,9 @@ import { importFetchedStatuses } from './importer';
export const fetchContext = createDataLoadingThunk(
'status/context',
({ statusId }: { statusId: string }) => apiGetContext(statusId),
({ context, refresh }, { dispatch }) => {
({ statusId }: { statusId: string; prefetchOnly?: boolean }) =>
apiGetContext(statusId),
({ context, refresh }, { dispatch, actionArg: { prefetchOnly = false } }) => {
const statuses = context.ancestors.concat(context.descendants);
dispatch(importFetchedStatuses(statuses));
@ -18,6 +19,7 @@ export const fetchContext = createDataLoadingThunk(
return {
context,
refresh,
prefetchOnly,
};
},
);
@ -26,6 +28,14 @@ export const completeContextRefresh = createAction<{ statusId: string }>(
'status/context/complete',
);
export const showPendingReplies = createAction<{ statusId: string }>(
'status/context/showPendingReplies',
);
export const clearPendingReplies = createAction<{ statusId: string }>(
'status/context/clearPendingReplies',
);
export const setStatusQuotePolicy = createDataLoadingThunk(
'status/setQuotePolicy',
({ statusId, policy }: { statusId: string; policy: ApiQuotePolicy }) => {

View File

@ -0,0 +1,28 @@
// See app/serializers/rest/announcement_serializer.rb
import type { ApiCustomEmojiJSON } from './custom_emoji';
import type { ApiMentionJSON, ApiStatusJSON, ApiTagJSON } from './statuses';
export interface ApiAnnouncementJSON {
id: string;
content: string;
starts_at: null | string;
ends_at: null | string;
all_day: boolean;
published_at: string;
updated_at: null | string;
read: boolean;
mentions: ApiMentionJSON[];
statuses: ApiStatusJSON[];
tags: ApiTagJSON[];
emojis: ApiCustomEmojiJSON[];
reactions: ApiAnnouncementReactionJSON[];
}
export interface ApiAnnouncementReactionJSON {
name: string;
count: number;
me: boolean;
url?: string;
static_url?: string;
}

View File

@ -5,6 +5,7 @@ import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { Link } from 'react-router-dom';
import { EmojiHTML } from '@/mastodon/components/emoji/html';
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
import {
blockAccount,
@ -331,9 +332,10 @@ export const Account: React.FC<AccountProps> = ({
{account &&
withBio &&
(account.note.length > 0 ? (
<div
<EmojiHTML
className='account__note translate'
dangerouslySetInnerHTML={{ __html: account.note_emojified }}
htmlString={account.note_emojified}
extraEmojis={account.emojis}
/>
) : (
<div className='account__note account__note--missing'>

View File

@ -7,8 +7,8 @@ import { useLinks } from 'mastodon/hooks/useLinks';
import { useAppSelector } from '../store';
import { isModernEmojiEnabled } from '../utils/environment';
import { AnimateEmojiProvider } from './emoji/context';
import { EmojiHTML } from './emoji/html';
import { useElementHandledLink } from './status/handled_link';
interface AccountBioProps {
className: string;
@ -24,19 +24,29 @@ export const AccountBio: React.FC<AccountBioProps> = ({
const handleClick = useLinks(showDropdown);
const handleNodeChange = useCallback(
(node: HTMLDivElement | null) => {
if (!showDropdown || !node || node.childNodes.length === 0) {
if (
!showDropdown ||
!node ||
node.childNodes.length === 0 ||
isModernEmojiEnabled()
) {
return;
}
addDropdownToHashtags(node, accountId);
},
[showDropdown, accountId],
);
const htmlHandlers = useElementHandledLink({
hashtagAccountId: showDropdown ? accountId : undefined,
});
const note = useAppSelector((state) => {
const account = state.accounts.get(accountId);
if (!account) {
return '';
}
return isModernEmojiEnabled() ? account.note : account.note_emojified;
return account.note_emojified;
});
const extraEmojis = useAppSelector((state) => {
const account = state.accounts.get(accountId);
@ -48,13 +58,14 @@ export const AccountBio: React.FC<AccountBioProps> = ({
}
return (
<AnimateEmojiProvider
<EmojiHTML
htmlString={note}
extraEmojis={extraEmojis}
className={classNames(className, 'translate')}
onClickCapture={handleClick}
ref={handleNodeChange}
>
<EmojiHTML htmlString={note} extraEmojis={extraEmojis} />
</AnimateEmojiProvider>
{...htmlHandlers}
/>
);
};

View File

@ -1,42 +1,70 @@
import { useIntl } from 'react-intl';
import classNames from 'classnames';
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
import { Icon } from 'mastodon/components/icon';
import { useLinks } from 'mastodon/hooks/useLinks';
import type { Account } from 'mastodon/models/account';
export const AccountFields: React.FC<{
fields: Account['fields'];
limit: number;
}> = ({ fields, limit = -1 }) => {
const handleClick = useLinks();
import { CustomEmojiProvider } from './emoji/context';
import { EmojiHTML } from './emoji/html';
import { useElementHandledLink } from './status/handled_link';
export const AccountFields: React.FC<Pick<Account, 'fields' | 'emojis'>> = ({
fields,
emojis,
}) => {
const intl = useIntl();
const htmlHandlers = useElementHandledLink();
if (fields.size === 0) {
return null;
}
return (
<div className='account-fields' onClickCapture={handleClick}>
{fields.take(limit).map((pair, i) => (
<dl
key={i}
className={classNames({ verified: pair.get('verified_at') })}
>
<dt
dangerouslySetInnerHTML={{ __html: pair.get('name_emojified') }}
<CustomEmojiProvider emojis={emojis}>
{fields.map((pair, i) => (
<dl key={i} className={classNames({ verified: pair.verified_at })}>
<EmojiHTML
as='dt'
htmlString={pair.name_emojified}
className='translate'
{...htmlHandlers}
/>
<dd className='translate' title={pair.get('value_plain') ?? ''}>
{pair.get('verified_at') && (
<Icon id='check' icon={CheckIcon} className='verified__mark' />
)}
<span
dangerouslySetInnerHTML={{ __html: pair.get('value_emojified') }}
<dd className='translate' title={pair.value_plain ?? ''}>
{pair.verified_at && (
<span
title={intl.formatMessage(
{
id: 'account.link_verified_on',
defaultMessage:
'Ownership of this link was checked on {date}',
},
{
date: intl.formatDate(pair.verified_at, dateFormatOptions),
},
)}
>
<Icon id='check' icon={CheckIcon} className='verified__mark' />
</span>
)}{' '}
<EmojiHTML
as='span'
htmlString={pair.value_emojified}
{...htmlHandlers}
/>
</dd>
</dl>
))}
</div>
</CustomEmojiProvider>
);
};
const dateFormatOptions: Intl.DateTimeFormatOptions = {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
};

View File

@ -150,10 +150,7 @@ const AutosuggestTextarea = forwardRef(({
}, [suggestions, onSuggestionSelected, textareaRef]);
const handlePaste = useCallback((e) => {
if (e.clipboardData && e.clipboardData.files.length === 1) {
onPaste(e.clipboardData.files);
e.preventDefault();
}
onPaste(e);
}, [onPaste]);
// Show the suggestions again whenever they change and the textarea is focused

View File

@ -1,15 +1,38 @@
import type { List } from 'immutable';
import type { CustomEmoji } from '../models/custom_emoji';
import type { Status } from '../models/status';
import { EmojiHTML } from './emoji/html';
import { StatusBanner, BannerVariant } from './status_banner';
export const ContentWarning: React.FC<{
text: string;
status: Status;
expanded?: boolean;
onClick?: () => void;
}> = ({ text, expanded, onClick }) => (
<StatusBanner
expanded={expanded}
onClick={onClick}
variant={BannerVariant.Warning}
>
<span dangerouslySetInnerHTML={{ __html: text }} />
</StatusBanner>
);
}> = ({ status, expanded, onClick }) => {
const hasSpoiler = !!status.get('spoiler_text');
if (!hasSpoiler) {
return null;
}
const text =
status.getIn(['translation', 'spoilerHtml']) || status.get('spoilerHtml');
if (typeof text !== 'string' || text.length === 0) {
return null;
}
return (
<StatusBanner
expanded={expanded}
onClick={onClick}
variant={BannerVariant.Warning}
>
<EmojiHTML
as='span'
htmlString={text}
extraEmojis={status.get('emoji') as List<CustomEmoji>}
/>
</StatusBanner>
);
};

View File

@ -2,8 +2,6 @@ import type { ComponentPropsWithoutRef, FC } from 'react';
import classNames from 'classnames';
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
import { AnimateEmojiProvider } from '../emoji/context';
import { EmojiHTML } from '../emoji/html';
import { Skeleton } from '../skeleton';
@ -24,11 +22,7 @@ export const DisplayNameWithoutDomain: FC<
{account ? (
<EmojiHTML
className='display-name__html'
htmlString={
isModernEmojiEnabled()
? account.get('display_name')
: account.get('display_name_html')
}
htmlString={account.get('display_name_html')}
as='strong'
extraEmojis={account.get('emojis')}
/>

View File

@ -1,7 +1,5 @@
import type { ComponentPropsWithoutRef, FC } from 'react';
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
import { EmojiHTML } from '../emoji/html';
import type { DisplayNameProps } from './index';
@ -19,11 +17,7 @@ export const DisplayNameSimple: FC<
<EmojiHTML
{...props}
as='span'
htmlString={
isModernEmojiEnabled()
? account.get('display_name')
: account.get('display_name_html')
}
htmlString={account.get('display_name_html')}
extraEmojis={account.get('emojis')}
/>
</bdi>

View File

@ -1,60 +1,89 @@
import { useMemo } from 'react';
import type { ComponentPropsWithoutRef, ElementType } from 'react';
import classNames from 'classnames';
import type { CustomEmojiMapArg } from '@/mastodon/features/emoji/types';
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
import type {
OnAttributeHandler,
OnElementHandler,
} from '@/mastodon/utils/html';
import { htmlStringToComponents } from '@/mastodon/utils/html';
import { polymorphicForwardRef } from '@/types/polymorphic';
import { AnimateEmojiProvider, CustomEmojiProvider } from './context';
import { textToEmojis } from './index';
type EmojiHTMLProps<Element extends ElementType = 'div'> = Omit<
ComponentPropsWithoutRef<Element>,
'dangerouslySetInnerHTML' | 'className'
> & {
interface EmojiHTMLProps {
htmlString: string;
extraEmojis?: CustomEmojiMapArg;
as?: Element;
className?: string;
};
onElement?: OnElementHandler;
onAttribute?: OnAttributeHandler;
}
export const ModernEmojiHTML = ({
extraEmojis,
htmlString,
as: asProp = 'div', // Rename for syntax highlighting
shallow,
className = '',
...props
}: EmojiHTMLProps<ElementType>) => {
const contents = useMemo(
() => htmlStringToComponents(htmlString, { onText: textToEmojis }),
[htmlString],
);
export const ModernEmojiHTML = polymorphicForwardRef<'div', EmojiHTMLProps>(
(
{
extraEmojis,
htmlString,
as: asProp = 'div', // Rename for syntax highlighting
className = '',
onElement,
onAttribute,
...props
},
ref,
) => {
const contents = useMemo(
() =>
htmlStringToComponents(htmlString, {
onText: textToEmojis,
onElement,
onAttribute,
}),
[htmlString, onAttribute, onElement],
);
return (
<CustomEmojiProvider emojis={extraEmojis}>
<AnimateEmojiProvider {...props} as={asProp} className={className}>
{contents}
</AnimateEmojiProvider>
</CustomEmojiProvider>
);
};
return (
<CustomEmojiProvider emojis={extraEmojis}>
<AnimateEmojiProvider
{...props}
as={asProp}
className={className}
ref={ref}
>
{contents}
</AnimateEmojiProvider>
</CustomEmojiProvider>
);
},
);
ModernEmojiHTML.displayName = 'ModernEmojiHTML';
export const LegacyEmojiHTML = <Element extends ElementType>(
props: EmojiHTMLProps<Element>,
) => {
const { as: asElement, htmlString, extraEmojis, className, ...rest } = props;
const Wrapper = asElement ?? 'div';
return (
<Wrapper
{...rest}
dangerouslySetInnerHTML={{ __html: htmlString }}
className={classNames(className, 'animate-parent')}
/>
);
};
export const LegacyEmojiHTML = polymorphicForwardRef<'div', EmojiHTMLProps>(
(props, ref) => {
const {
as: asElement,
htmlString,
extraEmojis,
className,
onElement,
onAttribute,
...rest
} = props;
const Wrapper = asElement ?? 'div';
return (
<Wrapper
{...rest}
ref={ref}
dangerouslySetInnerHTML={{ __html: htmlString }}
className={classNames(className, 'animate-parent')}
/>
);
},
);
LegacyEmojiHTML.displayName = 'LegacyEmojiHTML';
export const EmojiHTML = isModernEmojiEnabled()
? ModernEmojiHTML

View File

@ -23,6 +23,8 @@ import { domain } from 'mastodon/initial_state';
import { getAccountHidden } from 'mastodon/selectors/accounts';
import { useAppSelector, useAppDispatch } from 'mastodon/store';
import { useLinks } from '../hooks/useLinks';
export const HoverCardAccount = forwardRef<
HTMLDivElement,
{ accountId?: string }
@ -64,6 +66,8 @@ export const HoverCardAccount = forwardRef<
!isMutual &&
!isFollower;
const handleClick = useLinks();
return (
<div
ref={ref}
@ -105,7 +109,14 @@ export const HoverCardAccount = forwardRef<
accountId={account.id}
className='hover-card__bio'
/>
<AccountFields fields={account.fields} limit={2} />
<div className='account-fields' onClickCapture={handleClick}>
<AccountFields
fields={account.fields.take(2)}
emojis={account.emojis}
/>
</div>
{note && note.length > 0 && (
<dl className='hover-card__note'>
<dt className='hover-card__note-label'>

View File

@ -8,6 +8,7 @@ import classNames from 'classnames';
import { animated, useSpring } from '@react-spring/web';
import escapeTextContentForBrowser from 'escape-html';
import { EmojiHTML } from '@/mastodon/components/emoji/html';
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
import { openModal } from 'mastodon/actions/modal';
import { fetchPoll, vote } from 'mastodon/actions/polls';
@ -305,10 +306,11 @@ const PollOption: React.FC<PollOptionProps> = (props) => {
</span>
)}
<span
<EmojiHTML
className='poll__option__text translate'
lang={lang}
dangerouslySetInnerHTML={{ __html: titleHtml }}
htmlString={titleHtml}
extraEmojis={poll.emojis}
/>
{!!voted && (

View File

@ -118,7 +118,7 @@ class Status extends ImmutablePureComponent {
unread: PropTypes.bool,
showThread: PropTypes.bool,
isQuotedPost: PropTypes.bool,
shouldHighlightOnMount: PropTypes.bool,
shouldHighlightOnMount: PropTypes.bool,
getScrollPosition: PropTypes.func,
updateScrollBottom: PropTypes.func,
cacheMediaWidth: PropTypes.func,
@ -600,7 +600,7 @@ class Status extends ImmutablePureComponent {
{matchedFilters && <FilterWarning title={matchedFilters.join(', ')} expanded={this.state.showDespiteFilter} onClick={this.handleFilterToggle} />}
{(status.get('spoiler_text').length > 0 && (!matchedFilters || this.state.showDespiteFilter)) && <ContentWarning text={status.getIn(['translation', 'spoilerHtml']) || status.get('spoilerHtml')} expanded={expanded} onClick={this.handleExpandedToggle} />}
{(!matchedFilters || this.state.showDespiteFilter) && <ContentWarning status={status} expanded={expanded} onClick={this.handleExpandedToggle} />}
{expanded && (
<>

View File

@ -0,0 +1,65 @@
import type { Meta, StoryObj } from '@storybook/react-vite';
import { HashtagMenuController } from '@/mastodon/features/ui/components/hashtag_menu_controller';
import { accountFactoryState } from '@/testing/factories';
import { HoverCardController } from '../hover_card_controller';
import type { HandledLinkProps } from './handled_link';
import { HandledLink } from './handled_link';
const meta = {
title: 'Components/Status/HandledLink',
render(args) {
return (
<>
<HandledLink {...args} mentionAccountId='1' hashtagAccountId='1' />
<HashtagMenuController />
<HoverCardController />
</>
);
},
args: {
href: 'https://example.com/path/subpath?query=1#hash',
text: 'https://example.com',
},
parameters: {
state: {
accounts: {
'1': accountFactoryState(),
},
},
},
} satisfies Meta<Pick<HandledLinkProps, 'href' | 'text'>>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};
export const Hashtag: Story = {
args: {
text: '#example',
},
};
export const Mention: Story = {
args: {
text: '@user',
},
};
export const InternalLink: Story = {
args: {
href: '/about',
text: 'About',
},
};
export const InvalidURL: Story = {
args: {
href: 'ht!tp://invalid-url',
text: 'ht!tp://invalid-url -- invalid!',
},
};

View File

@ -0,0 +1,111 @@
import { useCallback } from 'react';
import type { ComponentProps, FC } from 'react';
import { Link } from 'react-router-dom';
import type { OnElementHandler } from '@/mastodon/utils/html';
export interface HandledLinkProps {
href: string;
text: string;
hashtagAccountId?: string;
mentionAccountId?: string;
}
export const HandledLink: FC<HandledLinkProps & ComponentProps<'a'>> = ({
href,
text,
hashtagAccountId,
mentionAccountId,
...props
}) => {
// Handle hashtags
if (text.startsWith('#')) {
const hashtag = text.slice(1).trim();
return (
<Link
{...props}
className='mention hashtag'
to={`/tags/${hashtag}`}
rel='tag'
data-menu-hashtag={hashtagAccountId}
>
#<span>{hashtag}</span>
</Link>
);
} else if (text.startsWith('@')) {
// Handle mentions
const mention = text.slice(1).trim();
return (
<Link
{...props}
className='mention'
to={`/@${mention}`}
title={`@${mention}`}
data-hover-card-account={mentionAccountId}
>
@<span>{mention}</span>
</Link>
);
}
// Non-absolute paths treated as internal links.
if (href.startsWith('/')) {
return (
<Link {...props} className='unhandled-link' to={href}>
{text}
</Link>
);
}
try {
const url = new URL(href);
const [first, ...rest] = url.pathname.split('/').slice(1); // Start at 1 to skip the leading slash.
return (
<a
{...props}
href={href}
title={href}
className='unhandled-link'
target='_blank'
rel='noreferrer noopener'
translate='no'
>
<span className='invisible'>{url.protocol + '//'}</span>
<span className='ellipsis'>{`${url.hostname}/${first ?? ''}`}</span>
<span className='invisible'>{'/' + rest.join('/')}</span>
</a>
);
} catch {
return text;
}
};
export const useElementHandledLink = ({
hashtagAccountId,
hrefToMentionAccountId,
}: {
hashtagAccountId?: string;
hrefToMentionAccountId?: (href: string) => string | undefined;
} = {}) => {
const onElement = useCallback<OnElementHandler>(
(element, { key, ...props }) => {
if (element instanceof HTMLAnchorElement) {
const mentionId = hrefToMentionAccountId?.(element.href);
return (
<HandledLink
{...props}
key={key as string} // React requires keys to not be part of spread props.
href={element.href}
text={element.innerText}
hashtagAccountId={hashtagAccountId}
mentionAccountId={mentionId}
/>
);
}
return undefined;
},
[hashtagAccountId, hrefToMentionAccountId],
);
return { onElement };
};

View File

@ -3,6 +3,8 @@ import { useCallback, useRef, useId } from 'react';
import { FormattedMessage } from 'react-intl';
import { AnimateEmojiProvider } from './emoji/context';
export enum BannerVariant {
Warning = 'warning',
Filter = 'filter',
@ -34,8 +36,7 @@ export const StatusBanner: React.FC<{
return (
// Element clicks are passed on to button
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div
<AnimateEmojiProvider
className={
variant === BannerVariant.Warning
? 'content-warning'
@ -69,6 +70,6 @@ export const StatusBanner: React.FC<{
/>
)}
</button>
</div>
</AnimateEmojiProvider>
);
};

View File

@ -18,6 +18,7 @@ import { languages as preloadedLanguages } from 'mastodon/initial_state';
import { isModernEmojiEnabled } from '../utils/environment';
import { EmojiHTML } from './emoji/html';
import { HandledLink } from './status/handled_link';
const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
@ -27,9 +28,6 @@ const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
* @returns {string}
*/
export function getStatusContent(status) {
if (isModernEmojiEnabled()) {
return status.getIn(['translation', 'content']) || status.get('content');
}
return status.getIn(['translation', 'contentHtml']) || status.get('contentHtml');
}
@ -99,6 +97,23 @@ class StatusContent extends PureComponent {
}
const { status, onCollapsedToggle } = this.props;
if (status.get('collapsed', null) === null && onCollapsedToggle) {
const { collapsible, onClick } = this.props;
const collapsed =
collapsible
&& onClick
&& node.clientHeight > MAX_HEIGHT
&& status.get('spoiler_text').length === 0;
onCollapsedToggle(collapsed);
}
// Exit if modern emoji is enabled, as it handles links using the HandledLink component.
if (isModernEmojiEnabled()) {
return;
}
const links = node.querySelectorAll('a');
let link, mention;
@ -128,18 +143,6 @@ class StatusContent extends PureComponent {
link.classList.add('unhandled-link');
}
}
if (status.get('collapsed', null) === null && onCollapsedToggle) {
const { collapsible, onClick } = this.props;
const collapsed =
collapsible
&& onClick
&& node.clientHeight > MAX_HEIGHT
&& status.get('spoiler_text').length === 0;
onCollapsedToggle(collapsed);
}
}
componentDidMount () {
@ -201,6 +204,25 @@ class StatusContent extends PureComponent {
this.node = c;
};
handleElement = (element, { key, ...props }) => {
if (element instanceof HTMLAnchorElement) {
const mention = this.props.status.get('mentions').find(item => element.href === item.get('url'));
return (
<HandledLink
{...props}
href={element.href}
text={element.innerText}
hashtagAccountId={this.props.status.getIn(['account', 'id'])}
mentionAccountId={mention?.get('id')}
key={key}
/>
);
} else if (element instanceof HTMLParagraphElement && element.classList.contains('quote-inline')) {
return null;
}
return undefined;
}
render () {
const { status, intl, statusContent } = this.props;
@ -245,6 +267,7 @@ class StatusContent extends PureComponent {
lang={language}
htmlString={content}
extraEmojis={status.get('emojis')}
onElement={this.handleElement.bind(this)}
/>
{poll}
@ -262,6 +285,7 @@ class StatusContent extends PureComponent {
lang={language}
htmlString={content}
extraEmojis={status.get('emojis')}
onElement={this.handleElement.bind(this)}
/>
{poll}

View File

@ -1,10 +1,17 @@
import { EmojiHTML } from '@/mastodon/components/emoji/html';
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
import { isModernEmojiEnabled } from '../utils/environment';
import type { OnAttributeHandler } from '../utils/html';
import { Icon } from './icon';
const domParser = new DOMParser();
const stripRelMe = (html: string) => {
if (isModernEmojiEnabled()) {
return html;
}
const document = domParser.parseFromString(html, 'text/html').documentElement;
document.querySelectorAll<HTMLAnchorElement>('a[rel]').forEach((link) => {
@ -15,7 +22,23 @@ const stripRelMe = (html: string) => {
});
const body = document.querySelector('body');
return body ? { __html: body.innerHTML } : undefined;
return body?.innerHTML ?? '';
};
const onAttribute: OnAttributeHandler = (name, value, tagName) => {
if (name === 'rel' && tagName === 'a') {
if (value === 'me') {
return null;
}
return [
name,
value
.split(' ')
.filter((x) => x !== 'me')
.join(' '),
];
}
return undefined;
};
interface Props {
@ -24,6 +47,10 @@ interface Props {
export const VerifiedBadge: React.FC<Props> = ({ link }) => (
<span className='verified-badge'>
<Icon id='check' icon={CheckIcon} className='verified-badge__mark' />
<span dangerouslySetInnerHTML={stripRelMe(link)} />
<EmojiHTML
as='span'
htmlString={stripRelMe(link)}
onAttribute={onAttribute}
/>
</span>
);

View File

@ -7,9 +7,9 @@ import { Helmet } from 'react-helmet';
import { NavLink } from 'react-router-dom';
import { AccountBio } from '@/mastodon/components/account_bio';
import { AccountFields } from '@/mastodon/components/account_fields';
import { DisplayName } from '@/mastodon/components/display_name';
import { AnimateEmojiProvider } from '@/mastodon/components/emoji/context';
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
import LockIcon from '@/material-icons/400-24px/lock.svg?react';
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
import NotificationsIcon from '@/material-icons/400-24px/notifications.svg?react';
@ -186,14 +186,6 @@ const titleFromAccount = (account: Account) => {
return `${prefix} (@${acct})`;
};
const dateFormatOptions: Intl.DateTimeFormatOptions = {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
};
export const AccountHeader: React.FC<{
accountId: string;
hideTabs?: boolean;
@ -891,46 +883,7 @@ export const AccountHeader: React.FC<{
</dd>
</dl>
{fields.map((pair, i) => (
<dl
key={i}
className={classNames({
verified: pair.verified_at,
})}
>
<dt
dangerouslySetInnerHTML={{
__html: pair.name_emojified,
}}
title={pair.name}
className='translate'
/>
<dd className='translate' title={pair.value_plain ?? ''}>
{pair.verified_at && (
<span
title={intl.formatMessage(messages.linkVerifiedOn, {
date: intl.formatDate(
pair.verified_at,
dateFormatOptions,
),
})}
>
<Icon
id='check'
icon={CheckIcon}
className='verified__mark'
/>
</span>
)}{' '}
<span
dangerouslySetInnerHTML={{
__html: pair.value_emojified,
}}
/>
</dd>
</dl>
))}
<AccountFields fields={fields} emojis={account.emojis} />
</div>
</div>

View File

@ -50,9 +50,7 @@ export const EditIndicator = () => {
<EmbeddedStatusContent
className='edit-indicator__content translate'
content={status.get('contentHtml')}
language={status.get('language')}
mentions={status.get('mentions')}
status={status}
/>
{(status.get('poll') || status.get('media_attachments').size > 0) && (

View File

@ -35,9 +35,7 @@ export const ReplyIndicator = () => {
<EmbeddedStatusContent
className='reply-indicator__content translate'
content={status.get('contentHtml')}
language={status.get('language')}
mentions={status.get('mentions')}
status={status}
/>
{(status.get('poll') || status.get('media_attachments').size > 0) && (

View File

@ -10,10 +10,13 @@ import {
insertEmojiCompose,
uploadCompose,
} from 'mastodon/actions/compose';
import { pasteLinkCompose } from 'mastodon/actions/compose_typed';
import { openModal } from 'mastodon/actions/modal';
import ComposeForm from '../components/compose_form';
const urlLikeRegex = /^https?:\/\/[^\s]+\/[^\s]+$/i;
const mapStateToProps = state => ({
text: state.getIn(['compose', 'text']),
suggestions: state.getIn(['compose', 'suggestions']),
@ -71,8 +74,21 @@ const mapDispatchToProps = (dispatch, props) => ({
dispatch(changeComposeSpoilerText(checked));
},
onPaste (files) {
dispatch(uploadCompose(files));
onPaste (e) {
if (e.clipboardData && e.clipboardData.files.length === 1) {
dispatch(uploadCompose(e.clipboardData.files));
e.preventDefault();
} else if (e.clipboardData && e.clipboardData.files.length === 0) {
const data = e.clipboardData.getData('text/plain');
if (!data.match(urlLikeRegex)) return;
try {
const url = new URL(data);
dispatch(pasteLinkCompose({ url }));
} catch {
return;
}
}
},
onPickEmoji (position, data, needsSpace) {

View File

@ -2,6 +2,7 @@ import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router-dom';
import { EmojiHTML } from '@/mastodon/components/emoji/html';
import { Avatar } from 'mastodon/components/avatar';
import { DisplayName } from 'mastodon/components/display_name';
import { FollowButton } from 'mastodon/components/follow_button';
@ -39,9 +40,10 @@ export const AccountCard: React.FC<{ accountId: string }> = ({ accountId }) => {
</Link>
{account.get('note').length > 0 && (
<div
className='account-card__bio translate animate-parent'
dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }}
<EmojiHTML
className='account-card__bio translate'
htmlString={account.get('note_emojified')}
extraEmojis={account.get('emojis')}
/>
)}

View File

@ -1,5 +1,6 @@
import Trie from 'substring-trie';
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
import { assetHost } from 'mastodon/utils/config';
import { autoPlayGif } from '../../initial_state';
@ -148,7 +149,17 @@ const emojifyNode = (node, customEmojis) => {
}
};
const emojify = (str, customEmojis = {}) => {
/**
* Legacy emoji processing function.
* @param {string} str
* @param {object} customEmojis
* @param {boolean} force If true, always emojify even if modern emoji is enabled
* @returns {string}
*/
const emojify = (str, customEmojis = {}, force = false) => {
if (isModernEmojiEnabled() && !force) {
return str;
}
const wrapper = document.createElement('div');
wrapper.innerHTML = str;

View File

@ -154,15 +154,21 @@ export function cleanExtraEmojis(extraEmojis?: CustomEmojiMapArg) {
if (!extraEmojis) {
return null;
}
if (!isList(extraEmojis)) {
return extraEmojis;
}
return extraEmojis
.toJSON()
.reduce<ExtraCustomEmojiMap>(
if (Array.isArray(extraEmojis)) {
return extraEmojis.reduce<ExtraCustomEmojiMap>(
(acc, emoji) => ({ ...acc, [emoji.shortcode]: emoji }),
{},
);
}
if (isList(extraEmojis)) {
return extraEmojis
.toJS()
.reduce<ExtraCustomEmojiMap>(
(acc, emoji) => ({ ...acc, [emoji.shortcode]: emoji }),
{},
);
}
return extraEmojis;
}
function hexStringToNumbers(hexString: string): number[] {

View File

@ -56,7 +56,9 @@ export type EmojiStateMap = LimitedCache<string, EmojiState>;
export type CustomEmojiMapArg =
| ExtraCustomEmojiMap
| ImmutableList<CustomEmoji>;
| ImmutableList<CustomEmoji>
| CustomEmoji[]
| ApiCustomEmojiJSON[];
export type ExtraCustomEmojiMap = Record<
string,

View File

@ -10,9 +10,10 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
import { Avatar } from '../../../components/avatar';
import { DisplayName } from '../../../components/display_name';
import { IconButton } from '../../../components/icon_button';
import { Avatar } from '@/mastodon/components/avatar';
import { DisplayName } from '@/mastodon/components/display_name';
import { IconButton } from '@/mastodon/components/icon_button';
import { EmojiHTML } from '@/mastodon/components/emoji/html';
const messages = defineMessages({
authorize: { id: 'follow_request.authorize', defaultMessage: 'Authorize' },
@ -30,7 +31,6 @@ class AccountAuthorize extends ImmutablePureComponent {
render () {
const { intl, account, onAuthorize, onReject } = this.props;
const content = { __html: account.get('note_emojified') };
return (
<div className='account-authorize__wrapper'>
@ -40,7 +40,11 @@ class AccountAuthorize extends ImmutablePureComponent {
<DisplayName account={account} />
</Link>
<div className='account__header__content translate' dangerouslySetInnerHTML={content} />
<EmojiHTML
className='account__header__content translate'
htmlString={account.get('note_emojified')}
extraEmojis={account.get('emojis')}
/>
</div>
<div className='account--panel'>

View File

@ -0,0 +1,119 @@
import { useEffect, useState } from 'react';
import type { FC } from 'react';
import { FormattedDate, FormattedMessage } from 'react-intl';
import type { ApiAnnouncementJSON } from '@/mastodon/api_types/announcements';
import { AnimateEmojiProvider } from '@/mastodon/components/emoji/context';
import { EmojiHTML } from '@/mastodon/components/emoji/html';
import { ReactionsBar } from './reactions';
export interface IAnnouncement extends ApiAnnouncementJSON {
contentHtml: string;
}
interface AnnouncementProps {
announcement: IAnnouncement;
selected: boolean;
}
export const Announcement: FC<AnnouncementProps> = ({
announcement,
selected,
}) => {
const [unread, setUnread] = useState(!announcement.read);
useEffect(() => {
// Only update `unread` marker once the announcement is out of view
if (!selected && unread !== !announcement.read) {
setUnread(!announcement.read);
}
}, [announcement.read, selected, unread]);
return (
<AnimateEmojiProvider className='announcements__item'>
<strong className='announcements__item__range'>
<FormattedMessage
id='announcement.announcement'
defaultMessage='Announcement'
/>
<span>
{' · '}
<Timestamp announcement={announcement} />
</span>
</strong>
<EmojiHTML
className='announcements__item__content translate'
htmlString={announcement.contentHtml}
extraEmojis={announcement.emojis}
/>
<ReactionsBar reactions={announcement.reactions} id={announcement.id} />
{unread && <span className='announcements__item__unread' />}
</AnimateEmojiProvider>
);
};
const Timestamp: FC<Pick<AnnouncementProps, 'announcement'>> = ({
announcement,
}) => {
const startsAt = announcement.starts_at && new Date(announcement.starts_at);
const endsAt = announcement.ends_at && new Date(announcement.ends_at);
const now = new Date();
const hasTimeRange = startsAt && endsAt;
const skipTime = announcement.all_day;
if (hasTimeRange) {
const skipYear =
startsAt.getFullYear() === endsAt.getFullYear() &&
endsAt.getFullYear() === now.getFullYear();
const skipEndDate =
startsAt.getDate() === endsAt.getDate() &&
startsAt.getMonth() === endsAt.getMonth() &&
startsAt.getFullYear() === endsAt.getFullYear();
return (
<>
<FormattedDate
value={startsAt}
year={
skipYear || startsAt.getFullYear() === now.getFullYear()
? undefined
: 'numeric'
}
month='short'
day='2-digit'
hour={skipTime ? undefined : '2-digit'}
minute={skipTime ? undefined : '2-digit'}
/>{' '}
-{' '}
<FormattedDate
value={endsAt}
year={
skipYear || endsAt.getFullYear() === now.getFullYear()
? undefined
: 'numeric'
}
month={skipEndDate ? undefined : 'short'}
day={skipEndDate ? undefined : '2-digit'}
hour={skipTime ? undefined : '2-digit'}
minute={skipTime ? undefined : '2-digit'}
/>
</>
);
}
const publishedAt = new Date(announcement.published_at);
return (
<FormattedDate
value={publishedAt}
year={
publishedAt.getFullYear() === now.getFullYear() ? undefined : 'numeric'
}
month='short'
day='2-digit'
hour={skipTime ? undefined : '2-digit'}
minute={skipTime ? undefined : '2-digit'}
/>
);
};

View File

@ -0,0 +1,118 @@
import { useCallback, useState } from 'react';
import type { FC } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import type { Map, List } from 'immutable';
import ReactSwipeableViews from 'react-swipeable-views';
import elephantUIPlane from '@/images/elephant_ui_plane.svg';
import { CustomEmojiProvider } from '@/mastodon/components/emoji/context';
import { IconButton } from '@/mastodon/components/icon_button';
import LegacyAnnouncements from '@/mastodon/features/getting_started/containers/announcements_container';
import { mascot, reduceMotion } from '@/mastodon/initial_state';
import { createAppSelector, useAppSelector } from '@/mastodon/store';
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
import ChevronLeftIcon from '@/material-icons/400-24px/chevron_left.svg?react';
import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react';
import type { IAnnouncement } from './announcement';
import { Announcement } from './announcement';
const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' },
previous: { id: 'lightbox.previous', defaultMessage: 'Previous' },
next: { id: 'lightbox.next', defaultMessage: 'Next' },
});
const announcementSelector = createAppSelector(
[(state) => state.announcements as Map<string, List<Map<string, unknown>>>],
(announcements) =>
(announcements.get('items')?.toJS() as IAnnouncement[] | undefined) ?? [],
);
export const ModernAnnouncements: FC = () => {
const intl = useIntl();
const announcements = useAppSelector(announcementSelector);
const emojis = useAppSelector((state) => state.custom_emojis);
const [index, setIndex] = useState(0);
const handleChangeIndex = useCallback(
(idx: number) => {
setIndex(idx % announcements.length);
},
[announcements.length],
);
const handleNextIndex = useCallback(() => {
setIndex((prevIndex) => (prevIndex + 1) % announcements.length);
}, [announcements.length]);
const handlePrevIndex = useCallback(() => {
setIndex((prevIndex) =>
prevIndex === 0 ? announcements.length - 1 : prevIndex - 1,
);
}, [announcements.length]);
if (announcements.length === 0) {
return null;
}
return (
<div className='announcements'>
<img
className='announcements__mastodon'
alt=''
draggable='false'
src={mascot ?? elephantUIPlane}
/>
<div className='announcements__container'>
<CustomEmojiProvider emojis={emojis}>
<ReactSwipeableViews
animateHeight
animateTransitions={!reduceMotion}
index={index}
onChangeIndex={handleChangeIndex}
>
{announcements
.map((announcement, idx) => (
<Announcement
key={announcement.id}
announcement={announcement}
selected={index === idx}
/>
))
.reverse()}
</ReactSwipeableViews>
</CustomEmojiProvider>
{announcements.length > 1 && (
<div className='announcements__pagination'>
<IconButton
disabled={announcements.length === 1}
title={intl.formatMessage(messages.previous)}
icon='chevron-left'
iconComponent={ChevronLeftIcon}
onClick={handlePrevIndex}
/>
<span>
{index + 1} / {announcements.length}
</span>
<IconButton
disabled={announcements.length === 1}
title={intl.formatMessage(messages.next)}
icon='chevron-right'
iconComponent={ChevronRightIcon}
onClick={handleNextIndex}
/>
</div>
)}
</div>
</div>
);
};
export const Announcements = isModernEmojiEnabled()
? ModernAnnouncements
: LegacyAnnouncements;

View File

@ -0,0 +1,108 @@
import { useCallback, useMemo } from 'react';
import type { FC, HTMLAttributes } from 'react';
import classNames from 'classnames';
import type { AnimatedProps } from '@react-spring/web';
import { animated, useTransition } from '@react-spring/web';
import { addReaction, removeReaction } from '@/mastodon/actions/announcements';
import type { ApiAnnouncementReactionJSON } from '@/mastodon/api_types/announcements';
import { AnimatedNumber } from '@/mastodon/components/animated_number';
import { Emoji } from '@/mastodon/components/emoji';
import { Icon } from '@/mastodon/components/icon';
import EmojiPickerDropdown from '@/mastodon/features/compose/containers/emoji_picker_dropdown_container';
import { isUnicodeEmoji } from '@/mastodon/features/emoji/utils';
import { useAppDispatch } from '@/mastodon/store';
import AddIcon from '@/material-icons/400-24px/add.svg?react';
export const ReactionsBar: FC<{
reactions: ApiAnnouncementReactionJSON[];
id: string;
}> = ({ reactions, id }) => {
const visibleReactions = useMemo(
() => reactions.filter((x) => x.count > 0),
[reactions],
);
const dispatch = useAppDispatch();
const handleEmojiPick = useCallback(
(emoji: { native: string }) => {
dispatch(addReaction(id, emoji.native.replaceAll(/:/g, '')));
},
[dispatch, id],
);
const transitions = useTransition(visibleReactions, {
from: {
scale: 0,
},
enter: {
scale: 1,
},
leave: {
scale: 0,
},
keys: visibleReactions.map((x) => x.name),
});
return (
<div
className={classNames('reactions-bar', {
'reactions-bar--empty': visibleReactions.length === 0,
})}
>
{transitions(({ scale }, reaction) => (
<Reaction
key={reaction.name}
reaction={reaction}
style={{ transform: scale.to((s) => `scale(${s})`) }}
id={id}
/>
))}
{visibleReactions.length < 8 && (
<EmojiPickerDropdown
onPickEmoji={handleEmojiPick}
button={<Icon id='plus' icon={AddIcon} />}
/>
)}
</div>
);
};
const Reaction: FC<{
reaction: ApiAnnouncementReactionJSON;
id: string;
style: AnimatedProps<HTMLAttributes<HTMLButtonElement>>['style'];
}> = ({ id, reaction, style }) => {
const dispatch = useAppDispatch();
const handleClick = useCallback(() => {
if (reaction.me) {
dispatch(removeReaction(id, reaction.name));
} else {
dispatch(addReaction(id, reaction.name));
}
}, [dispatch, id, reaction.me, reaction.name]);
const code = isUnicodeEmoji(reaction.name)
? reaction.name
: `:${reaction.name}:`;
return (
<animated.button
className={classNames('reactions-bar__item', {
active: reaction.me,
})}
onClick={handleClick}
style={style}
>
<span className='reactions-bar__item__emoji'>
<Emoji code={code} />
</span>
<span className='reactions-bar__item__count'>
<AnimatedNumber value={reaction.count} />
</span>
</animated.button>
);
};

View File

@ -14,7 +14,6 @@ import { SymbolLogo } from 'mastodon/components/logo';
import { fetchAnnouncements, toggleShowAnnouncements } from 'mastodon/actions/announcements';
import { IconWithBadge } from 'mastodon/components/icon_with_badge';
import { NotSignedInIndicator } from 'mastodon/components/not_signed_in_indicator';
import AnnouncementsContainer from 'mastodon/features/getting_started/containers/announcements_container';
import { identityContextPropShape, withIdentity } from 'mastodon/identity_context';
import { criticalUpdatesPending } from 'mastodon/initial_state';
import { withBreakpoint } from 'mastodon/features/ui/hooks/useBreakpoint';
@ -27,6 +26,7 @@ import StatusListContainer from '../ui/containers/status_list_container';
import { ColumnSettings } from './components/column_settings';
import { CriticalUpdateBanner } from './components/critical_update_banner';
import { Announcements } from './components/announcements';
const messages = defineMessages({
title: { id: 'column.home', defaultMessage: 'Home' },
@ -162,7 +162,7 @@ class HomeTimeline extends PureComponent {
pinned={pinned}
multiColumn={multiColumn}
extraButton={announcementsButton}
appendContent={hasAnnouncements && showAnnouncements && <AnnouncementsContainer />}
appendContent={hasAnnouncements && showAnnouncements && <Announcements />}
>
<ColumnSettings />
</ColumnHeader>

View File

@ -6,6 +6,7 @@ import { useHistory } from 'react-router-dom';
import type { List as ImmutableList, RecordOf } from 'immutable';
import type { ApiMentionJSON } from '@/mastodon/api_types/statuses';
import { AnimateEmojiProvider } from '@/mastodon/components/emoji/context';
import BarChart4BarsIcon from '@/material-icons/400-24px/bar_chart_4_bars.svg?react';
import PhotoLibraryIcon from '@/material-icons/400-24px/photo_library.svg?react';
@ -18,7 +19,7 @@ import { useAppSelector, useAppDispatch } from 'mastodon/store';
import { EmbeddedStatusContent } from './embedded_status_content';
export type Mention = RecordOf<{ url: string; acct: string }>;
export type Mention = RecordOf<ApiMentionJSON>;
export const EmbeddedStatus: React.FC<{ statusId: string }> = ({
statusId,
@ -86,12 +87,9 @@ export const EmbeddedStatus: React.FC<{ statusId: string }> = ({
}
// Assign status attributes to variables with a forced type, as status is not yet properly typed
const contentHtml = status.get('contentHtml') as string;
const contentWarning = status.get('spoilerHtml') as string;
const hasContentWarning = !!status.get('spoiler_text');
const poll = status.get('poll');
const language = status.get('language') as string;
const mentions = status.get('mentions') as ImmutableList<Mention>;
const expanded = !status.get('hidden') || !contentWarning;
const expanded = !status.get('hidden') || !hasContentWarning;
const mediaAttachmentsSize = (
status.get('media_attachments') as ImmutableList<unknown>
).size;
@ -109,20 +107,16 @@ export const EmbeddedStatus: React.FC<{ statusId: string }> = ({
<DisplayName account={account} />
</div>
{contentWarning && (
<ContentWarning
text={contentWarning}
onClick={handleContentWarningClick}
expanded={expanded}
/>
)}
<ContentWarning
status={status}
onClick={handleContentWarningClick}
expanded={expanded}
/>
{(!contentWarning || expanded) && (
{(!hasContentWarning || expanded) && (
<EmbeddedStatusContent
className='notification-group__embedded-status__content reply-indicator__content translate'
content={contentHtml}
language={language}
mentions={mentions}
status={status}
/>
)}

View File

@ -1,4 +1,4 @@
import { useCallback } from 'react';
import { useCallback, useMemo } from 'react';
import { useHistory } from 'react-router-dom';
@ -6,16 +6,22 @@ import type { List } from 'immutable';
import type { History } from 'history';
import type { ApiMentionJSON } from '@/mastodon/api_types/statuses';
import { EmojiHTML } from '@/mastodon/components/emoji/html';
import { useElementHandledLink } from '@/mastodon/components/status/handled_link';
import type { Status } from '@/mastodon/models/status';
import { isModernEmojiEnabled } from '@/mastodon/utils/environment';
import type { Mention } from './embedded_status';
const handleMentionClick = (
history: History,
mention: Mention,
mention: ApiMentionJSON,
e: MouseEvent,
) => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
history.push(`/@${mention.get('acct')}`);
history.push(`/@${mention.acct}`);
}
};
@ -31,16 +37,26 @@ const handleHashtagClick = (
};
export const EmbeddedStatusContent: React.FC<{
content: string;
mentions: List<Mention>;
language: string;
status: Status;
className?: string;
}> = ({ content, mentions, language, className }) => {
}> = ({ status, className }) => {
const history = useHistory();
const mentions = useMemo(
() => (status.get('mentions') as List<Mention>).toJS(),
[status],
);
const htmlHandlers = useElementHandledLink({
hashtagAccountId: status.get('account') as string | undefined,
hrefToMentionAccountId(href) {
const mention = mentions.find((item) => item.url === href);
return mention?.id;
},
});
const handleContentRef = useCallback(
(node: HTMLDivElement | null) => {
if (!node) {
if (!node || isModernEmojiEnabled()) {
return;
}
@ -53,7 +69,7 @@ export const EmbeddedStatusContent: React.FC<{
link.classList.add('status-link');
const mention = mentions.find((item) => link.href === item.get('url'));
const mention = mentions.find((item) => link.href === item.url);
if (mention) {
link.addEventListener(
@ -61,8 +77,8 @@ export const EmbeddedStatusContent: React.FC<{
handleMentionClick.bind(null, history, mention),
false,
);
link.setAttribute('title', `@${mention.get('acct')}`);
link.setAttribute('href', `/@${mention.get('acct')}`);
link.setAttribute('title', `@${mention.acct}`);
link.setAttribute('href', `/@${mention.acct}`);
} else if (
link.textContent.startsWith('#') ||
link.previousSibling?.textContent?.endsWith('#')
@ -83,11 +99,12 @@ export const EmbeddedStatusContent: React.FC<{
);
return (
<div
<EmojiHTML
{...htmlHandlers}
className={className}
ref={handleContentRef}
lang={language}
dangerouslySetInnerHTML={{ __html: content }}
lang={status.get('language') as string}
htmlString={status.get('contentHtml') as string}
/>
);
};

View File

@ -394,17 +394,13 @@ export const DetailedStatus: React.FC<{
/>
)}
{status.get('spoiler_text').length > 0 &&
(!matchedFilters || showDespiteFilter) && (
<ContentWarning
text={
status.getIn(['translation', 'spoilerHtml']) ||
status.get('spoilerHtml')
}
expanded={expanded}
onClick={handleExpandedToggle}
/>
)}
{(!matchedFilters || showDespiteFilter) && (
<ContentWarning
status={status}
expanded={expanded}
onClick={handleExpandedToggle}
/>
)}
{expanded && (
<>

View File

@ -5,6 +5,8 @@ import { useIntl, defineMessages } from 'react-intl';
import {
fetchContext,
completeContextRefresh,
showPendingReplies,
clearPendingReplies,
} from 'mastodon/actions/statuses';
import type { AsyncRefreshHeader } from 'mastodon/api';
import { apiGetAsyncRefresh } from 'mastodon/api/async_refreshes';
@ -34,10 +36,6 @@ const messages = defineMessages({
id: 'status.context.loading',
defaultMessage: 'Loading',
},
loadingMore: {
id: 'status.context.loading_more',
defaultMessage: 'Loading more replies',
},
success: {
id: 'status.context.loading_success',
defaultMessage: 'All replies loaded',
@ -52,36 +50,33 @@ const messages = defineMessages({
},
});
type LoadingState =
| 'idle'
| 'more-available'
| 'loading-initial'
| 'loading-more'
| 'success'
| 'error';
type LoadingState = 'idle' | 'more-available' | 'loading' | 'success' | 'error';
export const RefreshController: React.FC<{
statusId: string;
}> = ({ statusId }) => {
const refresh = useAppSelector(
(state) => state.contexts.refreshing[statusId],
);
const currentReplyCount = useAppSelector(
(state) => state.contexts.replies[statusId]?.length ?? 0,
);
const autoRefresh = !currentReplyCount;
const dispatch = useAppDispatch();
const intl = useIntl();
const [loadingState, setLoadingState] = useState<LoadingState>(
refresh && autoRefresh ? 'loading-initial' : 'idle',
const refreshHeader = useAppSelector(
(state) => state.contexts.refreshing[statusId],
);
const hasPendingReplies = useAppSelector(
(state) => !!state.contexts.pendingReplies[statusId]?.length,
);
const [partialLoadingState, setLoadingState] = useState<LoadingState>(
refreshHeader ? 'loading' : 'idle',
);
const loadingState = hasPendingReplies
? 'more-available'
: partialLoadingState;
const [wasDismissed, setWasDismissed] = useState(false);
const dismissPrompt = useCallback(() => {
setWasDismissed(true);
setLoadingState('idle');
}, []);
dispatch(clearPendingReplies({ statusId }));
}, [dispatch, statusId]);
useEffect(() => {
let timeoutId: ReturnType<typeof setTimeout>;
@ -89,36 +84,51 @@ export const RefreshController: React.FC<{
const scheduleRefresh = (refresh: AsyncRefreshHeader) => {
timeoutId = setTimeout(() => {
void apiGetAsyncRefresh(refresh.id).then((result) => {
if (result.async_refresh.status === 'finished') {
dispatch(completeContextRefresh({ statusId }));
if (result.async_refresh.result_count > 0) {
if (autoRefresh) {
void dispatch(fetchContext({ statusId })).then(() => {
setLoadingState('idle');
});
} else {
setLoadingState('more-available');
}
} else {
setLoadingState('idle');
}
} else {
// If the refresh status is not finished,
// schedule another refresh and exit
if (result.async_refresh.status !== 'finished') {
scheduleRefresh(refresh);
return;
}
// Refresh status is finished. The action below will clear `refreshHeader`
dispatch(completeContextRefresh({ statusId }));
// Exit if there's nothing to fetch
if (result.async_refresh.result_count === 0) {
setLoadingState('idle');
return;
}
// A positive result count means there _might_ be new replies,
// so we fetch the context in the background to check if there
// are any new replies.
// If so, they will populate `contexts.pendingReplies[statusId]`
void dispatch(fetchContext({ statusId, prefetchOnly: true }))
.then(() => {
// Reset loading state to `idle` but if the fetch
// has resulted in new pending replies, the `hasPendingReplies`
// flag will switch the loading state to 'more-available'
setLoadingState('idle');
})
.catch(() => {
// Show an error if the fetch failed
setLoadingState('error');
});
});
}, refresh.retry * 1000);
};
if (refresh && !wasDismissed) {
scheduleRefresh(refresh);
setLoadingState('loading-initial');
// Initialise a refresh
if (refreshHeader && !wasDismissed) {
scheduleRefresh(refreshHeader);
setLoadingState('loading');
}
return () => {
clearTimeout(timeoutId);
};
}, [dispatch, statusId, refresh, autoRefresh, wasDismissed]);
}, [dispatch, statusId, refreshHeader, wasDismissed]);
useEffect(() => {
// Hide success message after a short delay
@ -134,20 +144,19 @@ export const RefreshController: React.FC<{
return () => '';
}, [loadingState]);
const handleClick = useCallback(() => {
setLoadingState('loading-more');
dispatch(fetchContext({ statusId }))
.then(() => {
setLoadingState('success');
return '';
})
.catch(() => {
setLoadingState('error');
});
useEffect(() => {
// Clear pending replies on unmount
return () => {
dispatch(clearPendingReplies({ statusId }));
};
}, [dispatch, statusId]);
if (loadingState === 'loading-initial') {
const handleClick = useCallback(() => {
dispatch(showPendingReplies({ statusId }));
setLoadingState('success');
}, [dispatch, statusId]);
if (loadingState === 'loading') {
return (
<div
className='load-more load-gap'
@ -170,13 +179,6 @@ export const RefreshController: React.FC<{
onDismiss={dismissPrompt}
animateFrom='below'
/>
<AnimatedAlert
isLoading
withEntryDelay
isActive={loadingState === 'loading-more'}
message={intl.formatMessage(messages.loadingMore)}
animateFrom='below'
/>
<AnimatedAlert
withEntryDelay
isActive={loadingState === 'error'}

View File

@ -603,7 +603,7 @@ class Status extends ImmutablePureComponent {
/>
<ScrollContainer scrollKey='thread' shouldUpdateScroll={this.shouldUpdateScroll} childRef={this.setContainerRef}>
<div className={classNames('scrollable item-list', { fullscreen })} ref={this.setContainerRef}>
<div className={classNames('item-list scrollable scrollable--flex', { fullscreen })} ref={this.setContainerRef}>
{ancestors}
<Hotkeys handlers={handlers}>

View File

@ -15,6 +15,8 @@ import InlineAccount from 'mastodon/components/inline_account';
import MediaAttachments from 'mastodon/components/media_attachments';
import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
import emojify from 'mastodon/features/emoji/emoji';
import { EmojiHTML } from '@/mastodon/components/emoji/html';
import { CustomEmojiProvider } from '@/mastodon/components/emoji/context';
const mapStateToProps = (state, { statusId }) => ({
language: state.getIn(['statuses', statusId, 'language']),
@ -51,8 +53,8 @@ class CompareHistoryModal extends PureComponent {
return obj;
}, {});
const content = { __html: emojify(currentVersion.get('content'), emojiMap) };
const spoilerContent = { __html: emojify(escapeTextContentForBrowser(currentVersion.get('spoiler_text')), emojiMap) };
const content = emojify(currentVersion.get('content'), emojiMap);
const spoilerContent = emojify(escapeTextContentForBrowser(currentVersion.get('spoiler_text')), emojiMap);
const formattedDate = <RelativeTimestamp timestamp={currentVersion.get('created_at')} short={false} />;
const formattedName = <InlineAccount accountId={currentVersion.get('account')} />;
@ -65,43 +67,50 @@ class CompareHistoryModal extends PureComponent {
return (
<div className='modal-root__modal compare-history-modal'>
<div className='report-modal__target'>
<IconButton className='report-modal__close' icon='times' iconComponent={CloseIcon} onClick={onClose} size={20} />
{label}
</div>
<div className='compare-history-modal__container'>
<div className='status__content'>
{currentVersion.get('spoiler_text').length > 0 && (
<>
<div className='translate' dangerouslySetInnerHTML={spoilerContent} lang={language} />
<hr />
</>
)}
<div className='status__content__text status__content__text--visible translate' dangerouslySetInnerHTML={content} lang={language} />
{!!currentVersion.get('poll') && (
<div className='poll'>
<ul>
{currentVersion.getIn(['poll', 'options']).map(option => (
<li key={option.get('title')}>
<span className='poll__input disabled' />
<span
className='poll__option__text translate'
dangerouslySetInnerHTML={{ __html: emojify(escapeTextContentForBrowser(option.get('title')), emojiMap) }}
lang={language}
/>
</li>
))}
</ul>
</div>
)}
<MediaAttachments status={currentVersion} lang={language} />
<CustomEmojiProvider emojis={currentVersion.get('emojis')}>
<div className='report-modal__target'>
<IconButton className='report-modal__close' icon='times' iconComponent={CloseIcon} onClick={onClose} size={20} />
{label}
</div>
</div>
<div className='compare-history-modal__container'>
<div className='status__content'>
{currentVersion.get('spoiler_text').length > 0 && (
<>
<EmojiHTML className='translate' htmlString={spoilerContent} lang={language} />
<hr />
</>
)}
<EmojiHTML
className='status__content__text status__content__text--visible translate'
htmlString={content}
lang={language}
/>
{!!currentVersion.get('poll') && (
<div className='poll'>
<ul>
{currentVersion.getIn(['poll', 'options']).map(option => (
<li key={option.get('title')}>
<span className='poll__input disabled' />
<EmojiHTML
as="span"
className='poll__option__text translate'
htmlString={emojify(escapeTextContentForBrowser(option.get('title')), emojiMap)}
lang={language}
/>
</li>
))}
</ul>
</div>
)}
<MediaAttachments status={currentVersion} lang={language} />
</div>
</div>
</CustomEmojiProvider>
</div>
);
}

View File

@ -7,6 +7,8 @@ import { isFulfilled, isRejected } from '@reduxjs/toolkit';
import { openURL } from 'mastodon/actions/search';
import { useAppDispatch } from 'mastodon/store';
import { isModernEmojiEnabled } from '../utils/environment';
const isMentionClick = (element: HTMLAnchorElement) =>
element.classList.contains('mention') &&
!element.classList.contains('hashtag');
@ -53,6 +55,11 @@ export const useLinks = (skipHashtags?: boolean) => {
const handleClick = useCallback(
(e: React.MouseEvent) => {
// Exit early if modern emoji is enabled, as this is handled by HandledLink.
if (isModernEmojiEnabled()) {
return;
}
const target = (e.target as HTMLElement).closest('a');
if (!target || e.button !== 0 || e.ctrlKey || e.metaKey) {

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Утрымлівае цытату",
"status.context.loading": "Загружаюцца іншыя адказы",
"status.context.loading_error": "Немагчыма загрузіць новыя адказы",
"status.context.loading_more": "Загружаюцца іншыя адказы",
"status.context.loading_success": "Усе адказы загружаныя",
"status.context.more_replies_found": "Знойдзеныя іншыя адказы",
"status.context.retry": "Паспрабаваць зноў",

View File

@ -28,6 +28,7 @@
"account.disable_notifications": "Paouez d'am c'hemenn pa vez embannet traoù gant @{name}",
"account.domain_blocking": "Domani stanket",
"account.edit_profile": "Kemmañ ar profil",
"account.edit_profile_short": "Kemmañ",
"account.enable_notifications": "Ma c'hemenn pa vez embannet traoù gant @{name}",
"account.endorse": "Lakaat en a-raok war ar profil",
"account.familiar_followers_one": "Heuliet gant {name1}",
@ -39,6 +40,7 @@
"account.featured_tags.last_status_never": "Embann ebet",
"account.follow": "Heuliañ",
"account.follow_back": "Heuliañ d'ho tro",
"account.follow_request_cancel_short": "Nullañ",
"account.followers": "Tud koumanantet",
"account.followers.empty": "Den na heul an implijer·ez-mañ c'hoazh.",
"account.followers_counter": "{count, plural, one {{counter} heulier} two {{counter} heulier} few {{counter} heulier} many {{counter} heulier} other {{counter} heulier}}",
@ -216,7 +218,12 @@
"confirmations.remove_from_followers.title": "Dilemel an heulier·ez?",
"confirmations.revoke_quote.confirm": "Dilemel an embannadur",
"confirmations.revoke_quote.title": "Dilemel an embannadur?",
"confirmations.unblock.confirm": "Distankañ",
"confirmations.unblock.title": "Distankañ {name}?",
"confirmations.unfollow.confirm": "Diheuliañ",
"confirmations.unfollow.title": "Diheuliañ {name}?",
"confirmations.withdraw_request.confirm": "Nullañ ar reked",
"confirmations.withdraw_request.title": "Nullañ ho reked da heuliañ {name}?",
"content_warning.hide": "Kuzhat an embannadur",
"content_warning.show": "Diskwel memes tra",
"content_warning.show_more": "Diskouez muioc'h",

View File

@ -871,7 +871,6 @@
"status.contains_quote": "Conté una cita",
"status.context.loading": "Es carreguen més respostes",
"status.context.loading_error": "No s'han pogut carregar respostes noves",
"status.context.loading_more": "Es carreguen més respostes",
"status.context.loading_success": "S'han carregat totes les respostes",
"status.context.more_replies_found": "S'han trobat més respostes",
"status.context.retry": "Torna-ho a provar",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Obsahuje citaci",
"status.context.loading": "Načítání dalších odpovědí",
"status.context.loading_error": "Nelze načíst nové odpovědi",
"status.context.loading_more": "Načítání dalších odpovědí",
"status.context.loading_success": "Všechny odpovědi načteny",
"status.context.more_replies_found": "Nalezeny další odpovědi",
"status.context.retry": "Zkusit znovu",

View File

@ -870,7 +870,6 @@
"status.contains_quote": "Yn cynnwys dyfyniad",
"status.context.loading": "Yn llwytho mwy o atebion",
"status.context.loading_error": "Wedi methu llwytho atebion newydd",
"status.context.loading_more": "Yn llwytho mwy o atebion",
"status.context.loading_success": "Wedi llwytho'r holl atebion",
"status.context.more_replies_found": "Mwy o atebion wedi'u canfod",
"status.context.retry": "Ceisio eto",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Indeholder citat",
"status.context.loading": "Indlæser flere svar",
"status.context.loading_error": "Kunne ikke indlæse nye svar",
"status.context.loading_more": "Indlæser flere svar",
"status.context.loading_success": "Alle svar indlæst",
"status.context.more_replies_found": "Flere svar fundet",
"status.context.retry": "Prøv igen",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Enthält Zitat",
"status.context.loading": "Weitere Antworten laden",
"status.context.loading_error": "Weitere Antworten konnten nicht geladen werden",
"status.context.loading_more": "Weitere Antworten laden",
"status.context.loading_success": "Alle weiteren Antworten geladen",
"status.context.more_replies_found": "Weitere Antworten verfügbar",
"status.context.retry": "Erneut versuchen",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Περιέχει παράθεση",
"status.context.loading": "Φόρτωση περισσότερων απαντήσεων",
"status.context.loading_error": "Αδυναμία φόρτωσης νέων απαντήσεων",
"status.context.loading_more": "Φόρτωση περισσότερων απαντήσεων",
"status.context.loading_success": "Όλες οι απαντήσεις φορτώθηκαν",
"status.context.more_replies_found": "Βρέθηκαν περισσότερες απαντήσεις",
"status.context.retry": "Επανάληψη",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Contains quote",
"status.context.loading": "Loading more replies",
"status.context.loading_error": "Couldn't load new replies",
"status.context.loading_more": "Loading more replies",
"status.context.loading_success": "All replies loaded",
"status.context.more_replies_found": "More replies found",
"status.context.retry": "Retry",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Contiene cita",
"status.context.loading": "Cargando más respuestas",
"status.context.loading_error": "No se pudieron cargar nuevas respuestas",
"status.context.loading_more": "Cargando más respuestas",
"status.context.loading_success": "Se cargaron todas las respuestas",
"status.context.more_replies_found": "Se encontraron más respuestas",
"status.context.retry": "Reintentar",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Contiene cita",
"status.context.loading": "Cargando más respuestas",
"status.context.loading_error": "No se pudieron cargar nuevas respuestas",
"status.context.loading_more": "Cargando más respuestas",
"status.context.loading_success": "Todas las respuestas cargadas",
"status.context.more_replies_found": "Se han encontrado más respuestas",
"status.context.retry": "Reintentar",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Contiene cita",
"status.context.loading": "Cargando más respuestas",
"status.context.loading_error": "No se pudieron cargar nuevas respuestas",
"status.context.loading_more": "Cargando más respuestas",
"status.context.loading_success": "Se cargaron todas las respuestas",
"status.context.more_replies_found": "Se encontraron más respuestas",
"status.context.retry": "Reintentar",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Sisaldab tsitaati",
"status.context.loading": "Laadin veel vastuseid",
"status.context.loading_error": "Uute vastuste laadimine ei õnnestunud",
"status.context.loading_more": "Laadin veel vastuseid",
"status.context.loading_success": "Kõik vastused on laaditud",
"status.context.more_replies_found": "Leidub veel vastuseid",
"status.context.retry": "Proovi uuesti",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Sisältää lainauksen",
"status.context.loading": "Ladataan lisää vastauksia",
"status.context.loading_error": "Ei voitu ladata lisää vastauksia",
"status.context.loading_more": "Ladataan lisää vastauksia",
"status.context.loading_success": "Kaikki vastaukset ladattu",
"status.context.more_replies_found": "Löytyi lisää vastauksia",
"status.context.retry": "Yritä uudelleen",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Inniheldur sitat",
"status.context.loading": "Tekur fleiri svar niður",
"status.context.loading_error": "Fekk ikki tikið nýggj svar niður",
"status.context.loading_more": "Tekur fleiri svar niður",
"status.context.loading_success": "Øll svar tikin niður",
"status.context.more_replies_found": "Fleiri svar funnin",
"status.context.retry": "Royn aftur",

View File

@ -251,7 +251,12 @@
"confirmations.revoke_quote.confirm": "Retirer la publication",
"confirmations.revoke_quote.message": "Cette action ne peut pas être annulée.",
"confirmations.revoke_quote.title": "Retirer la publication ?",
"confirmations.unblock.confirm": "Débloquer",
"confirmations.unblock.title": "Débloquer {name} ?",
"confirmations.unfollow.confirm": "Ne plus suivre",
"confirmations.unfollow.title": "Ne plus suivre {name} ?",
"confirmations.withdraw_request.confirm": "Rejeter la demande",
"confirmations.withdraw_request.title": "Rejeter la demande de suivre {name} ?",
"content_warning.hide": "Masquer le message",
"content_warning.show": "Montrer quand même",
"content_warning.show_more": "Montrer plus",
@ -861,6 +866,13 @@
"status.cancel_reblog_private": "Débooster",
"status.cannot_quote": "Vous n'êtes pas autorisé à citer ce message",
"status.cannot_reblog": "Cette publication ne peut pas être boostée",
"status.contains_quote": "Contient la citation",
"status.context.loading": "Chargement de réponses supplémentaires",
"status.context.loading_error": "Impossible de charger les nouvelles réponses",
"status.context.loading_success": "Toutes les réponses sont chargées",
"status.context.more_replies_found": "Plus de réponses trouvées",
"status.context.retry": "Réessayer",
"status.context.show": "Montrer",
"status.continued_thread": "Suite du fil",
"status.copy": "Copier un lien vers cette publication",
"status.delete": "Supprimer",
@ -890,17 +902,22 @@
"status.quote": "Citer",
"status.quote.cancel": "Annuler la citation",
"status.quote_error.filtered": "Caché en raison de l'un de vos filtres",
"status.quote_error.limited_account_hint.action": "Afficher quand même",
"status.quote_error.limited_account_hint.title": "Ce profil a été masqué par la modération de {domain}.",
"status.quote_error.not_available": "Publication non disponible",
"status.quote_error.pending_approval": "Publication en attente",
"status.quote_error.pending_approval_popout.body": "Sur Mastodon, vous pouvez contrôler si quelqu'un peut vous citer. Ce message est en attente pendant que nous recevons l'approbation de l'auteur original.",
"status.quote_error.revoked": "Post supprimé par l'auteur",
"status.quote_followers_only": "Seul·e·s les abonné·e·s peuvent citer cette publication",
"status.quote_manual_review": "L'auteur va vérifier manuellement",
"status.quote_noun": "Citation",
"status.quote_policy_change": "Changer qui peut vous citer",
"status.quote_post_author": "A cité un message par @{name}",
"status.quote_private": "Les publications privées ne peuvent pas être citées",
"status.quotes": " {count, plural, one {quote} other {quotes}}",
"status.quotes.empty": "Personne n'a encore cité ce message. Quand quelqu'un le fera, il apparaîtra ici.",
"status.quotes.local_other_disclaimer": "Les citations rejetées par l'auteur ne seront pas affichées.",
"status.quotes.remote_other_disclaimer": "Seules les citations de {domain} sont garanties d'être affichées ici. Les citations rejetées par l'auteur ne seront pas affichées.",
"status.read_more": "En savoir plus",
"status.reblog": "Booster",
"status.reblog_or_quote": "Boost ou citation",

View File

@ -251,7 +251,12 @@
"confirmations.revoke_quote.confirm": "Retirer la publication",
"confirmations.revoke_quote.message": "Cette action ne peut pas être annulée.",
"confirmations.revoke_quote.title": "Retirer la publication ?",
"confirmations.unblock.confirm": "Débloquer",
"confirmations.unblock.title": "Débloquer {name} ?",
"confirmations.unfollow.confirm": "Ne plus suivre",
"confirmations.unfollow.title": "Ne plus suivre {name} ?",
"confirmations.withdraw_request.confirm": "Rejeter la demande",
"confirmations.withdraw_request.title": "Rejeter la demande de suivre {name} ?",
"content_warning.hide": "Masquer le message",
"content_warning.show": "Montrer quand même",
"content_warning.show_more": "Montrer plus",
@ -861,6 +866,13 @@
"status.cancel_reblog_private": "Annuler le partage",
"status.cannot_quote": "Vous n'êtes pas autorisé à citer ce message",
"status.cannot_reblog": "Ce message ne peut pas être partagé",
"status.contains_quote": "Contient la citation",
"status.context.loading": "Chargement de réponses supplémentaires",
"status.context.loading_error": "Impossible de charger les nouvelles réponses",
"status.context.loading_success": "Toutes les réponses sont chargées",
"status.context.more_replies_found": "Plus de réponses trouvées",
"status.context.retry": "Réessayer",
"status.context.show": "Montrer",
"status.continued_thread": "Suite du fil",
"status.copy": "Copier le lien vers le message",
"status.delete": "Supprimer",
@ -890,17 +902,22 @@
"status.quote": "Citer",
"status.quote.cancel": "Annuler la citation",
"status.quote_error.filtered": "Caché en raison de l'un de vos filtres",
"status.quote_error.limited_account_hint.action": "Afficher quand même",
"status.quote_error.limited_account_hint.title": "Ce profil a été masqué par la modération de {domain}.",
"status.quote_error.not_available": "Publication non disponible",
"status.quote_error.pending_approval": "Publication en attente",
"status.quote_error.pending_approval_popout.body": "Sur Mastodon, vous pouvez contrôler si quelqu'un peut vous citer. Ce message est en attente pendant que nous recevons l'approbation de l'auteur original.",
"status.quote_error.revoked": "Post supprimé par l'auteur",
"status.quote_followers_only": "Seul·e·s les abonné·e·s peuvent citer cette publication",
"status.quote_manual_review": "L'auteur va vérifier manuellement",
"status.quote_noun": "Citation",
"status.quote_policy_change": "Changer qui peut vous citer",
"status.quote_post_author": "A cité un message par @{name}",
"status.quote_private": "Les publications privées ne peuvent pas être citées",
"status.quotes": " {count, plural, one {quote} other {quotes}}",
"status.quotes.empty": "Personne n'a encore cité ce message. Quand quelqu'un le fera, il apparaîtra ici.",
"status.quotes.local_other_disclaimer": "Les citations rejetées par l'auteur ne seront pas affichées.",
"status.quotes.remote_other_disclaimer": "Seules les citations de {domain} sont garanties d'être affichées ici. Les citations rejetées par l'auteur ne seront pas affichées.",
"status.read_more": "Lire la suite",
"status.reblog": "Partager",
"status.reblog_or_quote": "Boost ou citation",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Tá luachan ann",
"status.context.loading": "Ag lódáil tuilleadh freagraí",
"status.context.loading_error": "Níorbh fhéidir freagraí nua a lódáil",
"status.context.loading_more": "Ag lódáil tuilleadh freagraí",
"status.context.loading_success": "Luchtaithe na freagraí uile",
"status.context.more_replies_found": "Tuilleadh freagraí aimsithe",
"status.context.retry": "Déan iarracht arís",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Contén unha cita",
"status.context.loading": "Cargando máis respostas",
"status.context.loading_error": "Non se puideron mostrar novas respostas",
"status.context.loading_more": "Cargando máis respostas",
"status.context.loading_success": "Móstranse todas as respostas",
"status.context.more_replies_found": "Existen máis respostas",
"status.context.retry": "Volver tentar",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "הודעה מכילה ציטוט",
"status.context.loading": "נטענות תשובות נוספות",
"status.context.loading_error": "טעינת תשובות נוספות נכשלה",
"status.context.loading_more": "נטענות תשובות נוספות",
"status.context.loading_success": "כל התשובות נטענו",
"status.context.more_replies_found": "תשובות נוספות נמצאו",
"status.context.retry": "נסה שוב",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Idézést tartalmaz",
"status.context.loading": "Több válasz betöltése",
"status.context.loading_error": "Az új válaszok nem tölthetőek be",
"status.context.loading_more": "Több válasz betöltése",
"status.context.loading_success": "Összes válasz betöltve",
"status.context.more_replies_found": "Több válasz található",
"status.context.retry": "Újra",

View File

@ -870,7 +870,6 @@
"status.contains_quote": "Contine un citation",
"status.context.loading": "Cargante plus responsas",
"status.context.loading_error": "Non poteva cargar nove responsas",
"status.context.loading_more": "Cargante plus responsas",
"status.context.loading_success": "Tote le responsas cargate",
"status.context.more_replies_found": "Plus responsas trovate",
"status.context.retry": "Tentar de novo",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Inniheldur tilvitnun",
"status.context.loading": "Hleð inn fleiri svörum",
"status.context.loading_error": "Gat ekki hlaðið inn nýjum svörum",
"status.context.loading_more": "Hleð inn fleiri svörum",
"status.context.loading_success": "Öllum svörum hlaðið inn",
"status.context.more_replies_found": "Fleiri svör fundust",
"status.context.retry": "Reyna aftur",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Contiene una citazione",
"status.context.loading": "Caricamento di altre risposte",
"status.context.loading_error": "Impossibile caricare nuove risposte",
"status.context.loading_more": "Caricamento di altre risposte",
"status.context.loading_success": "Tutte le risposte caricate",
"status.context.more_replies_found": "Sono state trovate altre risposte",
"status.context.retry": "Riprova",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "包含引用",
"status.context.loading": "載入其他回應",
"status.context.loading_error": "Bē當載入新回應",
"status.context.loading_more": "載入其他回應",
"status.context.loading_success": "回應lóng載入ah",
"status.context.more_replies_found": "Tshuē-tio̍h其他回應",
"status.context.retry": "Koh試",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Bevat citaat",
"status.context.loading": "Meer reacties laden",
"status.context.loading_error": "Kon geen nieuwe reacties laden",
"status.context.loading_more": "Meer reacties laden",
"status.context.loading_success": "Alle reacties zijn geladen",
"status.context.more_replies_found": "Meer reacties gevonden",
"status.context.retry": "Opnieuw proberen",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Inneheld eit sitat",
"status.context.loading": "Lastar fleire svar",
"status.context.loading_error": "Kunne ikkje lasta nye svar",
"status.context.loading_more": "Lastar fleire svar",
"status.context.loading_success": "Alle svara er lasta",
"status.context.more_replies_found": "Fann fleire svar",
"status.context.retry": "Prøv om att",

View File

@ -870,7 +870,6 @@
"status.contains_quote": "Contém citação",
"status.context.loading": "A carregar mais respostas",
"status.context.loading_error": "Não foi possível carregar novas respostas",
"status.context.loading_more": "A carregar mais respostas",
"status.context.loading_success": "Todas as respostas carregadas",
"status.context.more_replies_found": "Foram encontradas mais respostas",
"status.context.retry": "Repetir",

View File

@ -28,6 +28,7 @@
"account.disable_notifications": "Resht së njoftuari mua, kur poston @{name}",
"account.domain_blocking": "Bllokim përkatësie",
"account.edit_profile": "Përpunoni profilin",
"account.edit_profile_short": "Përpunojeni",
"account.enable_notifications": "Njoftomë, kur poston @{name}",
"account.endorse": "Pasqyrojeni në profil",
"account.familiar_followers_many": "Ndjekur nga {name1}, {name2} dhe {othersCount, plural, one {një tjetër që njihni} other {# të tjerë që njihni}}",
@ -40,6 +41,11 @@
"account.featured_tags.last_status_never": "Pa postime",
"account.follow": "Ndiqeni",
"account.follow_back": "Ndiqe gjithashtu",
"account.follow_back_short": "Ndiqe gjithashtu",
"account.follow_request": "Kërkoni ta ndiqni",
"account.follow_request_cancel": "Anuloje kërkesën",
"account.follow_request_cancel_short": "Anuloje",
"account.follow_request_short": "Kërkoje",
"account.followers": "Ndjekës",
"account.followers.empty": "Këtë përdorues ende se ndjek kush.",
"account.followers_counter": "{count, plural, one {{counter} ndjekës} other {{counter} ndjekës}}",
@ -233,13 +239,25 @@
"confirmations.missing_alt_text.secondary": "Postoje, sido qoftë",
"confirmations.missing_alt_text.title": "Të shtohet tekst alternativ?",
"confirmations.mute.confirm": "Heshtoje",
"confirmations.quiet_post_quote_info.dismiss": "Mos ma kujto më",
"confirmations.quiet_post_quote_info.got_it": "E mora vesh",
"confirmations.quiet_post_quote_info.message": "Kur citoni një postim publik të heshtuar, postimi juaj do të kalohet i fshehur te rrjedha kohore e gjërave në modë.",
"confirmations.quiet_post_quote_info.title": "Citim postimesh publikë të heshtuar",
"confirmations.redraft.confirm": "Fshijeni & rihartojeni",
"confirmations.redraft.message": "Jeni i sigurt se doni të fshihet kjo gjendje dhe të rihartohet? Të parapëlqyerit dhe përforcimet do të humbin, ndërsa përgjigjet te postimi origjinal do të bëhen jetime.",
"confirmations.redraft.title": "Të fshihet & riharothet postimi?",
"confirmations.remove_from_followers.confirm": "Hiqe ndjekësin",
"confirmations.remove_from_followers.message": "{name} do të reshtë së ndjekuri ju. Jeni i sigurt se doni të vazhdohet?",
"confirmations.remove_from_followers.title": "Të hiqet ndjekësi?",
"confirmations.revoke_quote.confirm": "Hiqe postimin",
"confirmations.revoke_quote.message": "Ky veprim smund të zhbëhet.",
"confirmations.revoke_quote.title": "Të hiqet postimi?",
"confirmations.unblock.confirm": "Zhbllokoje",
"confirmations.unblock.title": "Të zhbllojohet {name}?",
"confirmations.unfollow.confirm": "Resht së ndjekuri",
"confirmations.unfollow.title": "Të ndalet ndjekja për {name}?",
"confirmations.withdraw_request.confirm": "Tërhiqeni mbrapsht kërkesën",
"confirmations.withdraw_request.title": "Të tërhiqet mbrapsht kërkesa për ndjeken e {name}?",
"content_warning.hide": "Fshihe postimin",
"content_warning.show": "Shfaqe, sido qoftë",
"content_warning.show_more": "Shfaq më tepër",
@ -437,10 +455,12 @@
"ignore_notifications_modal.private_mentions_title": "Të shpërfillen njoftime nga Përmendje Private të pakërkuara?",
"info_button.label": "Ndihmë",
"info_button.what_is_alt_text": "<h1>Çështë teksti alternativ?</h1> <p>Teksti alternativ jep përshkrime figurash për persona me mangësi në të parët, lidhje me gjerësi bande të ulët, ose për ata që duan kontekst shtesë.</p> <p>Mund të përmirësoni përdorimin nga persona me aftësi të kufizuara dhe kuptimin për këto, duke shkruar tekst alternativ të qartë, konciz dhe objektiv.</p> <ul> <li>Rrokni elementët e rëndësishëm</li> <li>Përmblidhni tekst në figura</li> <li>Përdorni strukturë të rregullt fjalish</li> <li>Shmangni përsëritje informacioni</li> <li>Në aspekte pamore të ndërlikuara (fjala vjen, diagrame ose harta) përqendrohuni te prirje dhe gjetje gjërash kyçe</li> </ul>",
"interaction_modal.action": "Që të ndërveproni me postimin nga {name}, lypset të bëni hyrjen në llogarinë tuaj, ose në çfarëdo shërbyesi Mastodon që përdorni.",
"interaction_modal.go": "Shko",
"interaction_modal.no_account_yet": "Skeni ende një llogari?",
"interaction_modal.on_another_server": "Në një tjetër shërbyes",
"interaction_modal.on_this_server": "Në këtë shërbyes",
"interaction_modal.title": "Që të vazhdohet, bëni hyrjen",
"interaction_modal.username_prompt": "P.sh., {example}",
"intervals.full.days": "{number, plural, one {# ditë} other {# ditë}}",
"intervals.full.hours": "{number, plural, one {# orë} other {# orë}}",
@ -461,6 +481,7 @@
"keyboard_shortcuts.home": "Për hapje rrjedhe kohore vetjake",
"keyboard_shortcuts.hotkey": "Tast përkatës",
"keyboard_shortcuts.legend": "Për shfaqje të kësaj legjende",
"keyboard_shortcuts.load_more": "Kaloje fokusin te butoni “Ngarko më tepër”",
"keyboard_shortcuts.local": "Për hapje rrjedhe kohore vendore",
"keyboard_shortcuts.mention": "Për përmendje të autorit",
"keyboard_shortcuts.muted": "Për hapje liste përdoruesish të heshtuar",
@ -469,6 +490,7 @@
"keyboard_shortcuts.open_media": "Për hapje mediash",
"keyboard_shortcuts.pinned": "Për hapje liste mesazhesh të fiksuar",
"keyboard_shortcuts.profile": "Për hapje të profilit të autorit",
"keyboard_shortcuts.quote": "Citoni postim",
"keyboard_shortcuts.reply": "Për tiu përgjigjur një postimi",
"keyboard_shortcuts.requests": "Për hapje liste kërkesash për ndjekje",
"keyboard_shortcuts.search": "Për kalim fokusi te kërkimi",
@ -480,6 +502,8 @@
"keyboard_shortcuts.translate": "për të përkthyer një postim",
"keyboard_shortcuts.unfocus": "Për heqjen e fokusit nga fusha e hartimit të mesazheve apo kërkimeve",
"keyboard_shortcuts.up": "Për ngjitje sipër nëpër listë",
"learn_more_link.got_it": "E mora vesh",
"learn_more_link.learn_more": "Mësoni më tepër",
"lightbox.close": "Mbylle",
"lightbox.next": "Pasuesja",
"lightbox.previous": "E mëparshmja",
@ -578,6 +602,7 @@
"notification.label.mention": "Përmendje",
"notification.label.private_mention": "Përmendje private",
"notification.label.private_reply": "Përgjigje private",
"notification.label.quote": "{name} citoi postimin tuaj",
"notification.label.reply": "Përgjigje",
"notification.mention": "Përmendje",
"notification.mentioned_you": "{name} ju ka përmendur",
@ -592,6 +617,7 @@
"notification.moderation_warning.action_suspend": "Llogaria juaj është pezulluar.",
"notification.own_poll": "Pyetësori juaj ka përfunduar",
"notification.poll": "Ka përfunduar një pyetësor në të cilin keni marrë pjesë",
"notification.quoted_update": "{name} përpunoi një postim që keni cituar",
"notification.reblog": "{name} përforcoi mesazhin tuaj",
"notification.reblog.name_and_others_with_link": "Ju ka përforcuar {name} dhe <a>{count, plural, one {# tjetër} other {# të tjerë}}</a>",
"notification.relationships_severance_event": "Lidhje të humbura me {name}",
@ -635,6 +661,7 @@
"notifications.column_settings.mention": "Përmendje:",
"notifications.column_settings.poll": "Përfundime pyetësori:",
"notifications.column_settings.push": "Njoftime Push",
"notifications.column_settings.quote": "Ctime:",
"notifications.column_settings.reblog": "Përforcime:",
"notifications.column_settings.show": "Shfaqi në shtylla",
"notifications.column_settings.sound": "Luaj një tingull",
@ -711,6 +738,7 @@
"privacy.public.long": "Cilido që hyn e del në Mastodon",
"privacy.public.short": "Publik",
"privacy.unlisted.additional": "Ky sillet saktësisht si publik, vetëm se postimi sdo të shfaqet në prurje të drejtpërdrejta, ose në hashtag-ë, te eksploroni, apo kërkim në Mastodon, edhe kur keni zgjedhur të jetë për tërë llogarinë.",
"privacy.unlisted.long": "Fshehur nga përfundime kërkimi në Mastodon, rrjedha kohore gjërash në modë dhe publike",
"privacy.unlisted.short": "Publik i qetë",
"privacy_policy.last_updated": "Përditësuar së fundi më {date}",
"privacy_policy.title": "Rregulla Privatësie",
@ -729,6 +757,9 @@
"relative_time.minutes": "{number}m",
"relative_time.seconds": "{number}s",
"relative_time.today": "sot",
"remove_quote_hint.button_label": "E mora vesh",
"remove_quote_hint.message": "Këtë mund ta bëni një menuja e mundësive {icon}.",
"remove_quote_hint.title": "Doni të hiqet postimi juaj i cituar?",
"reply_indicator.attachments": "{count, plural, one {# bashkëngjitje} other {# bashkëngjitje}}",
"reply_indicator.cancel": "Anuloje",
"reply_indicator.poll": "Pyetësor",
@ -823,10 +854,19 @@
"status.block": "Blloko @{name}",
"status.bookmark": "Faqeruaje",
"status.cancel_reblog_private": "Shpërforcojeni",
"status.cannot_quote": "Skeni leje të citoni këtë postim",
"status.cannot_reblog": "Ky postim smund të përforcohet",
"status.contains_quote": "Përmban citim",
"status.context.loading": "Po ngarkohen më tepër përgjigje",
"status.context.loading_error": "Su ngarkuan dot përgjigje të reja",
"status.context.loading_success": "Janë ngarkuar krejt përgjigjet",
"status.context.more_replies_found": "U gjetën më tepër përgjigje",
"status.context.retry": "Riprovoni",
"status.context.show": "Shfaqe",
"status.continued_thread": "Vazhdoi rrjedhën",
"status.copy": "Kopjoje lidhjen për te mesazhi",
"status.delete": "Fshije",
"status.delete.success": "Postimi u fshi",
"status.detailed_status": "Pamje e hollësishme bisede",
"status.direct": "Përmendje private për @{name}",
"status.direct_indicator": "Përmendje private",
@ -850,19 +890,38 @@
"status.open": "Zgjeroje këtë mesazh",
"status.pin": "Fiksoje në profil",
"status.quote_error.filtered": "Fshehur për shkak të njërit nga filtrat tuaj",
"status.quote_error.limited_account_hint.action": "Shfaqe, sido qoftë",
"status.quote_error.limited_account_hint.title": "Kjo llogari është fshehur nga moderatorët e {domain}.",
"status.quote_error.not_available": "Postim që smund të kihet",
"status.quote_error.pending_approval": "Postim pezull",
"status.quote_error.pending_approval_popout.body": "Në Mastodon mundeni të kontrolloni nëse dikush ju citon a jo. Ky postim është pezull, teksa po marrim miratimin e autorit origjinal.",
"status.quote_error.revoked": "Postim i hequr nga autori",
"status.quote_followers_only": "Këtë postim mund ta citojnë vetëm ndjekës",
"status.quote_manual_review": "Autori do ta shqyrtojë dorazi",
"status.quote_noun": "Citim",
"status.quote_post_author": "U citua një postim nga @{name}",
"status.quotes": "{count, plural, one {citim} other {citime}}",
"status.quotes.empty": "Këtë postim ende se ka cituar kush. Kur dikush ta bëjë, do të shfaqet këtu.",
"status.quotes.local_other_disclaimer": "Citimet e hedhura poshtë nga autori sdo të shfaqen.",
"status.quotes.remote_other_disclaimer": "Këtu garantohet të shfaqen vetëm citime nga {domain}. Citime të hedhura poshtë nga autori sdo të shfaqen.",
"status.read_more": "Lexoni më tepër",
"status.reblog": "Përforcojeni",
"status.reblog_or_quote": "Përforconi ose citoni",
"status.reblog_private": "Rindajeni me ndjekësit tuaj",
"status.reblogged_by": "{name} përforcoi",
"status.reblogs": "{count, plural, one {përforcim} other {përforcime}}",
"status.reblogs.empty": "Këtë mesazh se ka përforcuar njeri deri tani. Kur ta bëjë dikush, kjo do të duket këtu.",
"status.redraft": "Fshijeni & rihartojeni",
"status.remove_bookmark": "Hiqe faqerojtësin",
"status.remove_favourite": "Hiqe nga të parapëlqyerat",
"status.remove_quote": "Hiqe",
"status.replied_in_thread": "U përgjigj te rrjedha",
"status.replied_to": "Iu përgjigj {name}",
"status.reply": "Përgjigjuni",
"status.replyAll": "Përgjigjuni rrjedhës",
"status.report": "Raportojeni @{name}",
"status.request_quote": "Kërkoni të citohet",
"status.revoke_quote": "Hiqe postimin tim nga postimi i @{name}",
"status.sensitive_warning": "Lëndë rezervat",
"status.share": "Ndajeni me të tjerë",
"status.show_less_all": "Shfaq më pak për të tërë",
@ -922,5 +981,14 @@
"video.skip_forward": "Anashkalo pasardhësen",
"video.unmute": "Hiqi heshtimin",
"video.volume_down": "Ulje volumi",
"video.volume_up": "Ngritje volumi"
"video.volume_up": "Ngritje volumi",
"visibility_modal.helper.direct_quoting": "Përmendje private të krijuara në Mastodon smund të citohen nga të tjerë.",
"visibility_modal.helper.privacy_editing": "Dukshmëria smund të ndryshohet pasi postimi botohet.",
"visibility_modal.helper.privacy_private_self_quote": "Citimet nga ju vetë të postime private smund të bëhen publike.",
"visibility_modal.helper.private_quoting": "Postime vetëm për ndjekësit, të krijuara në Mastodon smund të citohen nga të tjerë.",
"visibility_modal.instructions": "Kontrolloni cilët mund të ndërveprojnë me këtë postim. Rregullime mund të aplikooni edhe mbi krejt postimet e ardshme, që nga <link>Parapëlqime > Parazgjedhje postimi</link>.",
"visibility_modal.privacy_label": "Dukshmëri",
"visibility_modal.quote_label": "Cilët mund të citojnë",
"visibility_modal.quote_nobody": "Thjesht unë",
"visibility_modal.save": "Ruaje"
}

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Alıntı içeriyor",
"status.context.loading": "Daha fazla yanıt yükleniyor",
"status.context.loading_error": "Yeni yanıtlar yüklenemiyor",
"status.context.loading_more": "Daha fazla yanıt yükleniyor",
"status.context.loading_success": "Tüm yanıtlar yüklendi",
"status.context.more_replies_found": "Daha fazla yanıt bulundu",
"status.context.retry": "Yeniden dene",
@ -923,6 +922,8 @@
"status.quote_private": "Özel gönderiler alıntılanamaz",
"status.quotes": "{count, plural, one {# alıntı} other {# alıntı}}",
"status.quotes.empty": "Henüz hiç kimse bu gönderiyi alıntılamadı. Herhangi bir kullanıcı alıntıladığında burada görüntülenecek.",
"status.quotes.local_other_disclaimer": "Yazar tarafından reddedilen alıntılar gösterilmez.",
"status.quotes.remote_other_disclaimer": "Yalnızca {domain} adresinden gelen alıntılar burada gösterilir. Yazar tarafından reddedilen alıntılar gösterilmez.",
"status.read_more": "Devamını okuyun",
"status.reblog": "Yeniden paylaş",
"status.reblog_or_quote": "Yükselt veya alıntıla",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "Chứa trích dẫn",
"status.context.loading": "Tải thêm các trả lời",
"status.context.loading_error": "Không thể tải những trả lời mới",
"status.context.loading_more": "Tải thêm các trả lời",
"status.context.loading_success": "Đã tải toàn bộ trả lời",
"status.context.more_replies_found": "Có trả lời mới",
"status.context.retry": "Thử lại",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "包含引用",
"status.context.loading": "正在加载更多回复",
"status.context.loading_error": "无法加载新回复",
"status.context.loading_more": "正在加载更多回复",
"status.context.loading_success": "已加载所有回复",
"status.context.more_replies_found": "已找到更多回复",
"status.context.retry": "重试",

View File

@ -875,7 +875,6 @@
"status.contains_quote": "包含引用嘟文",
"status.context.loading": "讀取更多回嘟",
"status.context.loading_error": "無法讀取新回嘟",
"status.context.loading_more": "讀取更多回嘟",
"status.context.loading_success": "已讀取所有回嘟",
"status.context.more_replies_found": "已有更多回嘟",
"status.context.retry": "再試一次",

View File

@ -19,7 +19,7 @@ export function loadPolyfills() {
return Promise.all([
loadIntlPolyfills(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- those properties might not exist in old browsers, even if they are always here in types
needsExtraPolyfills && importExtraPolyfills(),
needsExtraPolyfills ? importExtraPolyfills() : Promise.resolve(),
loadEmojiPolyfills(),
]);
}

View File

@ -13,7 +13,12 @@ import type {
import type { Status } from 'mastodon/models/status';
import { blockAccountSuccess, muteAccountSuccess } from '../actions/accounts';
import { fetchContext, completeContextRefresh } from '../actions/statuses';
import {
fetchContext,
completeContextRefresh,
showPendingReplies,
clearPendingReplies,
} from '../actions/statuses';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';
@ -26,52 +31,84 @@ interface TimelineUpdateAction extends UnknownAction {
interface State {
inReplyTos: Record<string, string>;
replies: Record<string, string[]>;
pendingReplies: Record<
string,
Pick<ApiStatusJSON, 'id' | 'in_reply_to_id'>[]
>;
refreshing: Record<string, AsyncRefreshHeader>;
}
const initialState: State = {
inReplyTos: {},
replies: {},
pendingReplies: {},
refreshing: {},
};
const addReply = (
state: Draft<State>,
{ id, in_reply_to_id }: Pick<ApiStatusJSON, 'id' | 'in_reply_to_id'>,
) => {
if (!in_reply_to_id) {
return;
}
if (!state.inReplyTos[id]) {
const siblings = (state.replies[in_reply_to_id] ??= []);
const index = siblings.findIndex((sibling) => compareId(sibling, id) < 0);
siblings.splice(index + 1, 0, id);
state.inReplyTos[id] = in_reply_to_id;
}
};
const normalizeContext = (
state: Draft<State>,
id: string,
{ ancestors, descendants }: ApiContextJSON,
): void => {
const addReply = ({
id,
in_reply_to_id,
}: {
id: string;
in_reply_to_id?: string;
}) => {
if (!in_reply_to_id) {
return;
}
if (!state.inReplyTos[id]) {
const siblings = (state.replies[in_reply_to_id] ??= []);
const index = siblings.findIndex((sibling) => compareId(sibling, id) < 0);
siblings.splice(index + 1, 0, id);
state.inReplyTos[id] = in_reply_to_id;
}
};
ancestors.forEach((item) => {
addReply(state, item);
});
// We know in_reply_to_id of statuses but `id` itself.
// So we assume that the status of the id replies to last ancestors.
ancestors.forEach(addReply);
if (ancestors[0]) {
addReply({
addReply(state, {
id,
in_reply_to_id: ancestors[ancestors.length - 1]?.id,
});
}
descendants.forEach(addReply);
descendants.forEach((item) => {
addReply(state, item);
});
};
const applyPrefetchedReplies = (state: Draft<State>, statusId: string) => {
const pendingReplies = state.pendingReplies[statusId];
if (pendingReplies?.length) {
pendingReplies.forEach((item) => {
addReply(state, item);
});
delete state.pendingReplies[statusId];
}
};
const storePrefetchedReplies = (
state: Draft<State>,
statusId: string,
{ descendants }: ApiContextJSON,
): void => {
descendants.forEach(({ id, in_reply_to_id }) => {
if (!in_reply_to_id) {
return;
}
const isNewReply = !state.replies[in_reply_to_id]?.includes(id);
if (isNewReply) {
const pendingReplies = (state.pendingReplies[statusId] ??= []);
pendingReplies.push({ id, in_reply_to_id });
}
});
};
const deleteFromContexts = (state: Draft<State>, ids: string[]): void => {
@ -129,12 +166,30 @@ const updateContext = (state: Draft<State>, status: ApiStatusJSON): void => {
export const contextsReducer = createReducer(initialState, (builder) => {
builder
.addCase(fetchContext.fulfilled, (state, action) => {
normalizeContext(state, action.meta.arg.statusId, action.payload.context);
if (action.payload.prefetchOnly) {
storePrefetchedReplies(
state,
action.meta.arg.statusId,
action.payload.context,
);
} else {
normalizeContext(
state,
action.meta.arg.statusId,
action.payload.context,
);
if (action.payload.refresh) {
state.refreshing[action.meta.arg.statusId] = action.payload.refresh;
if (action.payload.refresh) {
state.refreshing[action.meta.arg.statusId] = action.payload.refresh;
}
}
})
.addCase(showPendingReplies, (state, action) => {
applyPrefetchedReplies(state, action.payload.statusId);
})
.addCase(clearPendingReplies, (state, action) => {
delete state.pendingReplies[action.payload.statusId];
})
.addCase(completeContextRefresh, (state, action) => {
delete state.refreshing[action.payload.statusId];
})

View File

@ -41,7 +41,7 @@ const popModal = (
modalType === state.get('stack').get(0)?.get('modalType')
) {
return state
.set('ignoreFocus', !!ignoreFocus)
.set('ignoreFocus', ignoreFocus)
.update('stack', (stack) => stack.shift());
} else {
return state;

View File

@ -53,13 +53,19 @@ describe('html', () => {
it('calls onElement callback', () => {
const input = '<p>lorem ipsum</p>';
const onElement = vi.fn(
(element: HTMLElement, children: React.ReactNode[]) =>
React.createElement(element.tagName.toLowerCase(), {}, ...children),
const onElement = vi.fn<html.OnElementHandler>(
(element, props, children) =>
React.createElement(
element.tagName.toLowerCase(),
props,
...children,
),
);
html.htmlStringToComponents(input, { onElement });
expect(onElement).toHaveBeenCalledExactlyOnceWith(
expect.objectContaining({ tagName: 'P' }),
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
expect.objectContaining({ key: expect.any(String) }),
expect.arrayContaining(['lorem ipsum']),
{},
);
@ -71,6 +77,8 @@ describe('html', () => {
const output = html.htmlStringToComponents(input, { onElement });
expect(onElement).toHaveBeenCalledExactlyOnceWith(
expect.objectContaining({ tagName: 'P' }),
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
expect.objectContaining({ key: expect.any(String) }),
expect.arrayContaining(['lorem ipsum']),
{},
);

View File

@ -20,10 +20,7 @@ export function isFeatureEnabled(feature: Features) {
export function isModernEmojiEnabled() {
try {
return (
isFeatureEnabled('modern_emojis') &&
localStorage.getItem('experiments')?.split(',').includes('modern_emojis')
);
return isFeatureEnabled('modern_emojis');
} catch {
return false;
}

View File

@ -32,20 +32,31 @@ interface QueueItem {
depth: number;
}
export interface HTMLToStringOptions<Arg extends Record<string, unknown>> {
export type OnElementHandler<
Arg extends Record<string, unknown> = Record<string, unknown>,
> = (
element: HTMLElement,
props: Record<string, unknown>,
children: React.ReactNode[],
extra: Arg,
) => React.ReactNode;
export type OnAttributeHandler<
Arg extends Record<string, unknown> = Record<string, unknown>,
> = (
name: string,
value: string,
tagName: string,
extra: Arg,
) => [string, unknown] | undefined | null;
export interface HTMLToStringOptions<
Arg extends Record<string, unknown> = Record<string, unknown>,
> {
maxDepth?: number;
onText?: (text: string, extra: Arg) => React.ReactNode;
onElement?: (
element: HTMLElement,
children: React.ReactNode[],
extra: Arg,
) => React.ReactNode;
onAttribute?: (
name: string,
value: string,
tagName: string,
extra: Arg,
) => [string, unknown] | null;
onElement?: OnElementHandler<Arg>;
onAttribute?: OnAttributeHandler<Arg>;
allowedTags?: AllowedTagsType;
extraArgs?: Arg;
}
@ -125,9 +136,57 @@ export function htmlStringToComponents<Arg extends Record<string, unknown>>(
const children: React.ReactNode[] = [];
let element: React.ReactNode = undefined;
// Generate props from attributes.
const key = `html-${uniqueIdCounter++}`; // Get the current key and then increment it.
const props: Record<string, unknown> = { key };
for (const attr of node.attributes) {
let name = attr.name.toLowerCase();
// Custom attribute handler.
if (onAttribute) {
const result = onAttribute(name, attr.value, tagName, extraArgs);
// Rewrite this attribute.
if (result) {
const [cbName, value] = result;
props[cbName] = value;
continue;
} else if (result === null) {
// Explicitly remove this attribute.
continue;
}
}
// Check global attributes first, then tag-specific ones.
const globalAttr = globalAttributes[name];
const tagAttr = tagInfo.attributes?.[name];
// Exit if neither global nor tag-specific attribute is allowed.
if (!globalAttr && !tagAttr) {
continue;
}
// Rename if needed.
if (typeof tagAttr === 'string') {
name = tagAttr;
} else if (typeof globalAttr === 'string') {
name = globalAttr;
}
let value: string | boolean | number = attr.value;
// Handle boolean attributes.
if (value === 'true') {
value = true;
} else if (value === 'false') {
value = false;
}
props[name] = value;
}
// If onElement is provided, use it to create the element.
if (onElement) {
const component = onElement(node, children, extraArgs);
const component = onElement(node, props, children, extraArgs);
// Check for undefined to allow returning null.
if (component !== undefined) {
@ -137,53 +196,6 @@ export function htmlStringToComponents<Arg extends Record<string, unknown>>(
// If the element wasn't created, use the default conversion.
if (element === undefined) {
const props: Record<string, unknown> = {};
props.key = `html-${uniqueIdCounter++}`; // Get the current key and then increment it.
for (const attr of node.attributes) {
let name = attr.name.toLowerCase();
// Custom attribute handler.
if (onAttribute) {
const result = onAttribute(
name,
attr.value,
node.tagName.toLowerCase(),
extraArgs,
);
if (result) {
const [cbName, value] = result;
props[cbName] = value;
}
} else {
// Check global attributes first, then tag-specific ones.
const globalAttr = globalAttributes[name];
const tagAttr = tagInfo.attributes?.[name];
// Exit if neither global nor tag-specific attribute is allowed.
if (!globalAttr && !tagAttr) {
continue;
}
// Rename if needed.
if (typeof tagAttr === 'string') {
name = tagAttr;
} else if (typeof globalAttr === 'string') {
name = globalAttr;
}
let value: string | boolean | number = attr.value;
// Handle boolean attributes.
if (value === 'true') {
value = true;
} else if (value === 'false') {
value = false;
}
props[name] = value;
}
}
element = React.createElement(
tagName,
props,

View File

@ -88,6 +88,14 @@ table + p {
padding: 24px;
}
.email-inner-nested-card-td {
border-radius: 12px;
padding: 18px;
overflow: hidden;
background-color: #fff;
border: 1px solid #dfdee3;
}
// Account
.email-account-banner-table {
background-color: #f3f2f5;
@ -559,12 +567,29 @@ table + p {
}
}
.email-quote-header-img {
width: 34px;
img {
width: 34px;
height: 34px;
border-radius: 8px;
overflow: hidden;
}
}
.email-status-header-text {
padding-left: 16px;
padding-right: 16px;
vertical-align: middle;
}
.email-quote-header-text {
padding-left: 14px;
padding-right: 14px;
vertical-align: middle;
}
.email-status-header-name {
font-size: 16px;
font-weight: 600;
@ -578,6 +603,19 @@ table + p {
color: #746a89;
}
.email-quote-header-name {
font-size: 14px;
font-weight: 600;
line-height: 18px;
color: #17063b;
}
.email-quote-header-handle {
font-size: 13px;
line-height: 18px;
color: #746a89;
}
.email-status-content {
padding-top: 24px;
}
@ -589,6 +627,10 @@ table + p {
}
.email-status-prose {
.quote-inline {
display: none;
}
p {
font-size: 14px;
line-height: 20px;

View File

@ -3153,18 +3153,23 @@ a.account__display-name {
.column__alert {
position: sticky;
bottom: 1rem;
bottom: 0;
z-index: 10;
box-sizing: border-box;
display: grid;
width: 100%;
max-width: 360px;
padding-inline: 10px;
margin-top: 1rem;
margin-inline: auto;
padding: 1rem;
margin: auto auto 0;
overflow: clip;
&:empty {
padding: 0;
}
@media (max-width: #{$mobile-menu-breakpoint - 1}) {
bottom: 4rem;
// Compensate for mobile menubar
bottom: var(--mobile-bottom-nav-height);
}
& > * {

View File

@ -27,17 +27,25 @@ class ActivityPub::Forwarder
@reblogged_by_account_ids ||= @status.reblogs.includes(:account).references(:account).merge(Account.local).pluck(:account_id)
end
def quoted_by_account_ids
@quoted_by_account_ids ||= @status.quotes.includes(:account).references(:account).merge(Account.local).pluck(:account_id)
end
def shared_by_account_ids
reblogged_by_account_ids.concat(quoted_by_account_ids)
end
def signature_account_id
@signature_account_id ||= if in_reply_to_local?
in_reply_to.account_id
else
reblogged_by_account_ids.first
shared_by_account_ids.first
end
end
def inboxes
@inboxes ||= begin
arr = inboxes_for_followers_of_reblogged_by_accounts
arr = inboxes_for_followers_of_shared_by_accounts
arr += inboxes_for_followers_of_replied_to_account if in_reply_to_local?
arr -= [@account.preferred_inbox_url]
arr.uniq!
@ -45,8 +53,8 @@ class ActivityPub::Forwarder
end
end
def inboxes_for_followers_of_reblogged_by_accounts
Account.where(id: ::Follow.where(target_account_id: reblogged_by_account_ids).select(:account_id)).inboxes
def inboxes_for_followers_of_shared_by_accounts
Account.where(id: ::Follow.where(target_account_id: shared_by_account_ids).select(:account_id)).inboxes
end
def inboxes_for_followers_of_replied_to_account

View File

@ -144,7 +144,7 @@ class ActivityPub::Parser::StatusParser
def quote_subpolicy(subpolicy)
flags = 0
allowed_actors = as_array(subpolicy)
allowed_actors = as_array(subpolicy).dup
allowed_actors.uniq!
flags |= Status::QUOTE_APPROVAL_POLICY_FLAGS[:public] if allowed_actors.delete('as:Public') || allowed_actors.delete('Public') || allowed_actors.delete('https://www.w3.org/ns/activitystreams#Public')

View File

@ -0,0 +1,17 @@
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-quote-header-img
= image_tag full_asset_url(status.account.avatar.url), alt: '', width: 34, height: 34
%td.email-quote-header-text
%h2.email-quote-header-name
= display_name(status.account)
%p.email-quote-header-handle
@#{status.account.pretty_acct}
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-status-content
= render 'status_content', status: status
%p.email-status-footer
= link_to l(status.created_at.in_time_zone(time_zone.presence), format: :with_time_zone), web_url("@#{status.account.pretty_acct}/#{status.id}")

View File

@ -11,21 +11,12 @@
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-status-content
.auto-dir
- if status.spoiler_text?
%p.email-status-spoiler
= status.spoiler_text
.email-status-prose
= status_content_format(status)
- if status.ordered_media_attachments.size.positive?
%p.email-status-media
- status.ordered_media_attachments.each do |a|
- if status.local?
= link_to full_asset_url(a.file.url(:original)), full_asset_url(a.file.url(:original))
- else
= link_to a.remote_url, a.remote_url
= render 'status_content', status: status
- if status.local? && status.quote
%table.email-inner-card-table{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-inner-nested-card-td
= render 'nested_quote', status: status.quote.quoted_status, time_zone: time_zone
%p.email-status-footer
= link_to l(status.created_at.in_time_zone(time_zone.presence), format: :with_time_zone), web_url("@#{status.account.pretty_acct}/#{status.id}")

View File

@ -4,5 +4,9 @@
>
<% end %>
> <%= raw word_wrap(extract_status_plain_text(status), break_sequence: "\n> ") %>
<% if status.local? && status.quote %>
>
>> <%= raw word_wrap(extract_status_plain_text(status.quote.quoted_status), break_sequence: "\n>> ") %>
<% end %>
<%= raw t('application_mailer.view')%> <%= web_url("@#{status.account.pretty_acct}/#{status.id}") %>

View File

@ -0,0 +1,15 @@
.auto-dir
- if status.spoiler_text?
%p.email-status-spoiler
= status.spoiler_text
.email-status-prose
= status_content_format(status)
- if status.ordered_media_attachments.size.positive?
%p.email-status-media
- status.ordered_media_attachments.each do |a|
- if status.local?
= link_to full_asset_url(a.file.url(:original)), full_asset_url(a.file.url(:original))
- else
= link_to a.remote_url, a.remote_url

View File

@ -707,7 +707,7 @@ be:
created_at: Створана
delete_and_resolve: Выдаліць допісы
forwarded: Пераслана
forwarded_replies_explanation: Гэтае паведамленне паступіла ад выдаленага карыстальніка і дакранаецца выдаленага змесціва. Яно было накіраванае вам, бо змесціва паведамлення з'яўляецца адказам аднаму з вашых карыстальнікаў.
forwarded_replies_explanation: Гэтае паведамленне паступіла ад карыстальніка з іншага сервера і дакранаецца змесціва адтуль. Яно было накіраванае вам, бо змесціва паведамлення з'яўляецца адказам аднаму з вашых карыстальнікаў.
forwarded_to: Пераслана на %{domain}
mark_as_resolved: Пазначыць як вырашаную
mark_as_sensitive: Пазначыць як далікатны
@ -876,6 +876,10 @@ be:
all: Для ўсіх
disabled: Нікому
users: Лакальным карыстальнікам, якія ўвайшлі
feed_access:
modes:
authenticated: Толькі аўтэнтыфікаваныя карыстальнікі
public: Усе
registrations:
moderation_recommandation: Пераканайцеся, што ў вас ёсць адэкватная і аператыўная каманда мадэратараў, перш чым адчыняць рэгістрацыю для ўсіх жадаючых!
preamble: Кантралюйце, хто можа ствараць уліковы запіс на вашым серверы.

View File

@ -145,6 +145,7 @@ br:
destroy_custom_emoji_html: Dilamet eo bet ar fromlun %{target} gant %{name}
destroy_email_domain_block_html: Distanket eo bet an domani postel %{target} gant %{name}
destroy_status_html: Dilamet eo bet toud %{target} gant %{name}
destroy_user_role_html: Dilamet eo bet ar perzh %{target} gant %{name}
disable_custom_emoji_html: Diweredekaet eo bet ar fromlun %{target} gant %{name}
enable_custom_emoji_html: Gweredekaet eo bet ar fromlun %{target} gant %{name}
resend_user_html: Adkaset eo bet ar postel kadarnaat evit %{target} gant %{name}

View File

@ -876,6 +876,10 @@ cs:
all: Všem
disabled: Nikomu
users: Přihlášeným místním uživatelům
feed_access:
modes:
authenticated: Pouze autentifikovaní uživatelé
public: Všichni
registrations:
moderation_recommandation: Před otevřením registrací všem se ujistěte, že máte vhodný a reaktivní moderační tým!
preamble: Mějte pod kontrolou, kdo může vytvořit účet na vašem serveru.

View File

@ -848,6 +848,10 @@ da:
all: Til alle
disabled: Til ingen
users: Til indloggede lokale brugere
feed_access:
modes:
authenticated: Kun godkendte brugere
public: Alle
registrations:
moderation_recommandation: Sørg for, at der er et tilstrækkeligt og reaktivt moderationsteam, før registrering åbnes for alle!
preamble: Styr, hvem der kan oprette en konto på serveren.
@ -1281,7 +1285,7 @@ da:
account_status: Kontostatus
confirming: Afventer færdiggørelse af e-mailbekræftelse.
functional: Din konto er fuldt funktionel.
pending: Ansøgningen afventer gennemgang af vores personale. Dette kan tage noget tid. Man bør modtage en e-mail, såfremt ansøgningen godkendes.
pending: Ansøgningen afventer gennemgang af vores personale. Dette kan tage noget tid. Du modtager en e-mail, hvis din ansøgning bliver godkendt.
redirecting_to: Din konto er inaktiv, da den pt. er omdirigerer til %{acct}.
self_destruct: Da %{domain} er under nedlukning, vil kontoadgangen være begrænset.
view_strikes: Se tidligere anmeldelser af din konto

View File

@ -848,6 +848,10 @@ de:
all: Allen
disabled: Niemandem
users: Für angemeldete lokale Benutzer*innen
feed_access:
modes:
authenticated: Nur authentifizierte Nutzer*innen
public: Alle
registrations:
moderation_recommandation: Bitte vergewissere dich, dass du ein geeignetes und reaktionsschnelles Moderationsteam hast, bevor du die Registrierungen uneingeschränkt zulässt!
preamble: Lege fest, wer auf deinem Server ein Konto erstellen darf.

View File

@ -848,6 +848,10 @@ el:
all: Για όλους
disabled: Για κανέναν
users: Προς συνδεδεμένους τοπικούς χρήστες
feed_access:
modes:
authenticated: Πιστοποιημένοι χρήστες μόνο
public: Όλοι
registrations:
moderation_recommandation: Παρακαλώ βεβαιώσου ότι έχεις μια επαρκής και ενεργή ομάδα συντονισμού πριν ανοίξεις τις εγγραφές για όλους!
preamble: Έλεγξε ποιος μπορεί να δημιουργήσει ένα λογαριασμό στον διακομιστή σας.

View File

@ -848,6 +848,10 @@ es-AR:
all: A todos
disabled: A nadie
users: A usuarios locales con sesiones abiertas
feed_access:
modes:
authenticated: Solo usuarios autenticados
public: Todos
registrations:
moderation_recommandation: Por favor, ¡asegurate de tener un equipo de moderación adecuado y reactivo antes de abrir los registros a todos!
preamble: Controlá quién puede crear una cuenta en tu servidor.

View File

@ -848,6 +848,10 @@ es-MX:
all: A todos
disabled: A nadie
users: Para los usuarios locales que han iniciado sesión
feed_access:
modes:
authenticated: Solo usuarios autenticados
public: Todos
registrations:
moderation_recommandation: "¡Por favor, asegúrate de contar con un equipo de moderación adecuado y activo antes de abrir el registro al público!"
preamble: Controla quién puede crear una cuenta en tu servidor.

Some files were not shown because too many files have changed in this diff Show More