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

Update normalizr #565

Merged
merged 1 commit into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"json-loader": "0.5.4",
"morgan": "1.7.0",
"node-sass": "4.1.1",
"normalizr": "2.2.1",
"normalizr": "3.0.2",
"pretty-error": "2.0.0",
"promise": "7.1.1",
"proxy-middleware": "0.14.0",
Expand Down
4 changes: 1 addition & 3 deletions src/redux/actions/ayahs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ayahsSchema } from 'redux/schemas';

import { arrayOf } from 'normalizr';

import {
LOAD,
LOAD_SUCCESS,
Expand All @@ -24,7 +22,7 @@ export function load(id, from, to, options = defaultOptions) {

return {
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
schema: arrayOf(ayahsSchema),
schema: [ayahsSchema],
promise: client => client.get(`/v2/surahs/${id}/ayahs`, {
params: {
from,
Expand Down
3 changes: 1 addition & 2 deletions src/redux/actions/bookmarks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { bookmarksSchema } from 'redux/schemas';
import { arrayOf } from 'normalizr';
import {
LOAD,
LOAD_SUCCESS,
Expand All @@ -19,7 +18,7 @@ export function isLoaded(globalState) {
export function load() {
return {
types: [LOAD, LOAD_SUCCESS, LOAD_FAILURE],
schema: arrayOf(bookmarksSchema),
schema: [bookmarksSchema],
promise: client => client.get('/onequran/api/v1/bookmarks')
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/redux/actions/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ayahsSchema } from 'redux/schemas';
import { arrayOf } from 'normalizr';

import {
SEARCH,
Expand All @@ -10,7 +9,7 @@ import {
export function search(params) {
return {
types: [SEARCH, SEARCH_SUCCESS, SEARCH_FAIL],
schema: { results: arrayOf({ ayah: ayahsSchema }) },
schema: { results: [{ ayah: ayahsSchema }] },
// TODO: We are doing this because of a weird obj.hasOwnProperty method missing on `params`
promise: client => client.get('/v2/search', { params: { q: params.q } }),
params
Expand Down
5 changes: 2 additions & 3 deletions src/redux/actions/surahs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { surahsSchema } from 'redux/schemas';
import { arrayOf } from 'normalizr';
import {
LOAD,
LOAD_SUCCESS,
Expand All @@ -13,15 +12,15 @@ import {
export function loadAll() {
return {
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
schema: arrayOf(surahsSchema),
schema: [surahsSchema],
promise: client => client.get('/v2/surahs')
};
}

export function load(id) {
return {
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
schema: arrayOf(surahsSchema),
schema: [surahsSchema],
promise: client => client.get(`/v2/surahs/${id}`)
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/redux/schemas.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Schema } from 'normalizr';
import { schema } from 'normalizr';

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

const schemas = {
surahsSchema,
Expand Down
5 changes: 1 addition & 4 deletions src/types/segmentType.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@ export default PropTypes.shape({
endTime: PropTypes.number.isRequired,
duration: PropTypes.number.isRequired,
})),
intervals: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object
]) // TODO: This should be done a better way.
intervals: PropTypes.any // TODO: This should be done a better way.
});