Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
options and fontface actions
  • Loading branch information
thabti committed Jul 26, 2016
commit 42f6eaa8b298c5d42ec161546bfe20add449ff73
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"browser": true,
"node": true,
Expand All @@ -13,13 +14,13 @@
"import/named": 0,
"import/namespace": 0,
"import/no-unresolved": 0,
"import/no-named-as-default": 0,
"import/no-named-as-default": 2,
// Temporarirly disabled due to a possible bug in babel-eslint (todomvc example)
"block-scoped-var": 0,
// Temporarily disabled for test/* until babel/babel-eslint#33 is resolved
"padded-blocks": 0,
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
"indent": [0, 0, {"SwitchCase": 0}],
"indent": [2, 2, {"SwitchCase": 1}],
"no-console": 0,
"no-alert": 0,
"object-curly-spacing": 0,
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import debug from './src/helpers/debug';
import Html from './src/helpers/Html';

import { setUserAgent } from './src/redux/actions/AudioPlayerActions.js';
import { setOption } from './src/redux/modules/options';
import { setOption } from './src/redux/actions/OptionsActions.js';

// Use varnish for the static routes, which will cache too
server.use(raven.middleware.express.requestHandler(config.sentryServer));
Expand Down
2 changes: 1 addition & 1 deletion src/components/FontStyles/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { fontFaceStyle, fontFaceStyleLoaded } from '../../helpers/buildFontFaces';
import { load } from 'redux/modules/fontFaces';
import { load } from 'redux/actions/FontFaceActions.js';

import debug from 'helpers/debug';
import selector from './selector';
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Surah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { surahsConnect, ayahsConnect } from './connect';

import * as AudioActions from '../../redux/actions/AudioPlayerActions.js';
import * as AyahActions from '../../redux/actions/AyahsActions.js';
import * as OptionsActions from '../../redux/modules/options';
import * as OptionsActions from '../../redux/actions/OptionsActions.js';

const style = require('./style.scss');

Expand Down
8 changes: 8 additions & 0 deletions src/redux/actions/FontFaceActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { LOAD } from '../constants/FontFaceActionTypes.js';

export function load(className) {
return {
type: LOAD,
className
};
}
23 changes: 23 additions & 0 deletions src/redux/actions/OptionsActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import cookie from 'react-cookie';
import { TOGGLE_READING_MODE, SET_OPTION } from '../constants/OptionsActionTypes.js'

export function isReadingMode(globalState) {
return globalState.options.isReadingMode;
}

export function setOption(payload) {
const options = cookie.load('options') || {}; // protect against first timers.
Object.keys(payload).forEach(option => { options[option] = payload[option]; });
cookie.save('options', JSON.stringify(options));

return {
type: SET_OPTION,
payload
};
}

export function toggleReadingMode() {
return {
type: TOGGLE_READING_MODE
};
}
1 change: 1 addition & 0 deletions src/redux/constants/FontFaceActionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LOAD = '@@quran/fontFaces/LOAD';
2 changes: 2 additions & 0 deletions src/redux/constants/OptionsActionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const TOGGLE_READING_MODE = '@@quran/options/TOGGLE_READING_MODE';
export const SET_OPTION = '@@quran/options/SET_OPTION';
14 changes: 4 additions & 10 deletions src/redux/modules/fontFaces.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LOAD_SUCCESS } from './ayahs';
import { SEARCH_SUCCESS } from './searchResults';

export const LOAD = '@@quran/fontFaces/LOAD';
import { LOAD_SUCCESS } from '../constants/AyahsActionTypes.js';
import { SEARCH_SUCCESS } from '../constants/SearchActionTypes.js';
import { LOAD } from '../constants/FontFaceActionTypes.js';

export default function reducer(state = {}, action = {}) {
switch (action.type) {
Expand Down Expand Up @@ -33,9 +32,4 @@ export default function reducer(state = {}, action = {}) {
}
}

export function load(className) {
return {
type: LOAD,
className
};
}

11 changes: 6 additions & 5 deletions src/redux/modules/lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import {
LOAD as AYAHS_LOAD,
LOAD_SUCCESS as AYAHS_LOAD_SUCCESS,
LOAD_FAIL as AYAHS_LOAD_FAIL
} from './ayahs';
LOAD_FAIL as AYAHS_LOAD_FAIL,
} from '../constants/AyahsActionTypes.js';

import { SET_CURRENT as SURAHS_SET_CURRENT } from './surahs';
import { SET_CURRENT as SURAHS_SET_CURRENT } from '../constants/SurahsActionTypes.js'

const initialState = {
lines: {},
lines: {}
};

export default function reducer(state = initialState, action = {}) {
Expand All @@ -26,7 +26,8 @@ export default function reducer(state = initialState, action = {}) {
};
case AYAHS_LOAD_SUCCESS:
const ayahs = action.result.entities.ayahs;
const lines = {...state.lines};
const stateLines = state.lines;
const lines = {...stateLines};

action.result.result.forEach(ayahId => {
const ayah = ayahs[ayahId];
Expand Down
28 changes: 3 additions & 25 deletions src/redux/modules/options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import cookie from 'react-cookie';

const TOGGLE_READING_MODE = '@@quran/options/TOGGLE_READING_MODE';
const SET_OPTION = '@@quran/options/SET_OPTION';
import { TOGGLE_READING_MODE, SET_OPTION } from '../constants/OptionsActionTypes.js';

const initialState = {
isReadingMode: false,
Expand All @@ -24,32 +22,12 @@ export default function reducer(state = initialState, action = {}) {
isReadingMode: !state.isReadingMode
};
case SET_OPTION:
const payload = action.payload;
return {
...state,
...action.payload
...payload
};
default:
return state;
}
}

export function isReadingMode(globalState) {
return globalState.options.isReadingMode;
}

export function setOption(payload) {
const options = cookie.load('options') || {}; // protect against first timers.
Object.keys(payload).forEach(option => { options[option] = payload[option]; });
cookie.save('options', JSON.stringify(options));

return {
type: SET_OPTION,
payload
};
}

export function toggleReadingMode() {
return {
type: TOGGLE_READING_MODE
};
}