diff --git a/src/components/posts/post-action-bar.js b/src/components/posts/post-action-bar.js index 458cc9d..e9d085f 100644 --- a/src/components/posts/post-action-bar.js +++ b/src/components/posts/post-action-bar.js @@ -1,36 +1,13 @@ import React, { useState, useEffect } from "react"; -import { +import { Image, + Text, View, Dimensions, TouchableWithoutFeedback } from "react-native"; import { activeOrNot } from "src/interface/interactions"; -function invertField (field, state, updater) { - // Takes a function (like `setState`) and uses it to invert the given field of `state` - let newState = state; - newState[field] = !newState[field]; - updater(newState); -} - -// These callbacks will eventually make calls to the instance's API -function favouritedCallback(state, updater) { - invertField("favourited", state, updater); -} - -function commentCallback(state, updater) { - invertField("commenting", state, updater); -} - -function reblogCallback(state, updater) { - invertField("reblogged", state, updater); -} - -function bookmarkCallback(state, updater) { - invertField("bookmarked", state, updater); -} - const PostActionJsx = (props) => { return ( { field = "favourited" pack = { icons.heart } state = { state } - callback = { () => favouritedCallback(state, setState) } /> + callback = { + () => { + setState({ ...state, favourited: !state.favourited }); + } + } /> reblogCallback(state, setState) } /> + callback = { + () => { + setState({ ...state, reblogged: !state.reblogged }); + } + } /> bookmarkCallback(state, setState) } /> + callback = { + () => { + setState({ ...state, bookmarked: !state.bookmarked }); + } + } /> ) } diff --git a/src/components/posts/post.js b/src/components/posts/post.js index b8fc264..9e38742 100644 --- a/src/components/posts/post.js +++ b/src/components/posts/post.js @@ -175,7 +175,7 @@ export const PostByDataJsx = (props) => { loaded: true }); }); - }); + }, []); return ( @@ -224,7 +224,7 @@ export const PostByIdJsx = (props) => { }); }); })(); - }); + }, []); return (