From 488db44a856d441d2c1f5108d73feac8d55e5460 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 15 Oct 2020 16:59:42 -0500 Subject: [PATCH] Preload frontend config https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3075 --- app/soapbox/reducers/soapbox.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/soapbox/reducers/soapbox.js b/app/soapbox/reducers/soapbox.js index ecf1656f5..40e65c608 100644 --- a/app/soapbox/reducers/soapbox.js +++ b/app/soapbox/reducers/soapbox.js @@ -3,6 +3,7 @@ import { SOAPBOX_CONFIG_REQUEST_SUCCESS, SOAPBOX_CONFIG_REQUEST_FAIL, } from '../actions/soapbox'; +import { PRELOAD_IMPORT } from 'soapbox/actions/preload'; import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable'; import { ConfigDB } from 'soapbox/utils/config_db'; @@ -25,8 +26,22 @@ const updateFromAdmin = (state, config) => { } }; +const preloadImport = (state, action) => { + const path = '/api/pleroma/frontend_configurations'; + const feData = action.data[path]; + + if (feData) { + const soapbox = feData.soapbox_fe; + return soapbox ? fallbackState.mergeDeep(fromJS(soapbox)) : fallbackState; + } else { + return state; + } +}; + export default function soapbox(state = initialState, action) { switch(action.type) { + case PRELOAD_IMPORT: + return preloadImport(state, action); case SOAPBOX_CONFIG_REQUEST_SUCCESS: return fromJS(action.soapboxConfig); case SOAPBOX_CONFIG_REQUEST_FAIL: