fix pixelcounter desync

This commit is contained in:
HF 2021-01-27 23:05:37 +01:00
parent 4e3f40c958
commit b4d19a2833
7 changed files with 12 additions and 21 deletions

View File

@ -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,
};
}

View File

@ -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 }

View File

@ -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,

View File

@ -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,

View File

@ -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;

View File

@ -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'

View File

@ -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';