mirror of
https://github.com/wassname/talk.git
synced 2026-07-05 03:21:53 +08:00
Renamed pageData -> config
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
export const CONFIG_UPDATED = 'CONFIG_UPDATED';
|
||||
|
||||
export const fetchConfig = () => dispatch => {
|
||||
let json = document.getElementById('data');
|
||||
let data = JSON.parse(json.textContent);
|
||||
dispatch({type: CONFIG_UPDATED, data});
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
export const PAGE_DATA_UPDATED = 'PAGE_DATA_UPDATED';
|
||||
|
||||
export const fetchPageData = () => dispatch => {
|
||||
let json = document.getElementById('data');
|
||||
let data = JSON.parse(json.textContent);
|
||||
dispatch({type: PAGE_DATA_UPDATED, data});
|
||||
};
|
||||
@@ -2,16 +2,16 @@ import React, {Component} from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
import Layout from '../components/ui/Layout';
|
||||
import {checkLogin, handleLogin, logout, requestPasswordReset} from '../actions/auth';
|
||||
import {fetchPageData} from '../actions/pageData';
|
||||
import {fetchConfig} from '../actions/config';
|
||||
import {FullLoading} from '../components/FullLoading';
|
||||
import AdminLogin from '../components/AdminLogin';
|
||||
|
||||
class LayoutContainer extends Component {
|
||||
componentWillMount () {
|
||||
const {checkLogin, fetchPageData} = this.props;
|
||||
const {checkLogin, fetchConfig} = this.props;
|
||||
|
||||
checkLogin();
|
||||
fetchPageData();
|
||||
fetchConfig();
|
||||
}
|
||||
render () {
|
||||
const {
|
||||
@@ -45,12 +45,12 @@ class LayoutContainer extends Component {
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
auth: state.auth.toJS(),
|
||||
TALK_RECAPTCHA_PUBLIC: state.pageData.get('data').get('TALK_RECAPTCHA_PUBLIC', null)
|
||||
TALK_RECAPTCHA_PUBLIC: state.config.get('data').get('TALK_RECAPTCHA_PUBLIC', null)
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
checkLogin: () => dispatch(checkLogin()),
|
||||
fetchPageData: () => dispatch(fetchPageData()),
|
||||
fetchConfig: () => dispatch(fetchConfig()),
|
||||
handleLogin: (username, password, recaptchaResponse) => dispatch(handleLogin(username, password, recaptchaResponse)),
|
||||
requestPasswordReset: email => dispatch(requestPasswordReset(email)),
|
||||
handleLogout: () => dispatch(logout())
|
||||
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
import {Map} from 'immutable';
|
||||
|
||||
import * as actions from '../actions/pageData';
|
||||
import * as actions from '../actions/config';
|
||||
|
||||
const initialState = Map({
|
||||
data: Map({})
|
||||
});
|
||||
|
||||
export default function pageData (state = initialState, action) {
|
||||
export default function config (state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case actions.PAGE_DATA_UPDATED:
|
||||
case actions.CONFIG_UPDATED:
|
||||
return state.set('data', Map(action.data));
|
||||
default:
|
||||
return state;
|
||||
@@ -4,7 +4,7 @@ import settings from './settings';
|
||||
import community from './community';
|
||||
import moderation from './moderation';
|
||||
import install from './install';
|
||||
import pageData from './pageData';
|
||||
import config from './config';
|
||||
|
||||
export default {
|
||||
auth,
|
||||
@@ -13,5 +13,5 @@ export default {
|
||||
community,
|
||||
moderation,
|
||||
install,
|
||||
pageData
|
||||
config
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user