mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-12 15:33:14 +00:00
Compare commits
4 Commits
80d4ba1005
...
1e31a98055
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1e31a98055 | ||
![]() |
3b52dca405 | ||
![]() |
853a0c466e | ||
![]() |
57de04ea46 |
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class Api::V1::StatusesController < Api::BaseController
|
class Api::V1::StatusesController < Api::BaseController
|
||||||
include Authorization
|
include Authorization
|
||||||
|
include AsyncRefreshesConcern
|
||||||
|
|
||||||
before_action -> { authorize_if_got_token! :read, :'read:statuses' }, except: [:create, :update, :destroy]
|
before_action -> { authorize_if_got_token! :read, :'read:statuses' }, except: [:create, :update, :destroy]
|
||||||
before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:create, :update, :destroy]
|
before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:create, :update, :destroy]
|
||||||
|
@ -57,9 +58,17 @@ class Api::V1::StatusesController < Api::BaseController
|
||||||
@context = Context.new(ancestors: loaded_ancestors, descendants: loaded_descendants)
|
@context = Context.new(ancestors: loaded_ancestors, descendants: loaded_descendants)
|
||||||
statuses = [@status] + @context.ancestors + @context.descendants
|
statuses = [@status] + @context.ancestors + @context.descendants
|
||||||
|
|
||||||
render json: @context, serializer: REST::ContextSerializer, relationships: StatusRelationshipsPresenter.new(statuses, current_user&.account_id)
|
refresh_key = "context:#{@status.id}:refresh"
|
||||||
|
async_refresh = AsyncRefresh.new(refresh_key)
|
||||||
|
|
||||||
ActivityPub::FetchAllRepliesWorker.perform_async(@status.id) if !current_account.nil? && @status.should_fetch_replies?
|
if async_refresh.running?
|
||||||
|
add_async_refresh_header(async_refresh, retry_seconds: 10)
|
||||||
|
elsif !current_account.nil? && @status.should_fetch_replies?
|
||||||
|
add_async_refresh_header(AsyncRefresh.create(refresh_key), retry_seconds: 10)
|
||||||
|
ActivityPub::FetchAllRepliesWorker.perform_async(@status.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: @context, serializer: REST::ContextSerializer, relationships: StatusRelationshipsPresenter.new(statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -26,6 +26,12 @@ module ContextHelper
|
||||||
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
||||||
attribution_domains: { 'toot' => 'http://joinmastodon.org/ns#', 'attributionDomains' => { '@id' => 'toot:attributionDomains', '@type' => '@id' } },
|
attribution_domains: { 'toot' => 'http://joinmastodon.org/ns#', 'attributionDomains' => { '@id' => 'toot:attributionDomains', '@type' => '@id' } },
|
||||||
quote_requests: { 'QuoteRequest' => 'https://w3id.org/fep/044f#QuoteRequest' },
|
quote_requests: { 'QuoteRequest' => 'https://w3id.org/fep/044f#QuoteRequest' },
|
||||||
|
quotes: {
|
||||||
|
'quote' => 'https://w3id.org/fep/044f#quote',
|
||||||
|
'quoteUri' => 'http://fedibird.com/ns#quoteUri',
|
||||||
|
'_misskey_quote' => 'https://misskey-hub.net/ns#_misskey_quote',
|
||||||
|
'quoteAuthorization' => 'https://w3id.org/fep/044f#quoteAuthorization',
|
||||||
|
},
|
||||||
interaction_policies: {
|
interaction_policies: {
|
||||||
'gts' => 'https://gotosocial.org/ns#',
|
'gts' => 'https://gotosocial.org/ns#',
|
||||||
'interactionPolicy' => { '@id' => 'gts:interactionPolicy', '@type' => '@id' },
|
'interactionPolicy' => { '@id' => 'gts:interactionPolicy', '@type' => '@id' },
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { createAction } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
import { apiGetContext } from 'mastodon/api/statuses';
|
import { apiGetContext } from 'mastodon/api/statuses';
|
||||||
import { createDataLoadingThunk } from 'mastodon/store/typed_functions';
|
import { createDataLoadingThunk } from 'mastodon/store/typed_functions';
|
||||||
|
|
||||||
|
@ -6,13 +8,18 @@ import { importFetchedStatuses } from './importer';
|
||||||
export const fetchContext = createDataLoadingThunk(
|
export const fetchContext = createDataLoadingThunk(
|
||||||
'status/context',
|
'status/context',
|
||||||
({ statusId }: { statusId: string }) => apiGetContext(statusId),
|
({ statusId }: { statusId: string }) => apiGetContext(statusId),
|
||||||
(context, { dispatch }) => {
|
({ context, refresh }, { dispatch }) => {
|
||||||
const statuses = context.ancestors.concat(context.descendants);
|
const statuses = context.ancestors.concat(context.descendants);
|
||||||
|
|
||||||
dispatch(importFetchedStatuses(statuses));
|
dispatch(importFetchedStatuses(statuses));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context,
|
context,
|
||||||
|
refresh,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const completeContextRefresh = createAction<{ statusId: string }>(
|
||||||
|
'status/context/complete',
|
||||||
|
);
|
||||||
|
|
|
@ -20,6 +20,50 @@ export const getLinks = (response: AxiosResponse) => {
|
||||||
return LinkHeader.parse(value);
|
return LinkHeader.parse(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface AsyncRefreshHeader {
|
||||||
|
id: string;
|
||||||
|
retry: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isAsyncRefreshHeader = (obj: object): obj is AsyncRefreshHeader =>
|
||||||
|
'id' in obj && 'retry' in obj;
|
||||||
|
|
||||||
|
export const getAsyncRefreshHeader = (
|
||||||
|
response: AxiosResponse,
|
||||||
|
): AsyncRefreshHeader | null => {
|
||||||
|
const value = response.headers['mastodon-async-refresh'] as
|
||||||
|
| string
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const asyncRefreshHeader: Record<string, unknown> = {};
|
||||||
|
|
||||||
|
value.split(/,\s*/).forEach((pair) => {
|
||||||
|
const [key, val] = pair.split('=', 2);
|
||||||
|
|
||||||
|
let typedValue: string | number;
|
||||||
|
|
||||||
|
if (key && ['id', 'retry'].includes(key) && val) {
|
||||||
|
if (val.startsWith('"')) {
|
||||||
|
typedValue = val.slice(1, -1);
|
||||||
|
} else {
|
||||||
|
typedValue = parseInt(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
asyncRefreshHeader[key] = typedValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isAsyncRefreshHeader(asyncRefreshHeader)) {
|
||||||
|
return asyncRefreshHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
const csrfHeader: RawAxiosRequestHeaders = {};
|
const csrfHeader: RawAxiosRequestHeaders = {};
|
||||||
|
|
||||||
const setCSRFHeader = () => {
|
const setCSRFHeader = () => {
|
||||||
|
@ -83,7 +127,7 @@ export default function api(withAuthorization = true) {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
type ApiUrl = `v${1 | 2}/${string}`;
|
type ApiUrl = `v${1 | '1_alpha' | 2}/${string}`;
|
||||||
type RequestParamsOrData = Record<string, unknown>;
|
type RequestParamsOrData = Record<string, unknown>;
|
||||||
|
|
||||||
export async function apiRequest<ApiResponse = unknown>(
|
export async function apiRequest<ApiResponse = unknown>(
|
||||||
|
|
5
app/javascript/mastodon/api/async_refreshes.ts
Normal file
5
app/javascript/mastodon/api/async_refreshes.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { apiRequestGet } from 'mastodon/api';
|
||||||
|
import type { ApiAsyncRefreshJSON } from 'mastodon/api_types/async_refreshes';
|
||||||
|
|
||||||
|
export const apiGetAsyncRefresh = (id: string) =>
|
||||||
|
apiRequestGet<ApiAsyncRefreshJSON>(`v1_alpha/async_refreshes/${id}`);
|
|
@ -1,5 +1,14 @@
|
||||||
import { apiRequestGet } from 'mastodon/api';
|
import api, { getAsyncRefreshHeader } from 'mastodon/api';
|
||||||
import type { ApiContextJSON } from 'mastodon/api_types/statuses';
|
import type { ApiContextJSON } from 'mastodon/api_types/statuses';
|
||||||
|
|
||||||
export const apiGetContext = (statusId: string) =>
|
export const apiGetContext = async (statusId: string) => {
|
||||||
apiRequestGet<ApiContextJSON>(`v1/statuses/${statusId}/context`);
|
const response = await api().request<ApiContextJSON>({
|
||||||
|
method: 'GET',
|
||||||
|
url: `/api/v1/statuses/${statusId}/context`,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
context: response.data,
|
||||||
|
refresh: getAsyncRefreshHeader(response),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
7
app/javascript/mastodon/api_types/async_refreshes.ts
Normal file
7
app/javascript/mastodon/api_types/async_refreshes.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
export interface ApiAsyncRefreshJSON {
|
||||||
|
async_refresh: {
|
||||||
|
id: string;
|
||||||
|
status: 'running' | 'finished';
|
||||||
|
result_count: number;
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,12 +1,30 @@
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import { useLinks } from 'mastodon/hooks/useLinks';
|
import { useLinks } from 'mastodon/hooks/useLinks';
|
||||||
|
|
||||||
export const AccountBio: React.FC<{
|
interface AccountBioProps {
|
||||||
note: string;
|
note: string;
|
||||||
className: string;
|
className: string;
|
||||||
}> = ({ note, className }) => {
|
dropdownAccountId?: string;
|
||||||
const handleClick = useLinks();
|
}
|
||||||
|
|
||||||
if (note.length === 0 || note === '<p></p>') {
|
export const AccountBio: React.FC<AccountBioProps> = ({
|
||||||
|
note,
|
||||||
|
className,
|
||||||
|
dropdownAccountId,
|
||||||
|
}) => {
|
||||||
|
const handleClick = useLinks(!!dropdownAccountId);
|
||||||
|
const handleNodeChange = useCallback(
|
||||||
|
(node: HTMLDivElement | null) => {
|
||||||
|
if (!dropdownAccountId || !node || node.childNodes.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addDropdownToHashtags(node, dropdownAccountId);
|
||||||
|
},
|
||||||
|
[dropdownAccountId],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (note.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +33,28 @@ export const AccountBio: React.FC<{
|
||||||
className={`${className} translate`}
|
className={`${className} translate`}
|
||||||
dangerouslySetInnerHTML={{ __html: note }}
|
dangerouslySetInnerHTML={{ __html: note }}
|
||||||
onClickCapture={handleClick}
|
onClickCapture={handleClick}
|
||||||
|
ref={handleNodeChange}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function addDropdownToHashtags(node: HTMLElement | null, accountId: string) {
|
||||||
|
if (!node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const childNode of node.childNodes) {
|
||||||
|
if (!(childNode instanceof HTMLElement)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
childNode instanceof HTMLAnchorElement &&
|
||||||
|
(childNode.classList.contains('hashtag') ||
|
||||||
|
childNode.innerText.startsWith('#')) &&
|
||||||
|
!childNode.dataset.menuHashtag
|
||||||
|
) {
|
||||||
|
childNode.dataset.menuHashtag = accountId;
|
||||||
|
} else if (childNode.childNodes.length > 0) {
|
||||||
|
addDropdownToHashtags(childNode, accountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import classNames from 'classnames';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { AccountBio } from '@/mastodon/components/account_bio';
|
||||||
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
|
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
|
||||||
import LockIcon from '@/material-icons/400-24px/lock.svg?react';
|
import LockIcon from '@/material-icons/400-24px/lock.svg?react';
|
||||||
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
||||||
|
@ -773,7 +774,6 @@ export const AccountHeader: React.FC<{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = { __html: account.note_emojified };
|
|
||||||
const displayNameHtml = { __html: account.display_name_html };
|
const displayNameHtml = { __html: account.display_name_html };
|
||||||
const fields = account.fields;
|
const fields = account.fields;
|
||||||
const isLocal = !account.acct.includes('@');
|
const isLocal = !account.acct.includes('@');
|
||||||
|
@ -897,12 +897,11 @@ export const AccountHeader: React.FC<{
|
||||||
<AccountNote accountId={accountId} />
|
<AccountNote accountId={accountId} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{account.note.length > 0 && account.note !== '<p></p>' && (
|
<AccountBio
|
||||||
<div
|
note={account.note_emojified}
|
||||||
className='account__header__content translate'
|
dropdownAccountId={accountId}
|
||||||
dangerouslySetInnerHTML={content}
|
className='account__header__content'
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
<div className='account__header__fields'>
|
<div className='account__header__fields'>
|
||||||
<dl>
|
<dl>
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
|
import { useIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import {
|
||||||
|
fetchContext,
|
||||||
|
completeContextRefresh,
|
||||||
|
} from 'mastodon/actions/statuses';
|
||||||
|
import type { AsyncRefreshHeader } from 'mastodon/api';
|
||||||
|
import { apiGetAsyncRefresh } from 'mastodon/api/async_refreshes';
|
||||||
|
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
|
||||||
|
import { useAppSelector, useAppDispatch } from 'mastodon/store';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
loading: {
|
||||||
|
id: 'status.context.loading',
|
||||||
|
defaultMessage: 'Checking for more replies',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const RefreshController: React.FC<{
|
||||||
|
statusId: string;
|
||||||
|
withBorder?: boolean;
|
||||||
|
}> = ({ statusId, withBorder }) => {
|
||||||
|
const refresh = useAppSelector(
|
||||||
|
(state) => state.contexts.refreshing[statusId],
|
||||||
|
);
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let timeoutId: ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
void dispatch(fetchContext({ statusId }));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scheduleRefresh(refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
}, refresh.retry * 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (refresh) {
|
||||||
|
scheduleRefresh(refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
};
|
||||||
|
}, [dispatch, statusId, refresh]);
|
||||||
|
|
||||||
|
if (!refresh) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={classNames('load-more load-gap', {
|
||||||
|
'timeline-hint--with-descendants': withBorder,
|
||||||
|
})}
|
||||||
|
aria-busy
|
||||||
|
aria-live='polite'
|
||||||
|
aria-label={intl.formatMessage(messages.loading)}
|
||||||
|
>
|
||||||
|
<LoadingIndicator />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
|
@ -69,7 +69,7 @@ import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from
|
||||||
|
|
||||||
import ActionBar from './components/action_bar';
|
import ActionBar from './components/action_bar';
|
||||||
import { DetailedStatus } from './components/detailed_status';
|
import { DetailedStatus } from './components/detailed_status';
|
||||||
|
import { RefreshController } from './components/refresh_controller';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
revealAll: { id: 'status.show_more_all', defaultMessage: 'Show more for all' },
|
revealAll: { id: 'status.show_more_all', defaultMessage: 'Show more for all' },
|
||||||
|
@ -549,7 +549,7 @@ class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let ancestors, descendants, remoteHint;
|
let ancestors, descendants, remoteHint;
|
||||||
const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
|
const { isLoading, status, ancestorsIds, descendantsIds, refresh, intl, domain, multiColumn, pictureInPicture } = this.props;
|
||||||
const { fullscreen } = this.state;
|
const { fullscreen } = this.state;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
@ -579,11 +579,9 @@ class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
if (!isLocal) {
|
if (!isLocal) {
|
||||||
remoteHint = (
|
remoteHint = (
|
||||||
<TimelineHint
|
<RefreshController
|
||||||
className={classNames(!!descendants && 'timeline-hint--with-descendants')}
|
statusId={status.get('id')}
|
||||||
url={status.get('url')}
|
withBorder={!!descendants}
|
||||||
message={<FormattedMessage id='hints.threads.replies_may_be_missing' defaultMessage='Replies from other servers may be missing.' />}
|
|
||||||
label={<FormattedMessage id='hints.threads.see_more' defaultMessage='See more replies on {domain}' values={{ domain: <strong>{status.getIn(['account', 'acct']).split('@')[1]}</strong> }} />}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,14 @@ import { openURL } from 'mastodon/actions/search';
|
||||||
import { useAppDispatch } from 'mastodon/store';
|
import { useAppDispatch } from 'mastodon/store';
|
||||||
|
|
||||||
const isMentionClick = (element: HTMLAnchorElement) =>
|
const isMentionClick = (element: HTMLAnchorElement) =>
|
||||||
element.classList.contains('mention');
|
element.classList.contains('mention') &&
|
||||||
|
!element.classList.contains('hashtag');
|
||||||
|
|
||||||
const isHashtagClick = (element: HTMLAnchorElement) =>
|
const isHashtagClick = (element: HTMLAnchorElement) =>
|
||||||
element.textContent?.[0] === '#' ||
|
element.textContent?.[0] === '#' ||
|
||||||
element.previousSibling?.textContent?.endsWith('#');
|
element.previousSibling?.textContent?.endsWith('#');
|
||||||
|
|
||||||
export const useLinks = () => {
|
export const useLinks = (skipHashtags?: boolean) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
@ -61,12 +62,12 @@ export const useLinks = () => {
|
||||||
if (isMentionClick(target)) {
|
if (isMentionClick(target)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
void handleMentionClick(target);
|
void handleMentionClick(target);
|
||||||
} else if (isHashtagClick(target)) {
|
} else if (isHashtagClick(target) && !skipHashtags) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleHashtagClick(target);
|
handleHashtagClick(target);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[handleMentionClick, handleHashtagClick],
|
[skipHashtags, handleMentionClick, handleHashtagClick],
|
||||||
);
|
);
|
||||||
|
|
||||||
return handleClick;
|
return handleClick;
|
||||||
|
|
|
@ -424,8 +424,6 @@
|
||||||
"hints.profiles.see_more_followers": "See more followers on {domain}",
|
"hints.profiles.see_more_followers": "See more followers on {domain}",
|
||||||
"hints.profiles.see_more_follows": "See more follows on {domain}",
|
"hints.profiles.see_more_follows": "See more follows on {domain}",
|
||||||
"hints.profiles.see_more_posts": "See more posts on {domain}",
|
"hints.profiles.see_more_posts": "See more posts on {domain}",
|
||||||
"hints.threads.replies_may_be_missing": "Replies from other servers may be missing.",
|
|
||||||
"hints.threads.see_more": "See more replies on {domain}",
|
|
||||||
"home.column_settings.show_quotes": "Show quotes",
|
"home.column_settings.show_quotes": "Show quotes",
|
||||||
"home.column_settings.show_reblogs": "Show boosts",
|
"home.column_settings.show_reblogs": "Show boosts",
|
||||||
"home.column_settings.show_replies": "Show replies",
|
"home.column_settings.show_replies": "Show replies",
|
||||||
|
@ -847,6 +845,7 @@
|
||||||
"status.bookmark": "Bookmark",
|
"status.bookmark": "Bookmark",
|
||||||
"status.cancel_reblog_private": "Unboost",
|
"status.cancel_reblog_private": "Unboost",
|
||||||
"status.cannot_reblog": "This post cannot be boosted",
|
"status.cannot_reblog": "This post cannot be boosted",
|
||||||
|
"status.context.loading": "Checking for more replies",
|
||||||
"status.continued_thread": "Continued thread",
|
"status.continued_thread": "Continued thread",
|
||||||
"status.copy": "Copy link to post",
|
"status.copy": "Copy link to post",
|
||||||
"status.delete": "Delete",
|
"status.delete": "Delete",
|
||||||
|
|
|
@ -126,6 +126,9 @@ export function createAccountFromServerJSON(serverJSON: ApiAccountJSON) {
|
||||||
? accountJSON.username
|
? accountJSON.username
|
||||||
: accountJSON.display_name;
|
: accountJSON.display_name;
|
||||||
|
|
||||||
|
const accountNote =
|
||||||
|
accountJSON.note && accountJSON.note !== '<p></p>' ? accountJSON.note : '';
|
||||||
|
|
||||||
return AccountFactory({
|
return AccountFactory({
|
||||||
...accountJSON,
|
...accountJSON,
|
||||||
moved: moved?.id,
|
moved: moved?.id,
|
||||||
|
@ -142,8 +145,8 @@ export function createAccountFromServerJSON(serverJSON: ApiAccountJSON) {
|
||||||
escapeTextContentForBrowser(displayName),
|
escapeTextContentForBrowser(displayName),
|
||||||
emojiMap,
|
emojiMap,
|
||||||
),
|
),
|
||||||
note_emojified: emojify(accountJSON.note, emojiMap),
|
note_emojified: emojify(accountNote, emojiMap),
|
||||||
note_plain: unescapeHTML(accountJSON.note),
|
note_plain: unescapeHTML(accountNote),
|
||||||
url:
|
url:
|
||||||
accountJSON.url.startsWith('http://') ||
|
accountJSON.url.startsWith('http://') ||
|
||||||
accountJSON.url.startsWith('https://')
|
accountJSON.url.startsWith('https://')
|
||||||
|
|
|
@ -4,6 +4,7 @@ import type { Draft, UnknownAction } from '@reduxjs/toolkit';
|
||||||
import type { List as ImmutableList } from 'immutable';
|
import type { List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
import { timelineDelete } from 'mastodon/actions/timelines_typed';
|
import { timelineDelete } from 'mastodon/actions/timelines_typed';
|
||||||
|
import type { AsyncRefreshHeader } from 'mastodon/api';
|
||||||
import type { ApiRelationshipJSON } from 'mastodon/api_types/relationships';
|
import type { ApiRelationshipJSON } from 'mastodon/api_types/relationships';
|
||||||
import type {
|
import type {
|
||||||
ApiStatusJSON,
|
ApiStatusJSON,
|
||||||
|
@ -12,7 +13,7 @@ import type {
|
||||||
import type { Status } from 'mastodon/models/status';
|
import type { Status } from 'mastodon/models/status';
|
||||||
|
|
||||||
import { blockAccountSuccess, muteAccountSuccess } from '../actions/accounts';
|
import { blockAccountSuccess, muteAccountSuccess } from '../actions/accounts';
|
||||||
import { fetchContext } from '../actions/statuses';
|
import { fetchContext, completeContextRefresh } from '../actions/statuses';
|
||||||
import { TIMELINE_UPDATE } from '../actions/timelines';
|
import { TIMELINE_UPDATE } from '../actions/timelines';
|
||||||
import { compareId } from '../compare_id';
|
import { compareId } from '../compare_id';
|
||||||
|
|
||||||
|
@ -25,11 +26,13 @@ interface TimelineUpdateAction extends UnknownAction {
|
||||||
interface State {
|
interface State {
|
||||||
inReplyTos: Record<string, string>;
|
inReplyTos: Record<string, string>;
|
||||||
replies: Record<string, string[]>;
|
replies: Record<string, string[]>;
|
||||||
|
refreshing: Record<string, AsyncRefreshHeader>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: State = {
|
const initialState: State = {
|
||||||
inReplyTos: {},
|
inReplyTos: {},
|
||||||
replies: {},
|
replies: {},
|
||||||
|
refreshing: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeContext = (
|
const normalizeContext = (
|
||||||
|
@ -127,6 +130,13 @@ export const contextsReducer = createReducer(initialState, (builder) => {
|
||||||
builder
|
builder
|
||||||
.addCase(fetchContext.fulfilled, (state, action) => {
|
.addCase(fetchContext.fulfilled, (state, action) => {
|
||||||
normalizeContext(state, action.meta.arg.statusId, action.payload.context);
|
normalizeContext(state, action.meta.arg.statusId, action.payload.context);
|
||||||
|
|
||||||
|
if (action.payload.refresh) {
|
||||||
|
state.refreshing[action.meta.arg.statusId] = action.payload.refresh;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.addCase(completeContextRefresh, (state, action) => {
|
||||||
|
delete state.refreshing[action.payload.statusId];
|
||||||
})
|
})
|
||||||
.addCase(blockAccountSuccess, (state, action) => {
|
.addCase(blockAccountSuccess, (state, action) => {
|
||||||
filterContexts(
|
filterContexts(
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ActivityPub::FetchAllRepliesWorker
|
||||||
MAX_PAGES = (ENV['FETCH_REPLIES_MAX_PAGES'] || 500).to_i
|
MAX_PAGES = (ENV['FETCH_REPLIES_MAX_PAGES'] || 500).to_i
|
||||||
|
|
||||||
def perform(root_status_id, options = {})
|
def perform(root_status_id, options = {})
|
||||||
|
@async_refresh = AsyncRefresh.new("context:#{root_status_id}:refresh")
|
||||||
@root_status = Status.remote.find_by(id: root_status_id)
|
@root_status = Status.remote.find_by(id: root_status_id)
|
||||||
return unless @root_status&.should_fetch_replies?
|
return unless @root_status&.should_fetch_replies?
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ class ActivityPub::FetchAllRepliesWorker
|
||||||
|
|
||||||
uris_to_fetch.concat(new_reply_uris)
|
uris_to_fetch.concat(new_reply_uris)
|
||||||
fetched_uris = fetched_uris.merge(new_reply_uris)
|
fetched_uris = fetched_uris.merge(new_reply_uris)
|
||||||
|
@async_refresh.increment_result_count(by: new_reply_uris.size)
|
||||||
n_pages += new_n_pages
|
n_pages += new_n_pages
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,6 +47,8 @@ class ActivityPub::FetchAllRepliesWorker
|
||||||
|
|
||||||
# Workers shouldn't be returning anything, but this is used in tests
|
# Workers shouldn't be returning anything, but this is used in tests
|
||||||
fetched_uris
|
fetched_uris
|
||||||
|
ensure
|
||||||
|
@async_refresh.finish!
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in New Issue
Block a user