2023-05-23 15:15:17 +00:00
|
|
|
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
|
|
|
|
2022-10-13 12:42:37 +00:00
|
|
|
import {
|
|
|
|
SERVER_FETCH_REQUEST,
|
|
|
|
SERVER_FETCH_SUCCESS,
|
|
|
|
SERVER_FETCH_FAIL,
|
2023-03-16 10:07:24 +00:00
|
|
|
SERVER_TRANSLATION_LANGUAGES_FETCH_REQUEST,
|
|
|
|
SERVER_TRANSLATION_LANGUAGES_FETCH_SUCCESS,
|
|
|
|
SERVER_TRANSLATION_LANGUAGES_FETCH_FAIL,
|
2022-10-13 12:42:37 +00:00
|
|
|
EXTENDED_DESCRIPTION_REQUEST,
|
|
|
|
EXTENDED_DESCRIPTION_SUCCESS,
|
|
|
|
EXTENDED_DESCRIPTION_FAIL,
|
|
|
|
SERVER_DOMAIN_BLOCKS_FETCH_REQUEST,
|
|
|
|
SERVER_DOMAIN_BLOCKS_FETCH_SUCCESS,
|
|
|
|
SERVER_DOMAIN_BLOCKS_FETCH_FAIL,
|
|
|
|
} from 'mastodon/actions/server';
|
2022-10-05 01:47:56 +00:00
|
|
|
|
|
|
|
const initialState = ImmutableMap({
|
2022-10-13 12:42:37 +00:00
|
|
|
server: ImmutableMap({
|
2023-07-02 09:12:16 +00:00
|
|
|
isLoading: false,
|
2022-10-13 12:42:37 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
extendedDescription: ImmutableMap({
|
2023-07-02 09:12:16 +00:00
|
|
|
isLoading: false,
|
2022-10-13 12:42:37 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
domainBlocks: ImmutableMap({
|
2023-07-02 09:12:16 +00:00
|
|
|
isLoading: false,
|
2022-10-13 12:42:37 +00:00
|
|
|
isAvailable: true,
|
|
|
|
items: ImmutableList(),
|
|
|
|
}),
|
2022-10-05 01:47:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export default function server(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
|
|
|
case SERVER_FETCH_REQUEST:
|
2022-10-13 12:42:37 +00:00
|
|
|
return state.setIn(['server', 'isLoading'], true);
|
2022-10-05 01:47:56 +00:00
|
|
|
case SERVER_FETCH_SUCCESS:
|
2022-10-13 12:42:37 +00:00
|
|
|
return state.set('server', fromJS(action.server)).setIn(['server', 'isLoading'], false);
|
2022-10-05 01:47:56 +00:00
|
|
|
case SERVER_FETCH_FAIL:
|
2022-10-13 12:42:37 +00:00
|
|
|
return state.setIn(['server', 'isLoading'], false);
|
2023-03-16 10:07:24 +00:00
|
|
|
case SERVER_TRANSLATION_LANGUAGES_FETCH_REQUEST:
|
|
|
|
return state.setIn(['translationLanguages', 'isLoading'], true);
|
|
|
|
case SERVER_TRANSLATION_LANGUAGES_FETCH_SUCCESS:
|
|
|
|
return state.setIn(['translationLanguages', 'items'], fromJS(action.translationLanguages)).setIn(['translationLanguages', 'isLoading'], false);
|
|
|
|
case SERVER_TRANSLATION_LANGUAGES_FETCH_FAIL:
|
|
|
|
return state.setIn(['translationLanguages', 'isLoading'], false);
|
2022-10-13 12:42:37 +00:00
|
|
|
case EXTENDED_DESCRIPTION_REQUEST:
|
|
|
|
return state.setIn(['extendedDescription', 'isLoading'], true);
|
|
|
|
case EXTENDED_DESCRIPTION_SUCCESS:
|
|
|
|
return state.set('extendedDescription', fromJS(action.description)).setIn(['extendedDescription', 'isLoading'], false);
|
|
|
|
case EXTENDED_DESCRIPTION_FAIL:
|
|
|
|
return state.setIn(['extendedDescription', 'isLoading'], false);
|
|
|
|
case SERVER_DOMAIN_BLOCKS_FETCH_REQUEST:
|
|
|
|
return state.setIn(['domainBlocks', 'isLoading'], true);
|
|
|
|
case SERVER_DOMAIN_BLOCKS_FETCH_SUCCESS:
|
|
|
|
return state.setIn(['domainBlocks', 'items'], fromJS(action.blocks)).setIn(['domainBlocks', 'isLoading'], false).setIn(['domainBlocks', 'isAvailable'], action.isAvailable);
|
|
|
|
case SERVER_DOMAIN_BLOCKS_FETCH_FAIL:
|
|
|
|
return state.setIn(['domainBlocks', 'isLoading'], false);
|
2022-10-05 01:47:56 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|