Skip to content

Commit

Permalink
selectCurrentDataIndex --> selectFrameIndex. Part of #10.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomoros committed Nov 15, 2021
1 parent 344a29e commit 0d00961
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/actions/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from './app.js';

import {
selectCurrentDataIndex,
selectFrameIndex,
} from '../selectors.js';

export const loadData = (data) => {
Expand All @@ -19,13 +19,13 @@ export const loadData = (data) => {
};

export const nextIndex = () => (dispatch, getState) => {
let currentIndex = selectCurrentDataIndex(getState());
let currentIndex = selectFrameIndex(getState());
currentIndex++;
dispatch(updateFrameIndex(currentIndex));
};

export const prevIndex = () => (dispatch, getState) => {
let currentIndex = selectCurrentDataIndex(getState());
let currentIndex = selectFrameIndex(getState());
currentIndex--;
if (currentIndex < 0) return;
dispatch(updateFrameIndex(currentIndex));
Expand Down
5 changes: 3 additions & 2 deletions src/components/main-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import {
selectExpandedCurrentMapData,
selectPageExtra,
selectCurrentDataIndex,
selectFrameIndex,
selectCurrentSimulationHeight,
selectCurrentSimulationWidth
} from "../selectors.js";
Expand Down Expand Up @@ -151,7 +151,8 @@ class MainView extends connect(store)(PageViewElement) {
stateChanged(state) {
this._expandedMapData = selectExpandedCurrentMapData(state);
this._pageExtra = selectPageExtra(state);
this._currentIndex = selectCurrentDataIndex(state);
//TODO: rename this property
this._currentIndex = selectFrameIndex(state);
this._height = selectCurrentSimulationHeight(state);
this._width = selectCurrentSimulationWidth(state);

Expand Down
10 changes: 5 additions & 5 deletions src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "./simulation.js";

const selectRawConfigData = state => state.data ? state.data.data : [];
export const selectFrameIndex = state => state.data ? state.data.frameIndex : 0;
export const selectRawFrameIndex = state => state.data ? state.data.frameIndex : 0;

export const selectPage = state => state.app ? state.app.page : '';
export const selectPageExtra = state => state.app ? state.app.pageExtra : '';
Expand All @@ -15,9 +15,8 @@ const selectSimulationCollection = createSelector(
(rawConfig) => new SimulationCollection(rawConfig)
);

//TODO: rename this
export const selectCurrentDataIndex = createSelector(
selectFrameIndex,
export const selectFrameIndex = createSelector(
selectRawFrameIndex,
selectSimulationCollection,
(rawIndex, collection) => {
if (rawIndex >= 0) return rawIndex;
Expand All @@ -41,9 +40,10 @@ export const selectCurrentSimulationHeight = createSelector(
(sim) => sim ? sim.height : 0
);

//TODO: rename this
export const selectExpandedCurrentMapData = createSelector(
selectCurrentSimulation,
selectCurrentDataIndex,
selectFrameIndex,
(sim, currentIndex) => {
if (!sim) return null;
return sim.run(0).frame(currentIndex);
Expand Down

0 comments on commit 0d00961

Please sign in to comment.