reenable negative notifications and move it from gui to user state

This commit is contained in:
HF 2020-04-24 20:59:05 +02:00
parent fdae2b76fe
commit 9cabf7c8fd
4 changed files with 21 additions and 19 deletions

View File

@ -254,8 +254,9 @@ export function requestPlacePixel(
if (waitSeconds) {
dispatch(setWait(waitSeconds * 1000));
}
if (coolDownSeconds > 1.0) {
dispatch(notify(Math.round(coolDownSeconds)));
const coolDownNotify = Math.round(coolDownSeconds);
if (coolDownSeconds) {
dispatch(notify(coolDownNotify));
}
if (response.ok) {
if (success) {

View File

@ -28,7 +28,7 @@ const NotifyBox = ({ notification }) => (
);
function mapStateToProps(state: State) {
const { notification } = state.gui;
const { notification } = state.user;
return { notification };
}

View File

@ -12,7 +12,6 @@ export type GUIState = {
hover: ?Cell,
pixelsPlaced: number,
autoZoomIn: boolean,
notification: string,
isPotato: boolean,
isLightGrid: boolean,
compactPalette: boolean,
@ -27,7 +26,6 @@ const initialState: GUIState = {
hover: null,
pixelsPlaced: 0,
autoZoomIn: false,
notification: null,
isPotato: false,
isLightGrid: false,
compactPalette: false,
@ -121,20 +119,6 @@ export default function gui(
};
}
case 'SET_NOTIFICATION': {
return {
...state,
notification: action.notification,
};
}
case 'UNSET_NOTIFICATION': {
return {
...state,
notification: null,
};
}
case 'SET_HOVER': {
const { hover } = action;
return {

View File

@ -28,6 +28,8 @@ export type UserState = {
minecraftname: string,
// if user is using touchscreen
isOnMobile: boolean,
// small notifications for received cooldown
notification: string,
};
const initialState: UserState = {
@ -45,6 +47,7 @@ const initialState: UserState = {
chatMessages: [['info', 'Welcome to the PixelPlanet Chat']],
minecraftname: null,
isOnMobile: false,
notification: null,
};
export default function user(
@ -196,6 +199,20 @@ export default function user(
};
}
case 'SET_NOTIFICATION': {
return {
...state,
notification: action.notification,
};
}
case 'UNSET_NOTIFICATION': {
return {
...state,
notification: null,
};
}
case 'REM_FROM_MESSAGES': {
const { message } = action;
const messages = [...state.messages];