Added LinkTimeline and PreviewCard fetching by id
• Added: - LinkTimeline and PreviewCard fetching by id
This commit is contained in:
@@ -15,6 +15,7 @@ import group_lists from './group_lists'
|
||||
import group_relationships from './group_relationships'
|
||||
import hashtags from './hashtags'
|
||||
import height_cache from './height_cache'
|
||||
import links from './links.js'
|
||||
import lists from './lists'
|
||||
import listAdder from './list_adder'
|
||||
import listEditor from './list_editor'
|
||||
@@ -59,6 +60,7 @@ const reducers = {
|
||||
group_relationships,
|
||||
hashtags,
|
||||
height_cache,
|
||||
links,
|
||||
lists,
|
||||
listAdder,
|
||||
listEditor,
|
||||
|
||||
40
app/javascript/gabsocial/reducers/links.js
Normal file
40
app/javascript/gabsocial/reducers/links.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
Map as ImmutableMap,
|
||||
List as ImmutableList,
|
||||
fromJS,
|
||||
} from 'immutable'
|
||||
import {
|
||||
LINK_FETCH_REQUEST,
|
||||
LINK_FETCH_SUCCESS,
|
||||
LINK_FETCH_FAIL,
|
||||
} from '../actions/links'
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
isFetched: false,
|
||||
isError: false,
|
||||
isLoading: false,
|
||||
items: ImmutableMap(),
|
||||
})
|
||||
|
||||
export default function links(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case LINK_FETCH_REQUEST:
|
||||
return state.set('isLoading', true)
|
||||
case LINK_FETCH_SUCCESS:
|
||||
return state.withMutations((mutable) => {
|
||||
mutable.setIn(['items', `${action.card.id}`], fromJS(action.card))
|
||||
mutable.set('isLoading', false)
|
||||
mutable.set('isFetched', false)
|
||||
mutable.set('isError', false)
|
||||
})
|
||||
case LINK_FETCH_FAIL:
|
||||
return state.withMutations((mutable) => {
|
||||
mutable.set('isLoading', false)
|
||||
mutable.set('isFetched', false)
|
||||
mutable.set('isError', true)
|
||||
})
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user