Enable bookmarking posts
Due to #22, this is definitely broken on Pixelfed instances, though it may or may not otherwise work on Mastodon. Further investigation is needed to determine why this issue persists
This commit is contained in:
parent
1e2ec90026
commit
eb47557cc4
|
@ -44,19 +44,16 @@ const PostActionBarJsx = (props) => {
|
||||||
return (
|
return (
|
||||||
<View style = { styles.flexContainer }>
|
<View style = { styles.flexContainer }>
|
||||||
<PostActionJsx
|
<PostActionJsx
|
||||||
field = "favourited"
|
|
||||||
pack = { icons.heart }
|
pack = { icons.heart }
|
||||||
active = { props.favourited }
|
active = { props.favourited }
|
||||||
onPress = { props.onFavourite } />
|
onPress = { props.onFavourite } />
|
||||||
|
|
||||||
<PostActionJsx
|
<PostActionJsx
|
||||||
field = "reblogged"
|
|
||||||
pack = { icons.reblog }
|
pack = { icons.reblog }
|
||||||
active = { props.reblogged }
|
active = { props.reblogged }
|
||||||
onPress = { props.onReblog }/>
|
onPress = { props.onReblog }/>
|
||||||
|
|
||||||
<PostActionJsx
|
<PostActionJsx
|
||||||
field = "bookmarked"
|
|
||||||
pack = { icons.bookmark }
|
pack = { icons.bookmark }
|
||||||
last = { true }
|
last = { true }
|
||||||
active = { props.bookmarked }
|
active = { props.bookmarked }
|
||||||
|
|
|
@ -137,7 +137,7 @@ export const RawPostJsx = (props) => {
|
||||||
<PostActionBarJsx
|
<PostActionBarJsx
|
||||||
favourited = { props.data.favourited }
|
favourited = { props.data.favourited }
|
||||||
reblogged = { props.data.reblogged }
|
reblogged = { props.data.reblogged }
|
||||||
bookmarked = { false }
|
bookmarked = { props.data.bookmarked }
|
||||||
onFavourite = { props.onFavourite }
|
onFavourite = { props.onFavourite }
|
||||||
onReblog = { props.onReblog }
|
onReblog = { props.onReblog }
|
||||||
onBookmark = { props.onBookmark } />
|
onBookmark = { props.onBookmark } />
|
||||||
|
@ -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 (
|
return (
|
||||||
<View>
|
<View>
|
||||||
{ state.loaded ?
|
{ state.loaded ?
|
||||||
|
@ -258,6 +281,7 @@ export const PostByDataJsx = (props) => {
|
||||||
dimensions = { state.dimensions }
|
dimensions = { state.dimensions }
|
||||||
onFavourite = { _handleFavourite }
|
onFavourite = { _handleFavourite }
|
||||||
onReblog = { _handleReblog }
|
onReblog = { _handleReblog }
|
||||||
|
onBookmark = { _handleBookmark }
|
||||||
navigation = { props.navigation }/>
|
navigation = { props.navigation }/>
|
||||||
: <View></View> }
|
: <View></View> }
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -116,6 +116,17 @@ export async function unreblogStatus(domain, id, token) {
|
||||||
const resp = await post(`https://${domain}/api/v1/statuses/${id}/unreblog`, token);
|
const resp = await post(`https://${domain}/api/v1/statuses/${id}/unreblog`, token);
|
||||||
return resp.json();
|
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) {
|
export async function fetchFollowing(domain, id, token) {
|
||||||
const resp = await get(`https://${domain}/api/v1/accounts/${id}/following`, token);
|
const resp = await get(`https://${domain}/api/v1/accounts/${id}/following`, token);
|
||||||
return resp.json();
|
return resp.json();
|
||||||
|
|
Loading…
Reference in New Issue