fix pixelcounter desync
This commit is contained in:
parent
4e3f40c958
commit
b4d19a2833
|
@ -175,9 +175,10 @@ export function selectCanvas(canvasId: number): Action {
|
|||
};
|
||||
}
|
||||
|
||||
export function placedPixel(): Action {
|
||||
export function placedPixels(amount: number): Action {
|
||||
return {
|
||||
type: 'PLACE_PIXEL',
|
||||
type: 'PLACED_PIXELS',
|
||||
amount,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ export type Action =
|
|||
| { type: 'COOLDOWN_DELTA', delta: number }
|
||||
| { type: 'SELECT_COLOR', color: ColorIndex }
|
||||
| { type: 'SELECT_CANVAS', canvasId: number }
|
||||
| { type: 'PLACE_PIXEL' }
|
||||
| { type: 'PLACED_PIXELS', amount: number }
|
||||
| { type: 'PIXEL_WAIT' }
|
||||
| { type: 'PIXEL_FAILURE' }
|
||||
| { type: 'SET_VIEW_COORDINATES', view: Cell }
|
||||
|
|
|
@ -8,7 +8,6 @@ export type GUIState = {
|
|||
showGrid: boolean,
|
||||
showPixelNotify: boolean,
|
||||
hover: ?Cell,
|
||||
pixelsPlaced: number,
|
||||
autoZoomIn: boolean,
|
||||
isPotato: boolean,
|
||||
isLightGrid: boolean,
|
||||
|
@ -22,7 +21,6 @@ const initialState: GUIState = {
|
|||
showGrid: false,
|
||||
showPixelNotify: false,
|
||||
hover: null,
|
||||
pixelsPlaced: 0,
|
||||
autoZoomIn: false,
|
||||
isPotato: false,
|
||||
isLightGrid: false,
|
||||
|
@ -126,15 +124,6 @@ export default function gui(
|
|||
};
|
||||
}
|
||||
|
||||
case 'PLACE_PIXEL': {
|
||||
let { pixelsPlaced } = state;
|
||||
pixelsPlaced += 1;
|
||||
return {
|
||||
...state,
|
||||
pixelsPlaced,
|
||||
};
|
||||
}
|
||||
|
||||
case 'UNSET_HOVER': {
|
||||
return {
|
||||
...state,
|
||||
|
|
|
@ -120,10 +120,11 @@ export default function user(
|
|||
};
|
||||
}
|
||||
|
||||
case 'PLACE_PIXEL': {
|
||||
case 'PLACED_PIXELS': {
|
||||
let { totalPixels, dailyTotalPixels } = state;
|
||||
totalPixels += 1;
|
||||
dailyTotalPixels += 1;
|
||||
const { amount } = action;
|
||||
totalPixels += amount;
|
||||
dailyTotalPixels += amount;
|
||||
return {
|
||||
...state,
|
||||
totalPixels,
|
||||
|
|
|
@ -132,7 +132,7 @@ export default (store) => (next) => (action) => {
|
|||
break;
|
||||
}
|
||||
|
||||
case 'PLACE_PIXEL': {
|
||||
case 'PLACED_PIXELS': {
|
||||
if (mute) break;
|
||||
const { palette, selectedColor: color } = state.canvas;
|
||||
const colorsAmount = palette.colors.length;
|
||||
|
|
|
@ -10,7 +10,7 @@ export default (store) => (next) => (action) => {
|
|||
if (!document.hasFocus()) {
|
||||
switch (action.type) {
|
||||
case 'RECEIVE_ME':
|
||||
case 'PLACE_PIXEL': {
|
||||
case 'PLACED_PIXELS': {
|
||||
if (window.Notification
|
||||
&& Notification.permission !== 'granted'
|
||||
&& Notification.permission !== 'denied'
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
gotCoolDownDelta,
|
||||
pixelFailure,
|
||||
setWait,
|
||||
placedPixel,
|
||||
placedPixels,
|
||||
pixelWait,
|
||||
updatePixel,
|
||||
} from '../actions';
|
||||
|
@ -200,7 +200,7 @@ export function receivePixelReturn(
|
|||
let msg = null;
|
||||
switch (retCode) {
|
||||
case 0:
|
||||
store.dispatch(placedPixel());
|
||||
store.dispatch(placedPixels(pxlCnt));
|
||||
break;
|
||||
case 1:
|
||||
errorTitle = 'Invalid Canvas';
|
||||
|
|
Loading…
Reference in New Issue
Block a user