remove flow type definition that are used inconsistently

This commit is contained in:
HF 2022-01-03 14:33:26 +01:00
parent 3f46edf50a
commit e59df4fb62
24 changed files with 347 additions and 548 deletions

View File

@ -2,7 +2,6 @@
* Collect api fetch commands for actions here
* (chunk and tiles requests in ui/ChunkLoader*.js)
*
* @flow
*/
import { t } from 'ttag';
@ -107,7 +106,7 @@ async function makeAPIGETRequest(url) {
* @param block true if block, false if unblock
* @return error string or null if successful
*/
export async function requestBlock(userId: number, block: boolean) {
export async function requestBlock(userId, block) {
const res = await makeAPIPOSTRequest(
'api/block',
{ userId, block },
@ -123,7 +122,7 @@ export async function requestBlock(userId: number, block: boolean) {
/*
* start new DM channel with user
* @param query Object with either userId: number or userName: string
* @param query Object with either userId or userName: string
* @return channel Array on success, error string if not
*/
export async function requestStartDm(query) {
@ -145,7 +144,7 @@ export async function requestStartDm(query) {
* @param block true if blocking all dms, false if unblocking
* @return error string or null if successful
*/
export async function requestBlockDm(block: boolean) {
export async function requestBlockDm(block) {
const res = await makeAPIPOSTRequest(
'api/blockdm',
{ block },
@ -164,7 +163,7 @@ export async function requestBlockDm(block: boolean) {
* @param channelId 8nteger id of channel
* @return error string or null if successful
*/
export async function requestLeaveChan(channelId: boolean) {
export async function requestLeaveChan(channelId) {
const res = await makeAPIPOSTRequest(
'api/leavechan',
{ channelId },

View File

@ -1,14 +1,5 @@
/* @flow */
import { t } from 'ttag';
import type {
Action,
ThunkAction,
PromiseAction,
} from './types';
import type { Cell } from '../core/Cell';
import type { ColorIndex } from '../core/Palette';
import {
requestStartDm,
requestBlock,
@ -17,11 +8,11 @@ import {
} from './fetch';
export function sweetAlert(
title: string,
text: string,
icon: string,
confirmButtonText: string,
): Action {
title,
text,
icon,
confirmButtonText,
) {
return {
type: 'ALERT',
title,
@ -31,178 +22,178 @@ export function sweetAlert(
};
}
export function closeAlert(): Action {
export function closeAlert() {
return {
type: 'CLOSE_ALERT',
};
}
export function toggleHistoricalView(): Action {
export function toggleHistoricalView() {
return {
type: 'TOGGLE_HISTORICAL_VIEW',
};
}
export function toggleHiddenCanvases(): Action {
export function toggleHiddenCanvases() {
return {
type: 'TOGGLE_HIDDEN_CANVASES',
};
}
export function toggleGrid(): Action {
export function toggleGrid() {
return {
type: 'TOGGLE_GRID',
};
}
export function togglePixelNotify(): Action {
export function togglePixelNotify() {
return {
type: 'TOGGLE_PIXEL_NOTIFY',
};
}
export function toggleAutoZoomIn(): Action {
export function toggleAutoZoomIn() {
return {
type: 'TOGGLE_AUTO_ZOOM_IN',
};
}
export function toggleMute(): Action {
export function toggleMute() {
return {
type: 'TOGGLE_MUTE',
};
}
export function toggleCompactPalette(): Action {
export function toggleCompactPalette() {
return {
type: 'TOGGLE_COMPACT_PALETTE',
};
}
export function toggleChatNotify(): Action {
export function toggleChatNotify() {
return {
type: 'TOGGLE_CHAT_NOTIFY',
};
}
export function togglePotatoMode(): Action {
export function togglePotatoMode() {
return {
type: 'TOGGLE_POTATO_MODE',
};
}
export function toggleLightGrid(): Action {
export function toggleLightGrid() {
return {
type: 'TOGGLE_LIGHT_GRID',
};
}
export function toggleOpenPalette(): Action {
export function toggleOpenPalette() {
return {
type: 'TOGGLE_OPEN_PALETTE',
};
}
export function selectStyle(style: string): Action {
export function selectStyle(style) {
return {
type: 'SELECT_STYLE',
style,
};
}
export function toggleOpenMenu(): Action {
export function toggleOpenMenu() {
return {
type: 'TOGGLE_OPEN_MENU',
};
}
export function setRequestingPixel(requestingPixel: boolean): Action {
export function setRequestingPixel(requestingPixel: boolean) {
return {
type: 'SET_REQUESTING_PIXEL',
requestingPixel,
};
}
export function setNotification(notification: string): Action {
export function setNotification(notification) {
return {
type: 'SET_NOTIFICATION',
notification,
};
}
export function unsetNotification(): Action {
export function unsetNotification() {
return {
type: 'UNSET_NOTIFICATION',
};
}
export function setHover(hover: Cell): Action {
export function setHover(hover) {
return {
type: 'SET_HOVER',
hover,
};
}
export function unsetHover(): Action {
export function unsetHover() {
return {
type: 'UNSET_HOVER',
};
}
export function setWait(wait: ?number): Action {
export function setWait(wait: ?number) {
return {
type: 'SET_WAIT',
wait,
};
}
export function setMobile(mobile: boolean): Action {
export function setMobile(mobile: boolean) {
return {
type: 'SET_MOBILE',
mobile,
};
}
export function windowResize(): Action {
export function windowResize() {
return {
type: 'WINDOW_RESIZE',
};
}
export function selectColor(color: ColorIndex): Action {
export function selectColor(color) {
return {
type: 'SELECT_COLOR',
color,
};
}
export function selectCanvas(canvasId: number): Action {
export function selectCanvas(canvasId) {
return {
type: 'SELECT_CANVAS',
canvasId,
};
}
export function placedPixels(amount: number): Action {
export function placedPixels(amount) {
return {
type: 'PLACED_PIXELS',
amount,
};
}
export function pixelWait(): Action {
export function pixelWait() {
return {
type: 'PIXEL_WAIT',
};
}
export function pixelFailure(): Action {
export function pixelFailure() {
return {
type: 'PIXEL_FAILURE',
};
}
export function receiveOnline(online: number): Action {
export function receiveOnline(online) {
return {
type: 'RECEIVE_ONLINE',
online,
@ -210,14 +201,14 @@ export function receiveOnline(online: number): Action {
}
export function receiveChatMessage(
name: string,
text: string,
country: string,
channel: number,
user: number,
name,
text,
country,
channel,
user,
isPing: boolean,
isRead: boolean,
): Action {
) {
return {
type: 'RECEIVE_CHAT_MESSAGE',
name,
@ -231,7 +222,7 @@ export function receiveChatMessage(
}
let lastNotify = null;
export function notify(notification: string) {
export function notify(notification) {
return async (dispatch) => {
dispatch(setNotification(notification));
if (lastNotify) {
@ -244,14 +235,14 @@ export function notify(notification: string) {
};
}
export function setViewCoordinates(view: Cell): Action {
export function setViewCoordinates(view) {
return {
type: 'SET_VIEW_COORDINATES',
view,
};
}
export function move([dx, dy]: Cell): ThunkAction {
export function move([dx, dy]) {
return (dispatch, getState) => {
const { view } = getState().canvas;
@ -260,7 +251,7 @@ export function move([dx, dy]: Cell): ThunkAction {
};
}
export function moveDirection([vx, vy]: Cell): ThunkAction {
export function moveDirection([vx, vy]) {
return (dispatch, getState) => {
const { viewscale } = getState().canvas;
@ -269,31 +260,31 @@ export function moveDirection([vx, vy]: Cell): ThunkAction {
};
}
export function moveNorth(): ThunkAction {
export function moveNorth() {
return (dispatch) => {
dispatch(moveDirection([0, -1]));
};
}
export function moveWest(): ThunkAction {
export function moveWest() {
return (dispatch) => {
dispatch(moveDirection([-1, 0]));
};
}
export function moveSouth(): ThunkAction {
export function moveSouth() {
return (dispatch) => {
dispatch(moveDirection([0, 1]));
};
}
export function moveEast(): ThunkAction {
export function moveEast() {
return (dispatch) => {
dispatch(moveDirection([1, 0]));
};
}
export function setScale(scale: number, zoompoint: Cell): Action {
export function setScale(scale, zoompoint) {
return {
type: 'SET_SCALE',
scale,
@ -301,7 +292,7 @@ export function setScale(scale: number, zoompoint: Cell): Action {
};
}
export function zoomIn(zoompoint): ThunkAction {
export function zoomIn(zoompoint) {
return (dispatch, getState) => {
const { scale } = getState().canvas;
const zoomscale = scale >= 1.0 ? scale * 1.1 : scale * 1.04;
@ -309,7 +300,7 @@ export function zoomIn(zoompoint): ThunkAction {
};
}
export function zoomOut(zoompoint): ThunkAction {
export function zoomOut(zoompoint) {
return (dispatch, getState) => {
const { scale } = getState().canvas;
const zoomscale = scale >= 1.0 ? scale / 1.1 : scale / 1.04;
@ -317,7 +308,7 @@ export function zoomOut(zoompoint): ThunkAction {
};
}
export function requestBigChunk(center: Cell): Action {
export function requestBigChunk(center) {
return {
type: 'REQUEST_BIG_CHUNK',
center,
@ -325,8 +316,8 @@ export function requestBigChunk(center: Cell): Action {
}
export function preLoadedBigChunk(
center: Cell,
): Action {
center,
) {
return {
type: 'PRE_LOADED_BIG_CHUNK',
center,
@ -334,9 +325,9 @@ export function preLoadedBigChunk(
}
export function receiveBigChunk(
center: Cell,
center,
chunk: Uint8Array,
): Action {
) {
return {
type: 'RECEIVE_BIG_CHUNK',
center,
@ -344,7 +335,7 @@ export function receiveBigChunk(
};
}
export function receiveBigChunkFailure(center: Cell, error: Error): Action {
export function receiveBigChunkFailure(center, error: Error) {
return {
type: 'RECEIVE_BIG_CHUNK_FAILURE',
center,
@ -353,8 +344,8 @@ export function receiveBigChunkFailure(center: Cell, error: Error): Action {
}
export function receiveCoolDown(
wait: number,
): Action {
wait,
) {
return {
type: 'RECEIVE_COOLDOWN',
wait,
@ -362,11 +353,11 @@ export function receiveCoolDown(
}
export function updatePixel(
i: number,
j: number,
offset: number,
color: ColorIndex,
): Action {
i,
j,
offset,
color,
) {
return {
type: 'UPDATE_PIXEL',
i,
@ -377,8 +368,8 @@ export function updatePixel(
}
export function loginUser(
me: Object,
): Action {
me,
) {
return {
type: 'LOGIN',
...me,
@ -386,8 +377,8 @@ export function loginUser(
}
export function receiveMe(
me: Object,
): Action {
me,
) {
return {
type: 'RECEIVE_ME',
...me,
@ -395,15 +386,15 @@ export function receiveMe(
}
export function logoutUser(
): Action {
) {
return {
type: 'LOGOUT',
};
}
export function receiveStats(
rankings: Object,
): Action {
rankings,
) {
const { ranking: totalRanking, dailyRanking: totalDailyRanking } = rankings;
return {
type: 'RECEIVE_STATS',
@ -413,8 +404,8 @@ export function receiveStats(
}
export function setName(
name: string,
): Action {
name,
) {
return {
type: 'SET_NAME',
name,
@ -423,7 +414,7 @@ export function setName(
export function setMailreg(
mailreg: boolean,
): Action {
) {
return {
type: 'SET_MAILREG',
mailreg,
@ -431,15 +422,15 @@ export function setMailreg(
}
export function remFromMessages(
message: string,
): Action {
message,
) {
return {
type: 'REM_FROM_MESSAGES',
message,
};
}
export function fetchStats(): PromiseAction {
export function fetchStats() {
return async (dispatch) => {
const response = await fetch('api/ranking', { credentials: 'include' });
if (response.ok) {
@ -450,7 +441,7 @@ export function fetchStats(): PromiseAction {
};
}
export function fetchMe(): PromiseAction {
export function fetchMe() {
return async (dispatch) => {
const response = await fetch('api/me', {
credentials: 'include',
@ -464,9 +455,9 @@ export function fetchMe(): PromiseAction {
}
function receiveChatHistory(
cid: number,
history: Array,
): Action {
cid,
history,
) {
return {
type: 'RECEIVE_CHAT_HISTORY',
cid,
@ -474,14 +465,14 @@ function receiveChatHistory(
};
}
function setChatFetching(fetching: boolean): Action {
function setChatFetching(fetching: boolean) {
return {
type: 'SET_CHAT_FETCHING',
fetching,
};
}
function setApiFetching(fetching: boolean): Action {
function setApiFetching(fetching: boolean) {
return {
type: 'SET_API_FETCHING',
fetching,
@ -489,8 +480,8 @@ function setApiFetching(fetching: boolean): Action {
}
export function fetchChatMessages(
cid: number,
): PromiseAction {
cid,
) {
return async (dispatch) => {
dispatch(setChatFetching(true));
const response = await fetch(`api/chathistory?cid=${cid}&limit=50`, {
@ -510,20 +501,20 @@ export function fetchChatMessages(
};
}
function setCoolDown(coolDown): Action {
function setCoolDown(coolDown) {
return {
type: 'COOLDOWN_SET',
coolDown,
};
}
function endCoolDown(): Action {
function endCoolDown() {
return {
type: 'COOLDOWN_END',
};
}
function getPendingActions(state): Array<Action> {
function getPendingActions(state) {
const actions = [];
const now = Date.now();
@ -539,7 +530,7 @@ function getPendingActions(state): Array<Action> {
return actions;
}
export function initTimer(): ThunkAction {
export function initTimer() {
return (dispatch, getState) => {
function tick() {
const state = getState();
@ -556,16 +547,16 @@ export function initTimer(): ThunkAction {
* fullscreen means to open as modal
*/
export function openWindow(
windowType: string,
title: string,
windowType,
title,
fullscreen: boolean,
cloneable: boolean,
args: Object,
xPos: number = null,
yPos: number = null,
width: number = null,
height: number = null,
): Action {
args,
xPos = null,
yPos = null,
width = null,
height = null,
) {
return {
type: 'OPEN_WINDOW',
windowType,
@ -580,7 +571,7 @@ export function openWindow(
};
}
export function showModal(modalType: string, title: string): Action {
export function showModal(modalType, title) {
return openWindow(
modalType,
title,
@ -590,14 +581,14 @@ export function showModal(modalType: string, title: string): Action {
);
}
export function showSettingsModal(): Action {
export function showSettingsModal() {
return showModal(
'SETTINGS',
'',
);
}
export function showUserAreaModal(): Action {
export function showUserAreaModal() {
return showModal(
'USERAREA',
'',
@ -621,34 +612,34 @@ export function setWindowTitle(windowId, title) {
};
}
export function showRegisterModal(): Action {
export function showRegisterModal() {
return showModal(
'REGISTER',
t`Register New Account`,
);
}
export function showForgotPasswordModal(): Action {
export function showForgotPasswordModal() {
return showModal(
'FORGOT_PASSWORD',
t`Restore my Password`,
);
}
export function showHelpModal(): Action {
export function showHelpModal() {
return showModal(
'HELP',
t`Welcome to PixelPlanet.fun`,
);
}
export function showArchiveModal(): Action {
export function showArchiveModal() {
return showModal(
'ARCHIVE',
t`Look at past Canvases`,
);
}
export function showCanvasSelectionModal(): Action {
export function showCanvasSelectionModal() {
return showModal(
'CANVAS_SELECTION',
'',
@ -656,11 +647,11 @@ export function showCanvasSelectionModal(): Action {
}
export function showContextMenu(
menuType: string,
xPos: number,
yPos: number,
args: Object,
): Action {
menuType,
xPos,
yPos,
args,
) {
return {
type: 'SHOW_CONTEXT_MENU',
menuType,
@ -670,28 +661,28 @@ export function showContextMenu(
};
}
export function openChatChannel(cid: number): Action {
export function openChatChannel(cid) {
return {
type: 'OPEN_CHAT_CHANNEL',
cid,
};
}
export function closeChatChannel(cid: number): Action {
export function closeChatChannel(cid) {
return {
type: 'CLOSE_CHAT_CHANNEL',
cid,
};
}
export function addChatChannel(channel: Object): Action {
export function addChatChannel(channel) {
return {
type: 'ADD_CHAT_CHANNEL',
channel,
};
}
export function blockUser(userId: number, userName: string): Action {
export function blockUser(userId, userName) {
return {
type: 'BLOCK_USER',
userId,
@ -699,7 +690,7 @@ export function blockUser(userId: number, userName: string): Action {
};
}
export function unblockUser(userId: number, userName: string): Action {
export function unblockUser(userId, userName) {
return {
type: 'UNBLOCK_USER',
userId,
@ -707,35 +698,35 @@ export function unblockUser(userId: number, userName: string): Action {
};
}
export function blockingDm(blockDm: boolean): Action {
export function blockingDm(blockDm: boolean) {
return {
type: 'SET_BLOCKING_DM',
blockDm,
};
}
export function removeChatChannel(cid: number): Action {
export function removeChatChannel(cid) {
return {
type: 'REMOVE_CHAT_CHANNEL',
cid,
};
}
export function muteChatChannel(cid: number): Action {
export function muteChatChannel(cid) {
return {
type: 'MUTE_CHAT_CHANNEL',
cid,
};
}
export function unmuteChatChannel(cid: number): Action {
export function unmuteChatChannel(cid) {
return {
type: 'UNMUTE_CHAT_CHANNEL',
cid,
};
}
export function setChatChannel(windowId: number, cid: number): Action {
export function setChatChannel(windowId, cid) {
return {
type: 'SET_CHAT_CHANNEL',
windowId,
@ -743,7 +734,7 @@ export function setChatChannel(windowId: number, cid: number): Action {
};
}
export function setChatInputMessage(windowId: number, msg: string): Action {
export function setChatInputMessage(windowId, msg) {
return {
type: 'SET_CHAT_INPUT_MSG',
windowId,
@ -751,7 +742,7 @@ export function setChatInputMessage(windowId: number, msg: string): Action {
};
}
export function addToChatInputMessage(windowId: number, msg: string): Action {
export function addToChatInputMessage(windowId, msg) {
return {
type: 'ADD_CHAT_INPUT_MSG',
windowId,
@ -759,48 +750,48 @@ export function addToChatInputMessage(windowId: number, msg: string): Action {
};
}
export function closeWindow(windowId): Action {
export function closeWindow(windowId) {
return {
type: 'CLOSE_WINDOW',
windowId,
};
}
export function removeWindow(windowId): Action {
export function removeWindow(windowId) {
return {
type: 'REMOVE_WINDOW',
windowId,
};
}
export function focusWindow(windowId): Action {
export function focusWindow(windowId) {
return {
type: 'FOCUS_WINDOW',
windowId,
};
}
export function cloneWindow(windowId): Action {
export function cloneWindow(windowId) {
return {
type: 'CLONE_WINDOW',
windowId,
};
}
export function maximizeWindow(windowId): Action {
export function maximizeWindow(windowId) {
return {
type: 'MAXIMIZE_WINDOW',
windowId,
};
}
export function restoreWindow(): Action {
export function restoreWindow() {
return {
type: 'RESTORE_WINDOW',
};
}
export function moveWindow(windowId, xDiff, yDiff): Action {
export function moveWindow(windowId, xDiff, yDiff) {
return {
type: 'MOVE_WINDOW',
windowId,
@ -809,7 +800,7 @@ export function moveWindow(windowId, xDiff, yDiff): Action {
};
}
export function resizeWindow(windowId, xDiff, yDiff): Action {
export function resizeWindow(windowId, xDiff, yDiff) {
return {
type: 'RESIZE_WINDOW',
windowId,
@ -818,7 +809,7 @@ export function resizeWindow(windowId, xDiff, yDiff): Action {
};
}
export function closeAllWindowTypes(windowType: string): Action {
export function closeAllWindowTypes(windowType) {
return {
type: 'CLOSE_ALL_WINDOW_TYPE',
windowType,
@ -826,9 +817,9 @@ export function closeAllWindowTypes(windowType: string): Action {
}
export function hideAllWindowTypes(
windowType: string,
windowType,
hide: boolean,
): Action {
) {
return {
type: 'HIDE_ALL_WINDOW_TYPE',
windowType,
@ -836,7 +827,7 @@ export function hideAllWindowTypes(
};
}
export function openChatWindow(): Action {
export function openChatWindow() {
return openWindow(
'CHAT',
'',
@ -851,9 +842,9 @@ export function openChatWindow(): Action {
}
/*
* query: Object with either userId: number or userName: string
* query with either userId or userName
*/
export function startDm(windowId, query): PromiseAction {
export function startDm(windowId, query) {
return async (dispatch) => {
dispatch(setApiFetching(true));
const res = await requestStartDm(query);
@ -873,7 +864,7 @@ export function startDm(windowId, query): PromiseAction {
};
}
export function gotCoolDownDelta(delta: number) {
export function gotCoolDownDelta(delta) {
return {
type: 'COOLDOWN_DELTA',
delta,
@ -881,8 +872,8 @@ export function gotCoolDownDelta(delta: number) {
}
export function setUserBlock(
userId: number,
userName: string,
userId,
userName,
block: boolean,
) {
return async (dispatch) => {
@ -925,7 +916,7 @@ export function setBlockingDm(
}
export function setLeaveChannel(
cid: number,
cid,
) {
return async (dispatch) => {
dispatch(setApiFetching(true));
@ -944,25 +935,25 @@ export function setLeaveChannel(
};
}
export function hideContextMenu(): Action {
export function hideContextMenu() {
return {
type: 'HIDE_CONTEXT_MENU',
};
}
export function reloadUrl(): Action {
export function reloadUrl() {
return {
type: 'RELOAD_URL',
};
}
export function onViewFinishChange(): Action {
export function onViewFinishChange() {
return {
type: 'ON_VIEW_FINISH_CHANGE',
};
}
export function selectHistoricalTime(date: string, time: string) {
export function selectHistoricalTime(date, time) {
return {
type: 'SET_HISTORICAL_TIME',
date,
@ -970,7 +961,7 @@ export function selectHistoricalTime(date: string, time: string) {
};
}
export function urlChange(): PromiseAction {
export function urlChange() {
return (dispatch) => {
dispatch(reloadUrl());
};

View File

@ -1,6 +1,5 @@
/* @flow */
import type { Cell } from '../core/Cell';
import type { ColorIndex } from '../core/Palette';
import type { State } from '../reducers';
@ -30,7 +29,7 @@ export type Action =
| { type: 'SET_NOTIFICATION', notification: string }
| { type: 'UNSET_NOTIFICATION' }
| { type: 'SET_REQUESTING_PIXEL', requestingPixel: boolean }
| { type: 'SET_HOVER', hover: Cell }
| { type: 'SET_HOVER', hover: Array }
| { type: 'UNSET_HOVER' }
| { type: 'SET_WAIT', wait: ?number }
| { type: 'RECEIVE_COOLDOWN', wait: number }
@ -44,12 +43,12 @@ export type Action =
| { type: 'PLACED_PIXELS', amount: number }
| { type: 'PIXEL_WAIT' }
| { type: 'PIXEL_FAILURE' }
| { type: 'SET_VIEW_COORDINATES', view: Cell }
| { type: 'SET_SCALE', scale: number, zoompoint: Cell }
| { type: 'REQUEST_BIG_CHUNK', center: Cell }
| { type: 'PRE_LOADED_BIG_CHUNK', center: Cell }
| { type: 'RECEIVE_BIG_CHUNK', center: Cell, chunk: Uint8Array }
| { type: 'RECEIVE_BIG_CHUNK_FAILURE', center: Cell, error: Error }
| { type: 'SET_VIEW_COORDINATES', view: Array }
| { type: 'SET_SCALE', scale: number, zoompoint: Array }
| { type: 'REQUEST_BIG_CHUNK', center: Array }
| { type: 'PRE_LOADED_BIG_CHUNK', center: Array }
| { type: 'RECEIVE_BIG_CHUNK', center: Array, chunk: Uint8Array }
| { type: 'RECEIVE_BIG_CHUNK_FAILURE', center: Array, error: Error }
| { type: 'UPDATE_PIXEL',
i: number,
j: number,

View File

@ -1,4 +0,0 @@
/* @flow */
export type Index = number; // TODO integer >= 0
export type Cell = [number, number, number];

View File

@ -1,8 +1,8 @@
/* @flow */
/*
* draw pixel on canvas
*/
import { using } from 'bluebird';
import type { User } from '../data/models';
import { redlock } from '../data/redis';
import {
getPixelFromChunkOffset,
@ -34,12 +34,12 @@ import { THREE_CANVAS_HEIGHT, THREE_TILE_SIZE, TILE_SIZE } from './constants';
* @return Promise<Object>
*/
export async function drawByOffsets(
user: User,
canvasId: number,
i: number,
j: number,
pixels: Array,
): Promise<Object> {
user,
canvasId,
i,
j,
pixels,
) {
let wait = 0;
let coolDown = 0;
let retCode = 0;
@ -199,13 +199,13 @@ export async function drawByOffsets(
* @returns {Promise.<Object>}
*/
export async function drawByCoords(
user: User,
canvasId: number,
color: ColorIndex,
x: number,
y: number,
z: number = null,
): Promise<Object> {
user,
canvasId,
color,
x,
y,
z = null,
) {
if (!({}.hasOwnProperty.call(canvases, canvasId))) {
return {
error: 'This canvas does not exist',
@ -369,13 +369,13 @@ export async function drawByCoords(
* @param z (optional for 3d canvas)
*/
export function drawSafeByCoords(
user: User,
canvasId: number,
color: ColorIndex,
x: number,
y: number,
z: number = null,
): Promise<Object> {
user,
canvasId,
color,
x,
y,
z = null,
) {
// can just check for one unique occurence,
// we use ip, because id for logged out users is
// always null
@ -407,12 +407,12 @@ export function drawSafeByCoords(
* @return Promise<Object>
*/
export function drawSafeByOffsets(
user: User,
canvasId: number,
i: number,
j: number,
pixels: Array,
): Promise<Object> {
user,
canvasId,
i,
j,
pixels,
) {
// can just check for one unique occurence,
// we use ip, because id for logged out users is
// always null

View File

@ -1,7 +1,6 @@
/*
* Set pixels on canvas.
* Pixels get collected in a cache for 5ms and sent to players at once.
* @flow
* */
import RedisCanvas from '../data/models/RedisCanvas';
import {
@ -22,11 +21,11 @@ import canvases from './canvases.json';
* @param offset Offset of pixel withing chunk
*/
export function setPixelByOffset(
canvasId: number,
color: ColorIndex,
i: number,
j: number,
offset: number,
canvasId,
color,
i,
j,
offset,
) {
RedisCanvas.setPixelInChunk(i, j, offset, color, canvasId);
pixelCache.append(canvasId, color, i, j, offset);
@ -42,11 +41,11 @@ export function setPixelByOffset(
* @param z optional, if given its 3d canvas
*/
export function setPixelByCoords(
canvasId: number,
color: ColorIndex,
x: number,
y: number,
z: number = null,
canvasId,
color,
x,
y,
z = null,
) {
const canvasSize = canvases[canvasId].size;
const [i, j] = getChunkOfPixel(canvasSize, x, y, z);

View File

@ -1,12 +1,10 @@
/* @flow
*
/*
* creation of tiles
*
*/
import fs from 'fs';
import type { Cell } from './Cell';
import logger from './logger';
// eslint-disable-next-line import/no-unresolved
import canvases from './canvases.json';
@ -31,14 +29,14 @@ import { mod, getMaxTiledZoom } from './utils';
const CanvasUpdaters = {};
class CanvasUpdater {
TileLoadingQueues: Array;
palette: Palette;
id: number;
canvas: Object;
firstZoomtileWidth: number;
canvasTileFolder: string;
TileLoadingQueues;
palette;
id;
canvas;
firstZoomtileWidth;
canvasTileFolder;
constructor(id: number) {
constructor(id) {
this.updateZoomlevelTiles = this.updateZoomlevelTiles.bind(this);
this.TileLoadingQueues = [];
@ -54,7 +52,7 @@ class CanvasUpdater {
/*
* @param zoom tilezoomlevel to update
*/
async updateZoomlevelTiles(zoom: number) {
async updateZoomlevelTiles(zoom) {
const queue = this.TileLoadingQueues[zoom];
if (typeof queue === 'undefined') return;
@ -104,7 +102,7 @@ class CanvasUpdater {
* register changed chunk, queue corespongind tile to reload
* @param chunk Chunk coordinates
*/
registerChunkChange(chunk: Cell) {
registerChunkChange(chunk) {
const queue = this.TileLoadingQueues[Math.max(this.maxTiledZoom - 1, 0)];
if (typeof queue === 'undefined') return;
@ -154,7 +152,7 @@ class CanvasUpdater {
}
}
export function registerChunkChange(canvasId: number, chunk: Cell) {
export function registerChunkChange(canvasId, chunk) {
if (CanvasUpdaters[canvasId]) {
CanvasUpdaters[canvasId].registerChunkChange(chunk);
}

View File

@ -1,7 +1,3 @@
/* @flow */
import type { Cell } from './Cell';
import type { State } from '../reducers';
import {
TILE_SIZE,
@ -15,7 +11,7 @@ import {
* @param m
* @returns {number} remainder
*/
export function mod(n: number, m: number): number {
export function mod(n, m) {
return ((n % m) + m) % m;
}
@ -30,18 +26,18 @@ export function getRandomInt(min, max) {
return min + (Math.floor(Math.random() * range));
}
export function distMax([x1, y1]: Cell, [x2, y2]: Cell): number {
export function distMax([x1, y1], [x2, y2]) {
return Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2));
}
export function clamp(n: number, min: number, max: number): number {
export function clamp(n, min, max) {
return Math.max(min, Math.min(n, max));
}
/*
* convert YYYY-MM-DD to YYYYMMDD
*/
export function dateToString(date: string) {
export function dateToString(date) {
// YYYY-MM-DD
return date.substr(0, 4) + date.substr(5, 2) + date.substr(8, 2);
}
@ -61,11 +57,11 @@ export function getToday() {
// z is assumed to be height here
// in ui and rendeer, y is height
export function getChunkOfPixel(
canvasSize: number,
x: number,
y: number,
z: number = null,
): Cell {
canvasSize,
x,
y,
z = null,
) {
const tileSize = (z === null) ? TILE_SIZE : THREE_TILE_SIZE;
const width = (z == null) ? y : z;
const cx = Math.floor((x + (canvasSize / 2)) / tileSize);
@ -74,25 +70,25 @@ export function getChunkOfPixel(
}
export function getTileOfPixel(
tileScale: number,
pixel: Cell,
canvasSize: number = null,
): Cell {
tileScale,
pixel,
canvasSize = null,
) {
const target = pixel.map(
(x) => Math.floor((x + canvasSize / 2) / TILE_SIZE * tileScale),
);
return target;
}
export function getMaxTiledZoom(canvasSize: number): number {
export function getMaxTiledZoom(canvasSize) {
if (!canvasSize) return 0;
return Math.log2(canvasSize / TILE_SIZE) / TILE_ZOOM_LEVEL * 2;
}
export function getHistoricalCanvasSize(
historicalDate: string,
canvasSize: number,
historicalSizes: Array,
historicalDate,
canvasSize,
historicalSizes,
) {
if (historicalDate && historicalSizes) {
let i = historicalSizes.length;
@ -107,7 +103,7 @@ export function getHistoricalCanvasSize(
return canvasSize;
}
export function getCanvasBoundaries(canvasSize: number): number {
export function getCanvasBoundaries(canvasSize) {
const canvasMinXY = -canvasSize / 2;
const canvasMaxXY = canvasSize / 2 - 1;
return [canvasMinXY, canvasMaxXY];
@ -116,11 +112,11 @@ export function getCanvasBoundaries(canvasSize: number): number {
// z is assumed to be height here
// in ui and rendeer, y is height
export function getOffsetOfPixel(
canvasSize: number,
x: number,
y: number,
z: number = null,
): number {
canvasSize,
x,
y,
z = null,
) {
const tileSize = (z === null) ? TILE_SIZE : THREE_TILE_SIZE;
const width = (z == null) ? y : z;
let offset = (z === null) ? 0 : (y * tileSize * tileSize);
@ -138,7 +134,7 @@ export function getOffsetOfPixel(
* @param ident ident string
* @return key
*/
export function getIdFromObject(obj: Object, ident: string): number {
export function getIdFromObject(obj, ident) {
const ids = Object.keys(obj);
for (let i = 0; i < ids.length; i += 1) {
const key = ids[i];
@ -152,12 +148,12 @@ export function getIdFromObject(obj: Object, ident: string): number {
// z is returned as height here
// in ui and rendeer, y is height
export function getPixelFromChunkOffset(
i: number,
j: number,
offset: number,
canvasSize: number,
i,
j,
offset,
canvasSize,
is3d: boolean = false,
): Cell {
) {
const tileSize = (is3d) ? THREE_TILE_SIZE : TILE_SIZE;
const cx = offset % tileSize;
const off = offset - cx;
@ -172,17 +168,17 @@ export function getPixelFromChunkOffset(
}
export function getCellInsideChunk(
canvasSize: number,
pixel: Cell,
): Cell {
canvasSize,
pixel,
) {
return pixel.map((x) => mod(x + canvasSize / 2, TILE_SIZE));
}
export function screenToWorld(
state: State,
$viewport: HTMLCanvasElement,
[x, y]: Cell,
): Cell {
state,
$viewport,
[x, y],
) {
const { view, viewscale } = state.canvas;
const [viewX, viewY] = view;
const { width, height } = $viewport;
@ -193,10 +189,10 @@ export function screenToWorld(
}
export function worldToScreen(
state: State,
$viewport: HTMLCanvasElement,
[x, y]: Cell,
): Cell {
state,
$viewport,
[x, y],
) {
const { view, viewscale } = state.canvas;
const [viewX, viewY] = view;
const { width, height } = $viewport;
@ -207,11 +203,11 @@ export function worldToScreen(
}
export function durationToString(
ms: number,
ms,
smallest: boolean = false,
): string {
) {
const seconds = Math.ceil(ms / 1000);
let timestring: string;
let timestring;
if (seconds < 60 && smallest) {
timestring = seconds;
} else {
@ -222,7 +218,7 @@ export function durationToString(
}
const postfix = ['k', 'M', 'B'];
export function numberToString(num: number): string {
export function numberToString(num) {
if (!num) {
return 'N/A';
}
@ -246,7 +242,7 @@ export function numberToString(num: number): string {
return '';
}
export function numberToStringFull(num: number): string {
export function numberToStringFull(num) {
if (num < 0) {
return `${num} :-(`;
} if (num < 1000) {
@ -262,7 +258,7 @@ export function numberToStringFull(num: number): string {
/*
* generates a color based on a given string
*/
export function colorFromText(str: string) {
export function colorFromText(str) {
if (!str) return '#000000';
let hash = 0;
@ -312,7 +308,7 @@ function escapeRegExp(string) {
* @param name name
* @return regular expression to search for name in message
*/
export function createNameRegExp(name: string) {
export function createNameRegExp(name) {
if (!name) return null;
return new RegExp(`(^|\\s+)(@${escapeRegExp(name)})(\\s+|$)`, 'g');
}

View File

@ -1,16 +1,4 @@
/* @flow */
import type { Action } from '../actions/types';
export type AlertState = {
alertOpen: boolean,
alertType: ?string,
alertTitle: ?string,
alertMessage: ?string,
alertBtn: ?string,
};
const initialState: AlertState = {
const initialState = {
alertOpen: false,
alertType: null,
alertTitle: null,
@ -19,9 +7,9 @@ const initialState: AlertState = {
};
export default function alert(
state: AlertState = initialState,
action: Action,
): AlertState {
state = initialState,
action,
) {
switch (action.type) {
case 'ALERT': {
const {

View File

@ -1,23 +1,15 @@
/* @flow */
import type { Action } from '../actions/types';
export type AudioState = {
mute: boolean,
chatNotify: boolean,
};
const initialState: AudioState = {
const initialState = {
mute: false,
chatNotify: true,
};
export default function audio(
state: AudioState = initialState,
action: Action,
): AudioState {
state = initialState,
action,
) {
switch (action.type) {
case 'TOGGLE_MUTE':
return {

View File

@ -1,8 +1,3 @@
/* @flow */
import type { Action } from '../actions/types';
import type { Cell } from '../core/Cell';
import type { ColorIndex } from '../core/Palette';
import Palette from '../core/Palette';
import {
clamp,
@ -23,13 +18,13 @@ import {
export type CanvasState = {
canvasId: number,
canvasIdent: string,
selectedColor: ColorIndex,
selectedColor: number,
is3D: boolean,
canvasSize: number,
canvasStartDate: string,
palette: Palette,
clrIgnore: number,
view: Cell,
view: Array,
scale: number,
viewscale: number,
isHistoricalView: boolean,
@ -135,7 +130,7 @@ function getViewFromURL(canvases: Object) {
}
}
const initialState: CanvasState = {
const initialState = {
...getViewFromURL(DEFAULT_CANVASES),
isHistoricalView: false,
historicalDate: null,
@ -146,8 +141,8 @@ const initialState: CanvasState = {
export default function canvasReducer(
state: CanvasState = initialState,
action: Action,
state = initialState,
action,
): CanvasState {
switch (action.type) {
case 'SET_SCALE': {

View File

@ -1,10 +1,6 @@
/* @flow */
import { MAX_CHAT_MESSAGES } from '../core/constants';
import type { Action } from '../actions/types';
export type ChatState = {
const initialState = {
/*
* {
* cid: [
@ -21,23 +17,17 @@ export type ChatState = {
* ...
* }
*/
channels: Object,
// [[uId, userName], [userId2, userName2],...]
blocked: Array,
// { cid: [message1,message2,message3,...]}
messages: Object,
}
const initialState: ChatState = {
channels: {},
// [[uId, userName], [userId2, userName2],...]
blocked: [],
// { cid: [message1,message2,message3,...]}
messages: {},
};
export default function chat(
state: ChatState = initialState,
action: Action,
): ChatState {
state = initialState,
action,
) {
switch (action.type) {
case 'RECEIVE_ME':
case 'LOGIN': {

View File

@ -1,36 +1,27 @@
/*
* local save state for chat stuff
*
* @flow
*/
import type { Action } from '../actions/types';
const TIME_DIFF_THREASHOLD = 15000;
export type ChatReadState = {
const initialState = {
// channels that are muted
// [cid, cid2, ...]
mute: Array,
mute: [],
// timestamps of last read
// {cid: lastTs, ...}
readTs: Object,
readTs: {},
// booleans if channel is unread
// {cid: unread, ...}
unread: Object,
};
const initialState: ChatReadState = {
mute: [],
readTs: {},
unread: {},
};
export default function chatRead(
state: ModalState = initialState,
action: Action,
): ChatReadState {
state = initialState,
action,
) {
switch (action.type) {
case 'RECEIVE_ME':
case 'LOGIN': {

View File

@ -1,20 +1,9 @@
/**
* https://stackoverflow.com/questions/35623656/how-can-i-display-a-modal-dialog-in-redux-that-performs-asynchronous-actions/35641680#35641680
*
* @flow
*/
import type { Action } from '../actions/types';
export type ContextMenuState = {
menuOpen: boolean,
menuType: ?string,
xPos: number,
yPos: number,
args: Object,
};
const initialState: ContextMenuState = {
const initialState = {
menuOpen: false,
menuType: null,
xPos: 0,
@ -24,9 +13,9 @@ const initialState: ContextMenuState = {
export default function contextMenu(
state: ModalState = initialState,
action: Action,
): ContextMenuState {
state = initialState,
action,
) {
switch (action.type) {
case 'SHOW_CONTEXT_MENU': {
const {

View File

@ -1,27 +1,18 @@
/*
* keeps track of some api fetching states
*
* @flow
*/
import type { Action } from '../actions/types';
export type FetchingState = {
fetchingChunks: number,
fetchingChat: boolean,
fetchinApi: boolean,
}
const initialState: FetchingState = {
const initialState = {
fetchingChunks: 0,
fetchingChat: false,
fetchinApi: false,
};
export default function fetching(
state: FetchingState = initialState,
action: Action,
): FetchingState {
state = initialState,
action,
) {
switch (action.type) {
case 'SET_CHAT_FETCHING': {
const { fetching: fetchingChat } = action;

View File

@ -1,23 +1,4 @@
/* @flow */
import type { Action } from '../actions/types';
import type { Cell } from '../core/Cell';
export type GUIState = {
showGrid: boolean,
showPixelNotify: boolean,
hover: ?Cell,
autoZoomIn: boolean,
isPotato: boolean,
isLightGrid: boolean,
compactPalette: boolean,
paletteOpen: boolean,
menuOpen: boolean,
style: string,
};
const initialState: GUIState = {
const initialState = {
showGrid: false,
showPixelNotify: false,
hover: null,
@ -32,9 +13,9 @@ const initialState: GUIState = {
export default function gui(
state: GUIState = initialState,
action: Action,
): GUIState {
state = initialState,
action,
) {
switch (action.type) {
case 'TOGGLE_GRID': {
return {

View File

@ -14,29 +14,6 @@ import contextMenu from './contextMenu';
import chatRead from './chatRead';
import fetching from './fetching';
import type { AudioState } from './audio';
import type { CanvasState } from './canvas';
import type { GUIState } from './gui';
import type { UserState } from './user';
import type { RanksState } from './ranks';
import type { AlertState } from './alert';
import type { ChatState } from './chat';
import type { ContextMenuState } from './contextMenu';
import type { FetchingState } from './fetching';
export type State = {
audio: AudioState,
canvas: CanvasState,
gui: GUIState,
user: UserState,
ranks: RanksState,
alert: AlertState,
chat: ChatState,
contextMenu: ContextMenuState,
chatRead: ChatReadState,
fetching: FetchingState,
};
const config = {
key: 'primary',
storage: localForage,

View File

@ -1,32 +1,19 @@
/* @flow */
import type { Action } from '../actions/types';
export type RanksState = {
totalPixels: number,
dailyTotalPixels: number,
ranking: number,
dailyRanking: number,
// global stats
online: ?number,
totalRanking: Object,
totalDailyRanking: Object,
};
const initialState: RanksState = {
const initialState = {
totalPixels: 0,
dailyTotalPixels: 0,
ranking: 1488,
dailyRanking: 1488,
// global stats
online: 1,
totalRanking: {},
totalDailyRanking: {},
};
export default function ranks(
state: RanksState = initialState,
action: Action,
): RanksState {
state = initialState,
action,
) {
switch (action.type) {
case 'PLACED_PIXELS': {
let { totalPixels, dailyTotalPixels } = state;

View File

@ -1,55 +1,31 @@
/* @flow */
import type { Action } from '../actions/types';
import { createNameRegExp } from '../core/utils';
export type UserState = {
name: string,
center: Cell,
wait: ?Date,
coolDown: ?number, // ms
lastCoolDownEnd: ?Date,
requestingPixel: boolean,
// messages are sent by api/me, like not_verified status
messages: Array,
mailreg: boolean,
// minecraft
minecraftname: string,
// blocking all Dms
blockDm: boolean,
// if user is using touchscreen
isOnMobile: boolean,
// small notifications for received cooldown
notification: string,
// 1: Admin, 2: Mod, 0: ordinary user
userlvl: number,
// regExp for detecting ping
nameRegExp: RegExp,
};
const initialState: UserState = {
const initialState = {
name: null,
center: [0, 0],
wait: null,
coolDown: null,
coolDown: null, // ms
lastCoolDownEnd: null,
requestingPixel: true,
// messages are sent by api/me, like not_verified status
messages: [],
mailreg: false,
minecraftname: null,
// blocking all Dms
blockDm: false,
// if user is using touchscreen
isOnMobile: false,
// small notifications for received cooldown
notification: null,
// 1: Admin, 2: Mod, 0: ordinary user
userlvl: 0,
// regExp for detecting ping
nameRegExp: null,
};
export default function user(
state: UserState = initialState,
action: Action,
): UserState {
state = initialState,
action,
) {
switch (action.type) {
case 'COOLDOWN_SET': {
const { coolDown } = action;
@ -112,7 +88,6 @@ export default function user(
const {
name,
mailreg,
minecraftname,
blockDm,
userlvl,
} = action;
@ -123,7 +98,6 @@ export default function user(
name,
messages,
mailreg,
minecraftname,
blockDm,
userlvl,
nameRegExp,
@ -136,7 +110,6 @@ export default function user(
name: null,
messages: [],
mailreg: false,
minecraftname: null,
blockDm: false,
userlvl: 0,
nameRegExp: null,
@ -161,14 +134,6 @@ export default function user(
};
}
case 'SET_MINECRAFT_NAME': {
const { minecraftname } = action;
return {
...state,
minecraftname,
};
}
case 'SET_NOTIFICATION': {
return {
...state,

View File

@ -1,11 +1,7 @@
/*
* state for open windows and modal and its content
*
* @flow
*/
import type { Action } from '../actions/types';
import { clamp } from '../core/utils';
const SCREEN_MARGIN_S = 30;
@ -87,17 +83,17 @@ function sortWindows(newState) {
return newState;
}
export type WindowsState = {
const initialState = {
// if windows get shown, false on small screens
showWindows: boolean,
showWindows: true,
// highest zIndex of window
zMax: number,
zMax: 0,
// modal is considerd as "fullscreen window"
// its windowId is considered 0 and args are under args[0]
modal: {
windowType: ?string,
title: ?string,
open: boolean,
windowType: null,
title: null,
open: false,
// used to remember and restore the size
// of a maximized window when restoring
// {
@ -107,7 +103,7 @@ export type WindowsState = {
// height: number,
// cloneable: boolean,
// }
prevWinSize: Object,
prevWinSize: {},
},
// [
// {
@ -124,32 +120,19 @@ export type WindowsState = {
// cloneable: boolean,
// },
// ]
windows: Array,
windows: [],
// {
// windowId: {
// ...
// }
// }
args: Object,
}
const initialState: WindowsState = {
showWindows: true,
zMax: 0,
modal: {
windowType: null,
title: null,
open: false,
prevWinSize: {},
},
windows: [],
args: {},
};
export default function windows(
state: WindowsState = initialState,
action: Action,
): WindowsState {
state = initialState,
action,
) {
switch (action.type) {
case 'OPEN_WINDOW': {
/*

View File

@ -1,8 +1,3 @@
/* @flow */
import type { Cell } from '../core/Cell';
import type { Palette } from '../core/Palette';
import { TILE_SIZE } from '../core/constants';
@ -11,10 +6,10 @@ class ChunkRGB {
image: HTMLCanvasElement;
ready: boolean;
timestamp: number;
palette: Palette;
palette;
isBasechunk: boolean;
constructor(palette: Palette, zoom = 0, cx = 0, cy = 0) {
constructor(palette, zoom = 0, cx = 0, cy = 0) {
// isBasechunk gets set to true by RECEIVE_BIG_CHUNK
// if true => chunk got requested from api/chunk and
// receives websocket pixel updates
@ -79,11 +74,11 @@ class ChunkRGB {
}
}
static getIndexFromCell([x, y]: Cell): number {
static getIndexFromCell([x, y]): number {
return x + (TILE_SIZE * y);
}
getColorIndex(cell: Cell): ColorIndex {
getColorIndex(cell) {
const [x, y] = cell;
const ctx = this.image.getContext('2d');
@ -91,7 +86,7 @@ class ChunkRGB {
return this.palette.getClosestIndexOfColor(rgb[0], rgb[1], rgb[2]);
}
hasColorIn(cell: Cell, color: ColorIndex): boolean {
hasColorIn(cell, color): boolean {
const index = ChunkRGB.getIndexFromCell(cell);
const ctx = this.image.getContext('2d');
@ -101,7 +96,7 @@ class ChunkRGB {
return (intView[index] === this.palette.abgr[color]);
}
setColor(cell: Cell, color: ColorIndex): boolean {
setColor(cell, color): boolean {
const [x, y] = cell;
const ctx = this.image.getContext('2d');
ctx.fillStyle = this.palette.colors[color];

View File

@ -1,11 +1,8 @@
/*
* Renders 2D canvases
*
* @flow
*/
import type { Cell } from '../core/Cell';
import type { State } from '../reducers';
import { TILE_ZOOM_LEVEL, TILE_SIZE } from '../core/constants';
import {
@ -42,7 +39,7 @@ class Renderer {
canvasId: number = null;
chunkLoader: Object = null;
//--
centerChunk: Cell;
centerChunk;
tiledScale: number;
tiledZoom: number;
hover: boolean;
@ -120,7 +117,7 @@ class Renderer {
this.controls = new PixelPainterControls(this, this.viewport, store);
}
updateCanvasData(state: State) {
updateCanvasData(state) {
const {
canvasId,
} = state.canvas;
@ -238,9 +235,9 @@ class Renderer {
i: number,
j: number,
offset: number,
color: ColorIndex,
color,
) {
const state: State = this.store.getState();
const state = this.store.getState();
const {
canvasSize,
palette,
@ -299,7 +296,7 @@ class Renderer {
renderChunks(
state: State,
state,
) {
const context = this.canvas.getContext('2d');
if (!context) return;
@ -400,7 +397,7 @@ class Renderer {
if (!this.chunkLoader) {
return;
}
const state: State = this.store.getState();
const state = this.store.getState();
if (state.canvas.isHistoricalView) {
this.renderHistorical(state);
} else {
@ -412,7 +409,7 @@ class Renderer {
// keep in mind that everything we got here gets executed 60 times per second
// avoiding unneccessary stuff is important
renderMain(
state: State,
state,
) {
const {
viewport,
@ -533,7 +530,7 @@ class Renderer {
renderHistoricalChunks(
state: State,
state,
) {
const context = this.canvas.getContext('2d');
if (!context) return;
@ -662,7 +659,7 @@ class Renderer {
// keep in mind that everything we got here gets executed 60 times per second
// avoiding unneccessary stuff is important
renderHistorical(
state: State,
state,
) {
const {
viewport,

View File

@ -229,7 +229,7 @@ class Renderer {
return this.threeRenderer.domElement;
}
updateCanvasData(state: State) {
updateCanvasData(state) {
const {
canvasId,
view,

View File

@ -65,10 +65,10 @@ export function requestFromQueue(store) {
export function receivePixelUpdate(
store,
i: number,
j: number,
offset: number,
color: ColorIndex,
i,
j,
offset,
color,
) {
for (let p = 0; p < clientPredictions.length; p += 1) {
const predPxl = clientPredictions[p];
@ -91,9 +91,9 @@ export function receivePixelUpdate(
*/
function revertPredictionsAt(
store,
sI: number,
sJ: number,
sOffset: number,
sI,
sJ,
sOffset,
) {
let p = 0;
while (p < clientPredictions.length) {
@ -123,11 +123,11 @@ function revertPredictionsAt(
export function tryPlacePixel(
store,
i: number,
j: number,
offset: number,
color: ColorIndex,
curColor: ColorIndex,
i,
j,
offset,
color,
curColor,
) {
store.dispatch(updatePixel(i, j, offset, color));
clientPredictions.push([i, j, offset, curColor, color]);
@ -155,9 +155,9 @@ export function tryPlacePixel(
export function receivePixelReturn(
store,
retCode: number,
wait: number,
coolDownSeconds: number,
retCode,
wait,
coolDownSeconds,
pxlCnt,
) {
clearTimeout(pixelTimeout);