split ranks from user reducer
This commit is contained in:
parent
dec817d8a0
commit
e76e56027f
|
@ -34,7 +34,7 @@ const DailyRankings = ({ totalDailyRanking }) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
function mapStateToProps(state: State) {
|
function mapStateToProps(state: State) {
|
||||||
const { totalDailyRanking } = state.user;
|
const { totalDailyRanking } = state.ranks;
|
||||||
return { totalDailyRanking };
|
return { totalDailyRanking };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ const TotalRankings = ({ totalRanking }) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
function mapStateToProps(state: State) {
|
function mapStateToProps(state: State) {
|
||||||
const { totalRanking } = state.user;
|
const { totalRanking } = state.ranks;
|
||||||
return { totalRanking };
|
return { totalRanking };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,11 +212,13 @@ function mapStateToProps(state: State) {
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
mailreg,
|
mailreg,
|
||||||
|
} = state.user;
|
||||||
|
const {
|
||||||
totalPixels,
|
totalPixels,
|
||||||
dailyTotalPixels,
|
dailyTotalPixels,
|
||||||
ranking,
|
ranking,
|
||||||
dailyRanking,
|
dailyRanking,
|
||||||
} = state.user;
|
} = state.ranks;
|
||||||
const stats = {
|
const stats = {
|
||||||
totalPixels,
|
totalPixels,
|
||||||
dailyTotalPixels,
|
dailyTotalPixels,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import canvas from './canvas';
|
||||||
import gui from './gui';
|
import gui from './gui';
|
||||||
import modal from './modal';
|
import modal from './modal';
|
||||||
import user from './user';
|
import user from './user';
|
||||||
|
import ranks from './ranks';
|
||||||
import chat from './chat';
|
import chat from './chat';
|
||||||
import contextMenu from './contextMenu';
|
import contextMenu from './contextMenu';
|
||||||
import chatRead from './chatRead';
|
import chatRead from './chatRead';
|
||||||
|
@ -38,6 +39,7 @@ const config = {
|
||||||
storage: localForage,
|
storage: localForage,
|
||||||
blacklist: [
|
blacklist: [
|
||||||
'user',
|
'user',
|
||||||
|
'ranks',
|
||||||
'canvas',
|
'canvas',
|
||||||
'modal',
|
'modal',
|
||||||
'chat',
|
'chat',
|
||||||
|
@ -52,6 +54,7 @@ export default persistCombineReducers(config, {
|
||||||
gui,
|
gui,
|
||||||
modal,
|
modal,
|
||||||
user,
|
user,
|
||||||
|
ranks,
|
||||||
chat,
|
chat,
|
||||||
contextMenu,
|
contextMenu,
|
||||||
chatRead,
|
chatRead,
|
||||||
|
|
80
src/reducers/ranks.js
Normal file
80
src/reducers/ranks.js
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/* @flow */
|
||||||
|
|
||||||
|
import type { Action } from '../actions/types';
|
||||||
|
|
||||||
|
export type UserState = {
|
||||||
|
totalPixels: number,
|
||||||
|
dailyTotalPixels: number,
|
||||||
|
ranking: number,
|
||||||
|
dailyRanking: number,
|
||||||
|
// global stats
|
||||||
|
online: ?number,
|
||||||
|
totalRanking: Object,
|
||||||
|
totalDailyRanking: Object,
|
||||||
|
};
|
||||||
|
|
||||||
|
const initialState: UserState = {
|
||||||
|
totalPixels: 0,
|
||||||
|
dailyTotalPixels: 0,
|
||||||
|
ranking: 1488,
|
||||||
|
dailyRanking: 1488,
|
||||||
|
online: 1,
|
||||||
|
totalRanking: {},
|
||||||
|
totalDailyRanking: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ranks(
|
||||||
|
state: UserState = initialState,
|
||||||
|
action: Action,
|
||||||
|
): UserState {
|
||||||
|
switch (action.type) {
|
||||||
|
case 'PLACED_PIXELS': {
|
||||||
|
let { totalPixels, dailyTotalPixels } = state;
|
||||||
|
const { amount } = action;
|
||||||
|
totalPixels += amount;
|
||||||
|
dailyTotalPixels += amount;
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
totalPixels,
|
||||||
|
dailyTotalPixels,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'RECEIVE_ONLINE': {
|
||||||
|
const { online } = action;
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
online,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'RECEIVE_ME':
|
||||||
|
case 'LOGIN': {
|
||||||
|
const {
|
||||||
|
totalPixels,
|
||||||
|
dailyTotalPixels,
|
||||||
|
ranking,
|
||||||
|
dailyRanking,
|
||||||
|
} = action;
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
totalPixels,
|
||||||
|
dailyTotalPixels,
|
||||||
|
ranking,
|
||||||
|
dailyRanking,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'RECEIVE_STATS': {
|
||||||
|
const { totalRanking, totalDailyRanking } = action;
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
totalRanking,
|
||||||
|
totalDailyRanking,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import type { Action } from '../actions/types';
|
||||||
import { createNameRegExp } from '../core/utils';
|
import { createNameRegExp } from '../core/utils';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UserState = {
|
export type UserState = {
|
||||||
name: string,
|
name: string,
|
||||||
center: Cell,
|
center: Cell,
|
||||||
|
@ -13,18 +12,9 @@ export type UserState = {
|
||||||
coolDown: ?number, // ms
|
coolDown: ?number, // ms
|
||||||
lastCoolDownEnd: ?Date,
|
lastCoolDownEnd: ?Date,
|
||||||
requestingPixel: boolean,
|
requestingPixel: boolean,
|
||||||
online: ?number,
|
|
||||||
// messages are sent by api/me, like not_verified status
|
// messages are sent by api/me, like not_verified status
|
||||||
messages: Array,
|
messages: Array,
|
||||||
mailreg: boolean,
|
mailreg: boolean,
|
||||||
// stats
|
|
||||||
totalPixels: number,
|
|
||||||
dailyTotalPixels: number,
|
|
||||||
ranking: number,
|
|
||||||
dailyRanking: number,
|
|
||||||
// global stats
|
|
||||||
totalRanking: Object,
|
|
||||||
totalDailyRanking: Object,
|
|
||||||
// minecraft
|
// minecraft
|
||||||
minecraftname: string,
|
minecraftname: string,
|
||||||
// blocking all Dms
|
// blocking all Dms
|
||||||
|
@ -46,11 +36,8 @@ const initialState: UserState = {
|
||||||
coolDown: null,
|
coolDown: null,
|
||||||
lastCoolDownEnd: null,
|
lastCoolDownEnd: null,
|
||||||
requestingPixel: true,
|
requestingPixel: true,
|
||||||
online: null,
|
|
||||||
messages: [],
|
messages: [],
|
||||||
mailreg: false,
|
mailreg: false,
|
||||||
totalRanking: {},
|
|
||||||
totalDailyRanking: {},
|
|
||||||
minecraftname: null,
|
minecraftname: null,
|
||||||
blockDm: false,
|
blockDm: false,
|
||||||
isOnMobile: false,
|
isOnMobile: false,
|
||||||
|
@ -120,35 +107,11 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'PLACED_PIXELS': {
|
|
||||||
let { totalPixels, dailyTotalPixels } = state;
|
|
||||||
const { amount } = action;
|
|
||||||
totalPixels += amount;
|
|
||||||
dailyTotalPixels += amount;
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
totalPixels,
|
|
||||||
dailyTotalPixels,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'RECEIVE_ONLINE': {
|
|
||||||
const { online } = action;
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
online,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'RECEIVE_ME':
|
case 'RECEIVE_ME':
|
||||||
case 'LOGIN': {
|
case 'LOGIN': {
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
mailreg,
|
mailreg,
|
||||||
totalPixels,
|
|
||||||
dailyTotalPixels,
|
|
||||||
ranking,
|
|
||||||
dailyRanking,
|
|
||||||
minecraftname,
|
minecraftname,
|
||||||
blockDm,
|
blockDm,
|
||||||
userlvl,
|
userlvl,
|
||||||
|
@ -160,10 +123,6 @@ export default function user(
|
||||||
name,
|
name,
|
||||||
messages,
|
messages,
|
||||||
mailreg,
|
mailreg,
|
||||||
totalPixels,
|
|
||||||
dailyTotalPixels,
|
|
||||||
ranking,
|
|
||||||
dailyRanking,
|
|
||||||
minecraftname,
|
minecraftname,
|
||||||
blockDm,
|
blockDm,
|
||||||
userlvl,
|
userlvl,
|
||||||
|
@ -184,15 +143,6 @@ export default function user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'RECEIVE_STATS': {
|
|
||||||
const { totalRanking, totalDailyRanking } = action;
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
totalRanking,
|
|
||||||
totalDailyRanking,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'SET_NAME': {
|
case 'SET_NAME': {
|
||||||
const { name } = action;
|
const { name } = action;
|
||||||
const nameRegExp = createNameRegExp(name);
|
const nameRegExp = createNameRegExp(name);
|
||||||
|
|
|
@ -31,7 +31,7 @@ export function getIPFromRequest(req): ?string {
|
||||||
|
|
||||||
if (!USE_XREALIP) {
|
if (!USE_XREALIP) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Connection not going through reverse proxy! IP: ${conip}`, reqheaders,
|
`Connection not going through reverse proxy! IP: ${conip}`, req.headers,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user