Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent duplicate concurrent calls of /api/*/instance in web UI #25663

Merged
merged 2 commits into from Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/javascript/mastodon/actions/server.js
Expand Up @@ -19,6 +19,10 @@ export const SERVER_DOMAIN_BLOCKS_FETCH_SUCCESS = 'SERVER_DOMAIN_BLOCKS_FETCH_SU
export const SERVER_DOMAIN_BLOCKS_FETCH_FAIL = 'SERVER_DOMAIN_BLOCKS_FETCH_FAIL';

export const fetchServer = () => (dispatch, getState) => {
if (getState().getIn(['server', 'server', 'isLoading'])) {
return;
}

dispatch(fetchServerRequest());

api(getState)
Expand Down Expand Up @@ -66,6 +70,10 @@ const fetchServerTranslationLanguagesFail = error => ({
});

export const fetchExtendedDescription = () => (dispatch, getState) => {
if (getState().getIn(['server', 'extendedDescription', 'isLoading'])) {
return;
}

dispatch(fetchExtendedDescriptionRequest());

api(getState)
Expand All @@ -89,6 +97,10 @@ const fetchExtendedDescriptionFail = error => ({
});

export const fetchDomainBlocks = () => (dispatch, getState) => {
if (getState().getIn(['server', 'domainBlocks', 'isLoading'])) {
return;
}

dispatch(fetchDomainBlocksRequest());

api(getState)
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/features/about/index.jsx
Expand Up @@ -161,7 +161,7 @@ class About extends PureComponent {
</Section>

<Section title={intl.formatMessage(messages.rules)}>
{!isLoading && (server.get('rules').isEmpty() ? (
{!isLoading && (server.get('rules', []).isEmpty() ? (
<p><FormattedMessage id='about.not_available' defaultMessage='This information has not been made available on this server.' /></p>
) : (
<ol className='rules-list'>
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/mastodon/reducers/server.js
Expand Up @@ -17,15 +17,15 @@ import {

const initialState = ImmutableMap({
server: ImmutableMap({
isLoading: true,
isLoading: false,
}),

extendedDescription: ImmutableMap({
isLoading: true,
isLoading: false,
}),

domainBlocks: ImmutableMap({
isLoading: true,
isLoading: false,
isAvailable: true,
items: ImmutableList(),
}),
Expand Down