diff --git a/src/components/posts/post-action-bar.js b/src/components/posts/post-action-bar.js index 6621877..f47c8bc 100644 --- a/src/components/posts/post-action-bar.js +++ b/src/components/posts/post-action-bar.js @@ -44,19 +44,16 @@ const PostActionBarJsx = (props) => { return ( { @@ -250,6 +250,29 @@ export const PostByDataJsx = (props) => { }); }; + const _handleBookmark = async () => { + let newStatus; + + if (!state.data.bookmarked) { + newStatus = await requests.bookmarkStatus( + state.instance, + state.data.id, + state.accessToken + ); + } else { + newStatus = await requests.unbookmarkStatus( + state.instance, + state.data.id, + state.accessToken + ); + } + console.warn(newStatus.bookmarked); + + setState({...state, + data: newStatus, + }); + }; + return ( { state.loaded ? @@ -258,6 +281,7 @@ export const PostByDataJsx = (props) => { dimensions = { state.dimensions } onFavourite = { _handleFavourite } onReblog = { _handleReblog } + onBookmark = { _handleBookmark } navigation = { props.navigation }/> : } diff --git a/src/requests.js b/src/requests.js index 25f3af6..fde88c0 100644 --- a/src/requests.js +++ b/src/requests.js @@ -116,6 +116,17 @@ export async function unreblogStatus(domain, id, token) { const resp = await post(`https://${domain}/api/v1/statuses/${id}/unreblog`, token); return resp.json(); } + +export async function bookmarkStatus(domain, id, token) { + const resp = await post(`https://${domain}/api/v1/statuses/${id}/bookmark`, token); + return resp.json(); +} + +export async function unbookmarkStatus(domain, id, token) { + const resp = await post(`https://${domain}/api/v1/statuses/${id}/unbookmark`, token); + return resp.json(); +} + export async function fetchFollowing(domain, id, token) { const resp = await get(`https://${domain}/api/v1/accounts/${id}/following`, token); return resp.json();