Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

Commit 93901f3

Browse files
authored
Fixes #656 Translation dropdown (#671)
* translation type * add content type
1 parent 7cebbda commit 93901f3

File tree

8 files changed

+105
-365
lines changed

8 files changed

+105
-365
lines changed

src/components/ContentDropdown/index.js

Lines changed: 48 additions & 357 deletions
Large diffs are not rendered by default.

src/components/ReciterDropdown/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ class ReciterDropdown extends Component {
2222
};
2323

2424
componentDidMount() {
25-
return this.props.loadRecitations();
25+
if (!this.props.recitations.length) {
26+
return this.props.loadRecitations();
27+
}
28+
29+
return false;
2630
}
2731

2832
renderMenu() {

src/redux/actions/options.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import {
33
SET_OPTION,
44
LOAD_RECITERS,
55
LOAD_RECITERS_SUCCESS,
6-
LOAD_RECITERS_FAIL
6+
LOAD_RECITERS_FAIL,
7+
LOAD_TRANSLATIONS,
8+
LOAD_TRANSLATIONS_SUCCESS,
9+
LOAD_TRANSLATIONS_FAIL
710
} from 'redux/constants/options.js';
811

912
export function isReadingMode(globalState) {
@@ -26,3 +29,8 @@ export const loadRecitations = () => ({
2629
types: [LOAD_RECITERS, LOAD_RECITERS_SUCCESS, LOAD_RECITERS_FAIL],
2730
promise: client => client.get('/api/v3/options/recitations')
2831
});
32+
33+
export const loadTranslations = () => ({
34+
types: [LOAD_TRANSLATIONS, LOAD_TRANSLATIONS_SUCCESS, LOAD_TRANSLATIONS_FAIL],
35+
promise: client => client.get('/api/v3/options/translations')
36+
});

src/redux/constants/options.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ export const TOGGLE_NIGHT_MODE = '@@quran/options/TOGGLE_NIGHT_MODE';
44
export const LOAD_RECITERS = '@@quran/verses/LOAD_RECITERS';
55
export const LOAD_RECITERS_SUCCESS = '@@quran/verses/LOAD_RECITERS_SUCCESS';
66
export const LOAD_RECITERS_FAIL = '@@quran/verses/LOAD_RECITERS_FAIL';
7+
8+
export const LOAD_TRANSLATIONS = '@@quran/verses/LOAD_TRANSLATIONS';
9+
export const LOAD_TRANSLATIONS_SUCCESS = '@@quran/verses/LOAD_TRANSLATIONS_SUCCESS';
10+
export const LOAD_TRANSLATIONS_FAIL = '@@quran/verses/LOAD_TRANSLATIONS_FAIL';

src/redux/modules/options.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import {
22
SET_OPTION,
33
LOAD_RECITERS,
4-
LOAD_RECITERS_SUCCESS
4+
LOAD_RECITERS_SUCCESS,
5+
LOAD_TRANSLATIONS,
6+
LOAD_TRANSLATIONS_SUCCESS
57
} from 'redux/constants/options.js';
68

79
const initialState = {
810
isReadingMode: false,
911
isShowingSurahInfo: false,
1012
loadingRecitations: false,
13+
loadingTranslations: false,
1114
audio: 8,
1215
translations: [20],
1316
tooltip: 'translation',
1417
options: {
15-
recitations: []
18+
recitations: [],
19+
translations: []
1620
},
1721
fontSize: {
1822
arabic: 3.5,
@@ -45,6 +49,22 @@ export default function reducer(state = initialState, action = {}) {
4549
}
4650
};
4751
}
52+
case LOAD_TRANSLATIONS: {
53+
return {
54+
...state,
55+
loadingTranslations: true
56+
};
57+
}
58+
case LOAD_TRANSLATIONS_SUCCESS: {
59+
return {
60+
...state,
61+
loadingTranslations: false,
62+
options: {
63+
...state.options,
64+
translations: action.result.translations
65+
}
66+
};
67+
}
4868
default:
4969
return state;
5070
}

src/server.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import createHistory from 'react-router/lib/createMemoryHistory';
99
import { Provider } from 'react-redux';
1010
import { IntlProvider } from 'react-intl';
1111
import cookie from 'react-cookie';
12-
import raven from 'raven';
12+
import Raven from 'raven';
1313
import errorhandler from 'errorhandler';
1414

1515
import config from 'config';
@@ -27,11 +27,16 @@ import getLocalMessages from './helpers/setLocal';
2727

2828
const pretty = new PrettyError();
2929
const server = express();
30+
Raven.config(config.sentryServer, {
31+
captureUnhandledRejections: true,
32+
autoBreadcrumbs: true
33+
}).install();
34+
3035

3136
expressConfig(server);
3237

33-
// Use varnish for the static routes, which will cache too
34-
server.use(raven.middleware.express.requestHandler(config.sentryServer));
38+
39+
server.use(Raven.requestHandler());
3540

3641
server.use((req, res, next) => {
3742
cookie.plugToRequest(req, res);
@@ -100,7 +105,7 @@ server.use((req, res, next) => {
100105
return false;
101106
});
102107

103-
server.use(raven.middleware.express.errorHandler(config.sentryServer));
108+
server.use(Raven.errorHandler());
104109

105110
if (process.env.NODE_ENV === 'development') {
106111
// only use in development

src/types/contentType.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { PropTypes } from 'react';
2+
3+
export default PropTypes.shape({
4+
id: PropTypes.number,
5+
authorName: PropTypes.string,
6+
languageName: PropTypes.string
7+
});

src/types/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export { default as wordType } from './wordType';
88
export { default as matchType } from './matchType';
99
export { default as recitationType } from './recitationType';
1010
export { default as translationType } from './translationType';
11+
export { default as contentType } from './contentType';

0 commit comments

Comments
 (0)