Added LinkTimeline and PreviewCard fetching by id
• Added: - LinkTimeline and PreviewCard fetching by id
This commit is contained in:
30
app/javascript/gabsocial/actions/links.js
Normal file
30
app/javascript/gabsocial/actions/links.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import api from '../api'
|
||||
|
||||
export const LINK_FETCH_REQUEST = 'LINK_FETCH_REQUEST'
|
||||
export const LINK_FETCH_SUCCESS = 'LINK_FETCH_SUCCESS'
|
||||
export const LINK_FETCH_FAIL = 'LINK_FETCH_FAIL'
|
||||
|
||||
export const fetchLinkCard = (cardId) => (dispatch, getState) => {
|
||||
dispatch(fetchLinkCardRequest(cardId))
|
||||
|
||||
api(getState).get(`/api/v1/links/${cardId}`).then(({ data }) => {
|
||||
dispatch(fetchLinkCardSuccess(data))
|
||||
})
|
||||
.catch((err) => dispatch(fetchLinkCardFail(err)))
|
||||
}
|
||||
|
||||
export const fetchLinkCardRequest = (cardId) => ({
|
||||
type: LINK_FETCH_REQUEST,
|
||||
cardId,
|
||||
})
|
||||
|
||||
export const fetchLinkCardSuccess = (card) => ({
|
||||
type: LINK_FETCH_SUCCESS,
|
||||
card,
|
||||
})
|
||||
|
||||
export const fetchLinkCardFail = (error, cardId) => ({
|
||||
type: LINK_FETCH_FAIL,
|
||||
error,
|
||||
cardId,
|
||||
})
|
||||
Reference in New Issue
Block a user