1
- import { put , takeEvery } from 'redux-saga/effects'
2
- import {
3
- ARTICLE_HYDRATE ,
4
- ARTICLE_SAVE_REQUEST ,
5
- ARTICLE_SAVE_SUCCESS ,
6
- ARTICLE_SAVE_FAILURE ,
7
- ARTICLE_UNSAVE_REQUEST ,
8
- ARTICLE_UNSAVE_SUCCESS ,
9
- ARTICLE_UNSAVE_FAILURE ,
10
- ARTICLE_GET_PONG
11
- } from 'actions'
1
+ import { takeEvery } from 'redux-saga/effects'
2
+ import { ARTICLE_HYDRATE , ARTICLE_GET_PONG } from 'actions'
12
3
import { getSyndicatedArticle } from 'common/api/queries/get-syndicated-article'
13
- import { saveItem } from 'common/api/_legacy/saveItem'
14
- import { removeItem } from 'common/api/_legacy/removeItem'
4
+
15
5
import { HYDRATE } from 'actions'
16
6
17
7
/** ACTIONS
18
8
--------------------------------------------------------------- */
19
9
export const hydrateArticle = ( hydrated ) => ( { type : ARTICLE_HYDRATE , hydrated } ) //prettier-ignore
20
- export const saveArticleItem = ( url ) => ( { type : ARTICLE_SAVE_REQUEST , url } )
21
- export const unSaveArticleItem = ( id ) => ( { type : ARTICLE_UNSAVE_REQUEST , id } )
22
10
export const callGetPong = ( ) => ( { type : ARTICLE_GET_PONG } )
23
11
24
12
/** REDUCERS
@@ -35,26 +23,6 @@ export const syndicatedArticleReducers = (state = initialState, action) => {
35
23
return { ...state , ...hydrated }
36
24
}
37
25
38
- case ARTICLE_SAVE_REQUEST : {
39
- return { ...state , saveStatus : 'saving' }
40
- }
41
-
42
- case ARTICLE_SAVE_SUCCESS : {
43
- return { ...state , saveStatus : 'saved' }
44
- }
45
-
46
- case ARTICLE_SAVE_FAILURE : {
47
- return { ...state , saveStatus : 'unsaved' }
48
- }
49
-
50
- case ARTICLE_UNSAVE_SUCCESS : {
51
- return { ...state , saveStatus : 'unsaved' }
52
- }
53
-
54
- case ARTICLE_UNSAVE_FAILURE : {
55
- return { ...state , saveStatus : 'saved' }
56
- }
57
-
58
26
// SPECIAL HYDRATE: This is sent from the next-redux wrapper and
59
27
// it represents the state used to build the page on the server.
60
28
case HYDRATE : {
@@ -69,36 +37,10 @@ export const syndicatedArticleReducers = (state = initialState, action) => {
69
37
70
38
/** SAGAS :: WATCHERS
71
39
--------------------------------------------------------------- */
72
- export const syndicatedArticleSagas = [
73
- takeEvery ( ARTICLE_SAVE_REQUEST , articleSaveRequest ) ,
74
- takeEvery ( ARTICLE_UNSAVE_REQUEST , articleUnSaveRequest ) ,
75
- takeEvery ( ARTICLE_GET_PONG , articleGetPong )
76
- ]
40
+ export const syndicatedArticleSagas = [ takeEvery ( ARTICLE_GET_PONG , articleGetPong ) ]
77
41
78
42
/** SAGA :: RESPONDERS
79
43
--------------------------------------------------------------- */
80
- function * articleSaveRequest ( { url } ) {
81
- try {
82
- const response = yield saveItem ( url )
83
- if ( response ?. status !== 1 ) throw new Error ( 'Unable to save' )
84
-
85
- yield put ( { type : ARTICLE_SAVE_SUCCESS } )
86
- } catch ( error ) {
87
- yield put ( { type : ARTICLE_SAVE_FAILURE , error } )
88
- }
89
- }
90
-
91
- function * articleUnSaveRequest ( { id } ) {
92
- try {
93
- const response = yield removeItem ( id )
94
- if ( response ?. status !== 1 ) throw new Error ( 'Unable to remove item' )
95
-
96
- yield put ( { type : ARTICLE_UNSAVE_SUCCESS } )
97
- } catch ( error ) {
98
- yield put ( { type : ARTICLE_UNSAVE_FAILURE , error } )
99
- }
100
- }
101
-
102
44
function * articleGetPong ( ) {
103
45
yield fetch ( '/api/pong/get' , {
104
46
method : 'post' ,
0 commit comments