Merge branch 'instance-placeholder' into 'develop'
Authenticated fetch: make the instance appear censored See merge request soapbox-pub/soapbox-fe!714
This commit is contained in:
commit
73baa1f55c
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
INSTANCE_FETCH_SUCCESS,
|
INSTANCE_FETCH_SUCCESS,
|
||||||
|
INSTANCE_FETCH_FAIL,
|
||||||
NODEINFO_FETCH_SUCCESS,
|
NODEINFO_FETCH_SUCCESS,
|
||||||
} from '../actions/instance';
|
} from '../actions/instance';
|
||||||
import { PRELOAD_IMPORT } from 'soapbox/actions/preload';
|
import { PRELOAD_IMPORT } from 'soapbox/actions/preload';
|
||||||
|
@ -71,12 +72,22 @@ const importConfigs = (state, configs) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAuthFetch = state => {
|
||||||
|
// Authenticated fetch is enabled, so make the instance appear censored
|
||||||
|
return ImmutableMap({
|
||||||
|
title: '██████',
|
||||||
|
description: '████████████',
|
||||||
|
}).merge(state);
|
||||||
|
};
|
||||||
|
|
||||||
export default function instance(state = initialState, action) {
|
export default function instance(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case PRELOAD_IMPORT:
|
case PRELOAD_IMPORT:
|
||||||
return preloadImport(state, action, '/api/v1/instance');
|
return preloadImport(state, action, '/api/v1/instance');
|
||||||
case INSTANCE_FETCH_SUCCESS:
|
case INSTANCE_FETCH_SUCCESS:
|
||||||
return initialState.mergeDeep(fromJS(action.instance));
|
return initialState.mergeDeep(fromJS(action.instance));
|
||||||
|
case INSTANCE_FETCH_FAIL:
|
||||||
|
return action.error.response.status === 401 ? handleAuthFetch(state) : state;
|
||||||
case NODEINFO_FETCH_SUCCESS:
|
case NODEINFO_FETCH_SUCCESS:
|
||||||
return nodeinfoToInstance(fromJS(action.nodeinfo)).mergeDeep(state);
|
return nodeinfoToInstance(fromJS(action.nodeinfo)).mergeDeep(state);
|
||||||
case ADMIN_CONFIG_UPDATE_REQUEST:
|
case ADMIN_CONFIG_UPDATE_REQUEST:
|
||||||
|
|
Loading…
Reference in New Issue