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

Commit a012203

Browse files
mmahalwythabti
authored andcommitted
Add new normalizr (#565)
1 parent 2bf8e1e commit a012203

File tree

7 files changed

+11
-19
lines changed

7 files changed

+11
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"json-loader": "0.5.4",
7878
"morgan": "1.7.0",
7979
"node-sass": "4.1.1",
80-
"normalizr": "2.2.1",
80+
"normalizr": "3.0.2",
8181
"pretty-error": "2.0.0",
8282
"promise": "7.1.1",
8383
"proxy-middleware": "0.14.0",

src/redux/actions/ayahs.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { ayahsSchema } from 'redux/schemas';
22

3-
import { arrayOf } from 'normalizr';
4-
53
import {
64
LOAD,
75
LOAD_SUCCESS,
@@ -24,7 +22,7 @@ export function load(id, from, to, options = defaultOptions) {
2422

2523
return {
2624
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
27-
schema: arrayOf(ayahsSchema),
25+
schema: [ayahsSchema],
2826
promise: client => client.get(`/v2/surahs/${id}/ayahs`, {
2927
params: {
3028
from,

src/redux/actions/bookmarks.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { bookmarksSchema } from 'redux/schemas';
2-
import { arrayOf } from 'normalizr';
32
import {
43
LOAD,
54
LOAD_SUCCESS,
@@ -19,7 +18,7 @@ export function isLoaded(globalState) {
1918
export function load() {
2019
return {
2120
types: [LOAD, LOAD_SUCCESS, LOAD_FAILURE],
22-
schema: arrayOf(bookmarksSchema),
21+
schema: [bookmarksSchema],
2322
promise: client => client.get('/onequran/api/v1/bookmarks')
2423
};
2524
}

src/redux/actions/search.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ayahsSchema } from 'redux/schemas';
2-
import { arrayOf } from 'normalizr';
32

43
import {
54
SEARCH,
@@ -10,7 +9,7 @@ import {
109
export function search(params) {
1110
return {
1211
types: [SEARCH, SEARCH_SUCCESS, SEARCH_FAIL],
13-
schema: { results: arrayOf({ ayah: ayahsSchema }) },
12+
schema: { results: [{ ayah: ayahsSchema }] },
1413
// TODO: We are doing this because of a weird obj.hasOwnProperty method missing on `params`
1514
promise: client => client.get('/v2/search', { params: { q: params.q } }),
1615
params

src/redux/actions/surahs.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { surahsSchema } from 'redux/schemas';
2-
import { arrayOf } from 'normalizr';
32
import {
43
LOAD,
54
LOAD_SUCCESS,
@@ -13,15 +12,15 @@ import {
1312
export function loadAll() {
1413
return {
1514
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
16-
schema: arrayOf(surahsSchema),
15+
schema: [surahsSchema],
1716
promise: client => client.get('/v2/surahs')
1817
};
1918
}
2019

2120
export function load(id) {
2221
return {
2322
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
24-
schema: arrayOf(surahsSchema),
23+
schema: [surahsSchema],
2524
promise: client => client.get(`/v2/surahs/${id}`)
2625
};
2726
}

src/redux/schemas.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Schema } from 'normalizr';
1+
import { schema } from 'normalizr';
22

3-
export const surahsSchema = new Schema('surahs');
4-
export const ayahsSchema = new Schema('ayahs', { idAttribute: 'ayahKey' });
5-
export const bookmarksSchema = new Schema('bookmarks', { idAttribute: 'ayahKey' });
3+
export const surahsSchema = new schema.Entity('surahs');
4+
export const ayahsSchema = new schema.Entity('ayahs', {}, { idAttribute: 'ayahKey' });
5+
export const bookmarksSchema = new schema.Entity('bookmarks', {}, { idAttribute: 'ayahKey' });
66

77
const schemas = {
88
surahsSchema,

src/types/segmentType.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ export default PropTypes.shape({
66
endTime: PropTypes.number.isRequired,
77
duration: PropTypes.number.isRequired,
88
})),
9-
intervals: PropTypes.oneOfType([
10-
PropTypes.array,
11-
PropTypes.object
12-
]) // TODO: This should be done a better way.
9+
intervals: PropTypes.any // TODO: This should be done a better way.
1310
});

0 commit comments

Comments
 (0)