reorganize store

This commit is contained in:
HF 2022-07-11 14:42:09 +02:00
parent 4612384a7d
commit 2789cd2a54
71 changed files with 123 additions and 160 deletions

View File

@ -17,7 +17,7 @@ import {
removeChatChannel, removeChatChannel,
setMobile, setMobile,
windowResize, windowResize,
} from './actions'; } from './store/actions';
import { import {
receivePixelUpdate, receivePixelUpdate,
receivePixelReturn, receivePixelReturn,

View File

@ -7,7 +7,7 @@ import React, { useState, useEffect, useCallback } from 'react';
import { useSelector, useDispatch } from 'react-redux'; import { useSelector, useDispatch } from 'react-redux';
import GlobalCaptcha from './GlobalCaptcha'; import GlobalCaptcha from './GlobalCaptcha';
import { closeAlert } from '../actions'; import { closeAlert } from '../store/actions';
const Alert = () => { const Alert = () => {
const [render, setRender] = useState(false); const [render, setRender] = useState(false);

View File

@ -9,7 +9,7 @@ import { t } from 'ttag';
import { import {
validateEMail, validatePassword, validateEMail, validatePassword,
} from '../utils/validation'; } from '../utils/validation';
import { requestMailChange } from '../actions/fetch'; import { requestMailChange } from '../store/actions/fetch';
function validate(email, password) { function validate(email, password) {
const errors = []; const errors = [];

View File

@ -8,8 +8,8 @@ import { t } from 'ttag';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { validateName } from '../utils/validation'; import { validateName } from '../utils/validation';
import { requestNameChange } from '../actions/fetch'; import { requestNameChange } from '../store/actions/fetch';
import { setName } from '../actions'; import { setName } from '../store/actions';
function validate(name) { function validate(name) {

View File

@ -7,9 +7,9 @@ import React, { useState } from 'react';
import { t } from 'ttag'; import { t } from 'ttag';
import { useSelector, useDispatch } from 'react-redux'; import { useSelector, useDispatch } from 'react-redux';
import { setMailreg } from '../actions'; import { setMailreg } from '../store/actions';
import { validatePassword } from '../utils/validation'; import { validatePassword } from '../utils/validation';
import { requestPasswordChange } from '../actions/fetch'; import { requestPasswordChange } from '../store/actions/fetch';
function validate(mailreg, password, newPassword, confirmPassword) { function validate(mailreg, password, newPassword, confirmPassword) {
const errors = []; const errors = [];

View File

@ -5,7 +5,7 @@
import React from 'react'; import React from 'react';
import { useSelector, useDispatch } from 'react-redux'; import { useSelector, useDispatch } from 'react-redux';
import { showContextMenu } from '../actions'; import { showContextMenu } from '../store/actions';
import { MarkdownParagraph } from './Markdown'; import { MarkdownParagraph } from './Markdown';
import { import {
colorFromText, colorFromText,

View File

@ -8,7 +8,7 @@ import { useSelector, useDispatch } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import copy from '../utils/clipboard'; import copy from '../utils/clipboard';
import { notify } from '../actions'; import { notify } from '../store/actions';
function renderCoordinates(cell): string { function renderCoordinates(cell): string {

View File

@ -8,8 +8,8 @@ import { useDispatch } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import { validatePassword } from '../utils/validation'; import { validatePassword } from '../utils/validation';
import { requestDeleteAccount } from '../actions/fetch'; import { requestDeleteAccount } from '../store/actions/fetch';
import { logoutUser } from '../actions'; import { logoutUser } from '../store/actions';
function validate(password) { function validate(password) {
const errors = []; const errors = [];

View File

@ -8,7 +8,7 @@ import React, { useState } from 'react';
import { t } from 'ttag'; import { t } from 'ttag';
import Captcha from './Captcha'; import Captcha from './Captcha';
import { requestSolveCaptcha } from '../actions/fetch'; import { requestSolveCaptcha } from '../store/actions/fetch';
const GlobalCaptcha = ({ close }) => { const GlobalCaptcha = ({ close }) => {
const [errors, setErrors] = useState([]); const [errors, setErrors] = useState([]);

View File

@ -9,8 +9,8 @@ import { useSelector, shallowEqual, useDispatch } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import { dateToString, getToday } from '../core/utils'; import { dateToString, getToday } from '../core/utils';
import { selectHistoricalTime } from '../actions'; import { selectHistoricalTime } from '../store/actions';
import { requestHistoricalTimes } from '../actions/fetch'; import { requestHistoricalTimes } from '../store/actions/fetch';
function stringToDate(dateString) { function stringToDate(dateString) {

View File

@ -6,7 +6,7 @@ import { useDispatch } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import LogInForm from './LogInForm'; import LogInForm from './LogInForm';
import { changeWindowType } from '../actions'; import { changeWindowType } from '../store/actions';
const logoStyle = { const logoStyle = {
marginRight: 5, marginRight: 5,

View File

@ -9,8 +9,8 @@ import { t } from 'ttag';
import { import {
validateEMail, validateName, validatePassword, validateEMail, validateName, validatePassword,
} from '../utils/validation'; } from '../utils/validation';
import { requestLogin } from '../actions/fetch'; import { requestLogin } from '../store/actions/fetch';
import { loginUser } from '../actions'; import { loginUser } from '../store/actions';
function validate(nameoremail, password) { function validate(nameoremail, password) {

View File

@ -14,7 +14,7 @@ import {
closeWindow, closeWindow,
restoreWindow, restoreWindow,
removeWindow, removeWindow,
} from '../actions'; } from '../store/actions';
import COMPONENTS from './windows'; import COMPONENTS from './windows';
const ModalRoot = () => { const ModalRoot = () => {

View File

@ -8,7 +8,7 @@ import { useSelector, useDispatch, shallowEqual } from 'react-redux';
import { FaUser, FaPaintBrush, FaFlipboard } from 'react-icons/fa'; import { FaUser, FaPaintBrush, FaFlipboard } from 'react-icons/fa';
import { t } from 'ttag'; import { t } from 'ttag';
import { toggleOnlineCanvas } from '../actions'; import { toggleOnlineCanvas } from '../store/actions';
import { numberToString } from '../core/utils'; import { numberToString } from '../core/utils';

View File

@ -6,7 +6,7 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { useDispatch, useSelector, shallowEqual } from 'react-redux'; import { useDispatch, useSelector, shallowEqual } from 'react-redux';
import { selectColor } from '../actions'; import { selectColor } from '../store/actions';
import useWindowSize from './hooks/resize'; import useWindowSize from './hooks/resize';

View File

@ -10,7 +10,7 @@ import { t } from 'ttag';
import { import {
setBlockingDm, setBlockingDm,
setUserBlock, setUserBlock,
} from '../actions'; } from '../store/actions';
import MdToggleButton from './MdToggleButton'; import MdToggleButton from './MdToggleButton';
const SocialSettings = ({ done }) => { const SocialSettings = ({ done }) => {

View File

@ -13,8 +13,8 @@ import ChangeName from './ChangeName';
import ChangeMail from './ChangeMail'; import ChangeMail from './ChangeMail';
import DeleteAccount from './DeleteAccount'; import DeleteAccount from './DeleteAccount';
import SocialSettings from './SocialSettings'; import SocialSettings from './SocialSettings';
import { logoutUser } from '../actions'; import { logoutUser } from '../store/actions';
import { requestLogOut } from '../actions/fetch'; import { requestLogOut } from '../store/actions/fetch';
import { numberToString } from '../core/utils'; import { numberToString } from '../core/utils';

View File

@ -6,7 +6,7 @@ import React, { useState } from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import { requestResendVerify } from '../actions/fetch'; import { requestResendVerify } from '../store/actions/fetch';
const UserMessages = () => { const UserMessages = () => {

View File

@ -17,7 +17,7 @@ import {
maximizeWindow, maximizeWindow,
cloneWindow, cloneWindow,
focusWindow, focusWindow,
} from '../actions'; } from '../store/actions';
import useDrag from './hooks/drag'; import useDrag from './hooks/drag';
import COMPONENTS from './windows'; import COMPONENTS from './windows';
@ -153,7 +153,7 @@ const Window = ({ id }) => {
> >
</div> </div>
<div <div
className="win-content" className="win-content"
key="content" key="content"
> >

View File

@ -7,7 +7,7 @@ import { useDispatch } from 'react-redux';
import { FaFlipboard } from 'react-icons/fa'; import { FaFlipboard } from 'react-icons/fa';
import { t } from 'ttag'; import { t } from 'ttag';
import { showCanvasSelectionModal } from '../../actions'; import { showCanvasSelectionModal } from '../../store/actions';
const CanvasSwitchButton = () => { const CanvasSwitchButton = () => {

View File

@ -13,7 +13,7 @@ import { t } from 'ttag';
import { import {
hideAllWindowTypes, hideAllWindowTypes,
openChatWindow, openChatWindow,
} from '../../actions'; } from '../../store/actions';
/* /*
* return [ showWindows, chatOpen, chatHiden ] * return [ showWindows, chatOpen, chatHiden ]

View File

@ -9,7 +9,7 @@ import { useSelector, useDispatch } from 'react-redux';
import { MdExpandMore, MdExpandLess } from 'react-icons/md'; import { MdExpandMore, MdExpandLess } from 'react-icons/md';
import { t } from 'ttag'; import { t } from 'ttag';
import { toggleOpenMenu } from '../../actions'; import { toggleOpenMenu } from '../../store/actions';
const ExpandMenuButton = () => { const ExpandMenuButton = () => {
const menuOpen = useSelector((state) => state.gui.menuOpen); const menuOpen = useSelector((state) => state.gui.menuOpen);

View File

@ -8,7 +8,7 @@ import { useDispatch } from 'react-redux';
import { FaQuestion } from 'react-icons/fa'; import { FaQuestion } from 'react-icons/fa';
import { t } from 'ttag'; import { t } from 'ttag';
import { showHelpModal } from '../../actions'; import { showHelpModal } from '../../store/actions';
const HelpButton = () => { const HelpButton = () => {

View File

@ -8,7 +8,7 @@ import { useDispatch } from 'react-redux';
import { MdPerson } from 'react-icons/md'; import { MdPerson } from 'react-icons/md';
import { t } from 'ttag'; import { t } from 'ttag';
import { showUserAreaModal } from '../../actions'; import { showUserAreaModal } from '../../store/actions';
const LogInButton = () => { const LogInButton = () => {

View File

@ -9,7 +9,7 @@ import { useSelector, useDispatch, shallowEqual } from 'react-redux';
import { MdPalette } from 'react-icons/md'; import { MdPalette } from 'react-icons/md';
import { t } from 'ttag'; import { t } from 'ttag';
import { toggleOpenPalette } from '../../actions'; import { toggleOpenPalette } from '../../store/actions';
const PalselButton = () => { const PalselButton = () => {
const paletteOpen = useSelector((state) => state.gui.paletteOpen); const paletteOpen = useSelector((state) => state.gui.paletteOpen);

View File

@ -8,7 +8,7 @@ import { useDispatch } from 'react-redux';
import { FaCog } from 'react-icons/fa'; import { FaCog } from 'react-icons/fa';
import { t } from 'ttag'; import { t } from 'ttag';
import { showSettingsModal } from '../../actions'; import { showSettingsModal } from '../../store/actions';
const SettingsButton = () => { const SettingsButton = () => {

View File

@ -15,7 +15,7 @@ import {
setLeaveChannel, setLeaveChannel,
muteChatChannel, muteChatChannel,
unmuteChatChannel, unmuteChatChannel,
} from '../../actions'; } from '../../store/actions';
const ChannelContextMenu = () => { const ChannelContextMenu = () => {
const wrapperRef = useRef(null); const wrapperRef = useRef(null);

View File

@ -16,7 +16,7 @@ import {
startDm, startDm,
setUserBlock, setUserBlock,
setChatChannel, setChatChannel,
} from '../../actions'; } from '../../store/actions';
import { escapeMd } from '../../core/utils'; import { escapeMd } from '../../core/utils';
const UserContextMenu = () => { const UserContextMenu = () => {

View File

@ -8,7 +8,7 @@ import { useDispatch, useSelector, shallowEqual } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import CanvasItem from '../CanvasItem'; import CanvasItem from '../CanvasItem';
import { changeWindowType, selectCanvas } from '../../actions'; import { changeWindowType, selectCanvas } from '../../store/actions';
const CanvasSelect = ({ windowId }) => { const CanvasSelect = ({ windowId }) => {

View File

@ -20,7 +20,7 @@ import {
fetchChatMessages, fetchChatMessages,
showContextMenu, showContextMenu,
setWindowTitle, setWindowTitle,
} from '../../actions'; } from '../../store/actions';
import SocketClient from '../../socket/SocketClient'; import SocketClient from '../../socket/SocketClient';

View File

@ -6,9 +6,9 @@ import React, { useState } from 'react';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import { changeWindowType } from '../../actions'; import { changeWindowType } from '../../store/actions';
import { validateEMail } from '../../utils/validation'; import { validateEMail } from '../../utils/validation';
import { requestNewPassword } from '../../actions/fetch'; import { requestNewPassword } from '../../store/actions/fetch';
function validate(email) { function validate(email) {
const errors = []; const errors = [];

View File

@ -10,9 +10,9 @@ import Captcha from '../Captcha';
import { import {
validateEMail, validateName, validatePassword, validateEMail, validateName, validatePassword,
} from '../../utils/validation'; } from '../../utils/validation';
import { requestRegistration } from '../../actions/fetch'; import { requestRegistration } from '../../store/actions/fetch';
import { changeWindowType, loginUser } from '../../actions'; import { changeWindowType, loginUser } from '../../store/actions';
function validate(name, email, password, confirmPassword) { function validate(name, email, password, confirmPassword) {

View File

@ -20,7 +20,7 @@ import {
toggleLightGrid, toggleLightGrid,
toggleHistoricalView, toggleHistoricalView,
selectStyle, selectStyle,
} from '../../actions'; } from '../../store/actions';
const flexy = { const flexy = {

View File

@ -7,7 +7,7 @@ import React, { Suspense } from 'react';
import { useSelector, useDispatch } from 'react-redux'; import { useSelector, useDispatch } from 'react-redux';
import { t } from 'ttag'; import { t } from 'ttag';
import { fetchStats } from '../../actions'; import { fetchStats } from '../../store/actions';
import useInterval from '../hooks/interval'; import useInterval from '../hooks/interval';
import LogInArea from '../LogInArea'; import LogInArea from '../LogInArea';
import Tabs from '../Tabs'; import Tabs from '../Tabs';

View File

@ -20,7 +20,7 @@ import {
moveSouth, moveSouth,
moveEast, moveEast,
onViewFinishChange, onViewFinishChange,
} from '../actions'; } from '../store/actions';
import { import {
tryPlacePixel, tryPlacePixel,
} from '../ui/placePixel'; } from '../ui/placePixel';

View File

@ -27,7 +27,7 @@ import {
import { import {
onViewFinishChange, onViewFinishChange,
setViewCoordinates, setViewCoordinates,
} from '../actions'; } from '../store/actions';
import { import {
THREE_CANVAS_HEIGHT, THREE_CANVAS_HEIGHT,
} from '../core/constants'; } from '../core/constants';

View File

@ -1,6 +1,5 @@
/* /*
* keypress actions * keypress actions
* @flow
*/ */
import { t } from 'ttag'; import { t } from 'ttag';
import store from '../ui/store'; import store from '../ui/store';
@ -13,11 +12,11 @@ import {
toggleMute, toggleMute,
notify, notify,
selectCanvas, selectCanvas,
} from '../actions'; } from '../store/actions';
const usedKeys = ['g', 'h', 'x', 'm', 'r', 'p']; const usedKeys = ['g', 'h', 'x', 'm', 'r', 'p'];
function onKeyPress(event: KeyboardEvent) { function onKeyPress(event) {
// ignore key presses if modal is open or chat is used // ignore key presses if modal is open or chat is used
if (event.target.nodeName === 'INPUT' if (event.target.nodeName === 'INPUT'
|| event.target.nodeName === 'TEXTAREA' || event.target.nodeName === 'TEXTAREA'

3
src/store/README.md Normal file
View File

@ -0,0 +1,3 @@
# Store
We use redux as a state manager of our application:
https://redux.js.org/

View File

@ -6,7 +6,7 @@
import { t } from 'ttag'; import { t } from 'ttag';
import { dateToString } from '../core/utils'; import { dateToString } from '../../core/utils';
/* /*
* Adds customizeable timeout to fetch * Adds customizeable timeout to fetch

View File

@ -1,25 +0,0 @@
/**
* Copyright 2016 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
* form for use in connection with the web services and APIs provided by
* Facebook.
*
* As with any software that integrates with the Facebook platform, your use
* of this software is subject to the Facebook Developer Principles and
* Policies [http://developers.facebook.com/policy/]. This copyright notice
* shall be included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
*/
export default () => (next) => (action) => (Array.isArray(action)
? action.map(next)
: next(action));

View File

@ -1,20 +1,18 @@
/* @flow */
import { applyMiddleware, createStore, compose } from 'redux'; import { applyMiddleware, createStore, compose } from 'redux';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
import { persistStore } from 'redux-persist'; import { persistStore } from 'redux-persist';
import audio from './audio'; import audio from './middleware/audio';
import socketClientHook from './socketClientHook'; import socketClientHook from './middleware/socketClientHook';
import rendererHook from './rendererHook'; import rendererHook from './middleware/rendererHook';
// import ads from './ads'; // import ads from './ads';
import array from './array'; import array from './middleware/array';
import promise from './promise'; import promise from './middleware/promise';
import notifications from './notifications'; import notifications from './middleware/notifications';
import title from './title'; import title from './middleware/title';
import placePixelControl from './placePixelControl'; import placePixelControl from './middleware/placePixelControl';
import extensions from './extensions'; import extensions from './middleware/extensions';
import reducers from '../reducers'; import reducers from './reducers';
const store = createStore( const store = createStore(
@ -37,9 +35,11 @@ const store = createStore(
); );
export default function configureStore(onComplete: ?() => void) { export default function configureStore(onComplete) {
persistStore(store, null, () => { persistStore(store, null, () => {
onComplete(store); if (onComplete) {
onComplete(store);
}
}); });
return store; return store;
} }

View File

@ -0,0 +1,7 @@
/*
* consume array of actions
*/
export default () => (next) => (action) => (Array.isArray(action)
? action.map(next)
: next(action));

View File

@ -1,8 +1,6 @@
/* @flow /*
* * play sounds using the HTML5 AudoContext
* play sounds using the HTML5 AudoContext */
*
* */
// iPhone needs this // iPhone needs this

View File

@ -2,7 +2,6 @@
* sends events via window.pixelPlanetEvents to potential * sends events via window.pixelPlanetEvents to potential
* Extensions and Userscripts * Extensions and Userscripts
* *
* @flow
*/ */
import EventEmitter from 'events'; import EventEmitter from 'events';

View File

@ -1,10 +1,9 @@
/* /*
* Hooks for placePixel * Hooks for placePixel
* *
* @flow
*/ */
import { requestFromQueue } from '../ui/placePixel'; import { requestFromQueue } from '../../ui/placePixel';
export default (store) => (next) => (action) => { export default (store) => (next) => (action) => {
switch (action.type) { switch (action.type) {

View File

@ -0,0 +1,13 @@
/*
* consume async function as action
*/
function warn(error) {
// eslint-disable-next-line no-console
console.warn(error.message || error);
throw error; // To let the caller handle the rejection
}
export default () => (next) => (action) => (typeof action.then === 'function'
? Promise.resolve(action).then(next, warn)
: next(action));

View File

@ -3,25 +3,13 @@
* *
*/ */
/*
* set theme-color meta tag that sets the color
* of address bars on phones
*/
/* /*
* hooks for rendering * hooks for rendering
*/ */
import { import {
getRenderer, getRenderer,
initRenderer, initRenderer,
} from '../ui/renderer'; } from '../../ui/renderer';
function setThemeColorMeta(r, g, b) {
const metaThemeColor = document.querySelector('meta[name=theme-color]');
if (metaThemeColor) {
metaThemeColor.setAttribute('content', `rgb(${r}, ${g}, ${b})`);
}
}
export default (store) => (next) => (action) => { export default (store) => (next) => (action) => {
const { type } = action; const { type } = action;
@ -63,10 +51,7 @@ export default (store) => (next) => (action) => {
case 'SELECT_CANVAS': case 'SELECT_CANVAS':
case 'RECEIVE_ME': { case 'RECEIVE_ME': {
const renderer = getRenderer(); const renderer = getRenderer();
const { is3D, palette } = state.canvas; const { is3D } = state.canvas;
const [r, g, b] = palette.rgb;
setThemeColorMeta(r, g, b);
if (is3D === renderer.is3D) { if (is3D === renderer.is3D) {
renderer.updateCanvasData(state); renderer.updateCanvasData(state);

View File

@ -1,10 +1,9 @@
/* /*
* Hooks for websocket client to store changes * Hooks for websocket client to store changes
* *
* @flow
*/ */
import SocketClient from '../socket/SocketClient'; import SocketClient from '../../socket/SocketClient';
export default (store) => (next) => (action) => { export default (store) => (next) => (action) => {
switch (action.type) { switch (action.type) {

View File

@ -1,12 +1,21 @@
/** /**
* * set URL in adress bar, theme-color and title
* @flow
*/ */
import { import {
durationToString, durationToString,
} from '../core/utils'; } from '../../core/utils';
/*
* set theme-color meta tag that sets the color
* of address bars on phones
*/
function setThemeColorMeta(r, g, b) {
const metaThemeColor = document.querySelector('meta[name=theme-color]');
if (metaThemeColor) {
metaThemeColor.setAttribute('content', `rgb(${r}, ${g}, ${b})`);
}
}
const TITLE = 'PixelPlanet.fun'; const TITLE = 'PixelPlanet.fun';
@ -35,12 +44,20 @@ export default (store) => (next) => (action) => {
case 'RECEIVE_ME': case 'RECEIVE_ME':
case 'RELOAD_URL': case 'RELOAD_URL':
case 'ON_VIEW_FINISH_CHANGE': { case 'ON_VIEW_FINISH_CHANGE': {
const state = store.getState();
const { const {
view, view,
viewscale, viewscale,
canvasIdent, canvasIdent,
is3D, is3D,
} = store.getState().canvas; } = state.canvas;
if (action.type !== 'ON_VIEW_FINISH_CHANGE') {
const [r, g, b] = state.canvas.palette.rgb;
setThemeColorMeta(r, g, b);
}
const coords = view.map((u) => Math.round(u)).join(','); const coords = view.map((u) => Math.round(u)).join(',');
let newhash = `#${canvasIdent},${coords}`; let newhash = `#${canvasIdent},${coords}`;
if (!is3D) { if (!is3D) {

View File

@ -1,31 +0,0 @@
/**
* Copyright 2016 Facebook, Inc.
*
* You are hereby granted a non-exclusive, worldwide, royalty-free license to
* use, copy, modify, and distribute this software in source code or binary
* form for use in connection with the web services and APIs provided by
* Facebook.
*
* As with any software that integrates with the Facebook platform, your use
* of this software is subject to the Facebook Developer Principles and
* Policies [http://developers.facebook.com/policy/]. This copyright notice
* shall be included in all copies or substantial portions of the software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE
*/
function warn(error) {
// eslint-disable-next-line no-console
console.warn(error.message || error);
throw error; // To let the caller handle the rejection
}
export default () => (next) => (action) => (typeof action.then === 'function'
? Promise.resolve(action).then(next, warn)
: next(action));

View File

@ -1,10 +1,10 @@
import Palette from '../core/Palette'; import Palette from '../../core/Palette';
import { import {
clamp, clamp,
getIdFromObject, getIdFromObject,
getHistoricalCanvasSize, getHistoricalCanvasSize,
getMaxTiledZoom, getMaxTiledZoom,
} from '../core/utils'; } from '../../core/utils';
import { import {
@ -13,7 +13,7 @@ import {
DEFAULT_CANVAS_ID, DEFAULT_CANVAS_ID,
DEFAULT_CANVASES, DEFAULT_CANVASES,
TILE_SIZE, TILE_SIZE,
} from '../core/constants'; } from '../../core/constants';
export type CanvasState = { export type CanvasState = {
canvasId: number, canvasId: number,

View File

@ -1,4 +1,4 @@
import { MAX_CHAT_MESSAGES } from '../core/constants'; import { MAX_CHAT_MESSAGES } from '../../core/constants';
const initialState = { const initialState = {
/* /*

View File

@ -2,7 +2,7 @@
* state for open windows and modal and its content * state for open windows and modal and its content
*/ */
import { clamp } from '../core/utils'; import { clamp } from '../../core/utils';
const SCREEN_MARGIN_S = 30; const SCREEN_MARGIN_S = 30;
const SCREEN_MARGIN_EW = 70; const SCREEN_MARGIN_EW = 70;

View File

@ -13,7 +13,7 @@ import {
receiveBigChunk, receiveBigChunk,
receiveBigChunkFailure, receiveBigChunkFailure,
// preLoadedBigChunk, // preLoadedBigChunk,
} from '../actions'; } from '../store/actions';
import { import {
getMaxTiledZoom, getMaxTiledZoom,
getCellInsideChunk, getCellInsideChunk,

View File

@ -8,7 +8,7 @@ import {
requestBigChunk, requestBigChunk,
receiveBigChunk, receiveBigChunk,
receiveBigChunkFailure, receiveBigChunkFailure,
} from '../actions'; } from '../store/actions';
import { import {
getChunkOfPixel, getChunkOfPixel,
getOffsetOfPixel, getOffsetOfPixel,

View File

@ -19,7 +19,7 @@ import {
import { import {
setHover, setHover,
selectColor, selectColor,
} from '../actions'; } from '../store/actions';
import { tryPlacePixel } from './placePixel'; import { tryPlacePixel } from './placePixel';

View File

@ -16,7 +16,7 @@ import {
placedPixels, placedPixels,
pixelWait, pixelWait,
updatePixel, updatePixel,
} from '../actions'; } from '../store/actions';
import SocketClient from '../socket/SocketClient'; import SocketClient from '../socket/SocketClient';
let pixelTimeout = null; let pixelTimeout = null;

View File

@ -9,7 +9,7 @@
import { t } from 'ttag'; import { t } from 'ttag';
import Renderer2D from './Renderer2D'; import Renderer2D from './Renderer2D';
import { sweetAlert } from '../actions'; import { sweetAlert } from '../store/actions';
import { isWebGL2Available } from '../core/utils'; import { isWebGL2Available } from '../core/utils';
const dummyRenderer = { const dummyRenderer = {