Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show follow back instead of follow when user is already being f… #242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/FriendButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const connectionsStore = useConnectionsStore();
const rootStore = useRootStore();

const isFollowing = computed(() => connectionsStore.getFollowStatus(store.id, props.authorid));
const checkFollow = computed(() => connectionsStore.getFollowingStatus(store.id, props.authorid));

function handleFollowUnfollow() {
if (store.$state.id === ``) {
Expand Down Expand Up @@ -51,7 +52,7 @@ function handleFollowUnfollow() {
<span
class="bg-darkBG hover:bg-opacity-75 hidden rounded-lg px-5 text-sm font-semibold text-lightOnPrimaryText shadow-sm border border-lightBorder dark:border-gray7 transition duration-300 ease-in-out xl:block"
style="padding-top: 0.4rem; padding-bottom: 0.4rem"
>Follow</span
>{{ checkFollow ? `Follow back` : `Follow` }}</span
>
<!-- Mobile -->
<div
Expand Down
7 changes: 7 additions & 0 deletions src/store/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export const useConnectionsStore = defineStore(`connections`, {
const myFollowing = state.profiles.get(me)?.following;
return myFollowing?.has(them);
},
getFollowingStatus: (state: Connections) => (me: string, them: string) => {
if (me === ``) {
return false;
}
const checkFollowing = state.profiles.get(them)?.following?.has(me);
return checkFollowing;
},
getConnections: (state: Connections) => (id: string) => {
return state.profiles.get(id);
},
Expand Down