Fakultas Ilmu Komputer UI

Commit f70acd56 authored by Ahmad Izzudin Alifyandra's avatar Ahmad Izzudin Alifyandra
Browse files

Merge branch 'fix-creator-ecosystem-follow-logic' into 'master'

fix: creator ecosystem follow logic

See merge request !154
parents 57822efe cf9f8ec9
Pipeline #88905 passed with stage
in 10 minutes and 31 seconds
......@@ -38,6 +38,7 @@ const VerticalEcosystemCarousel = ({ list }: props) => {
image: item.pic,
member: item.followerCount.toString(),
rating: item.rating.toString(),
creatorId: item.creatorId,
},
});
}}
......
......@@ -110,6 +110,7 @@ const CategoryEcosystemListScreen = ({
image: item.pic,
member: item.followerCount.toString(),
rating: item.rating.toString(),
creatorId: item.creatorId,
},
})
}
......
......@@ -16,21 +16,18 @@ import { useEffect, useState } from "react";
import RatingForm from "../../components/RatingForm";
import { rateEcosystem } from "../../service/functions/rateEcosystem";
import { getEcosystemRating } from "../../service/firestore/ecosystem/getEcosystemRating";
import { isOwner } from "../../service/firestore/ecosystem/isOwner";
import { deleteEcosystem } from "../../service/functions/deleteEcosystem";
const EcosystemDetailScreen = ({
route,
}: EcosystemStackScreenProps<"EcosystemDetails">) => {
const { id, title, desc, image, member, rating } = route.params;
const { id, title, desc, image, member, rating, creatorId } = route.params;
const nav = useNavigation();
const user = useUser();
const [isInEcosystem, setIsInEcosystem] = useState(false);
const [isFetched, setIsFetched] = useState(false);
const [isRating, setIsRating] = useState(false);
const [currentRating, setCurrentRating] = useState(0);
const [isEcosystemOwner, setIsEcosystemOnwer] = useState(false);
const [isOwnerFetched, setIsOwnerFetched] = useState(false);
useEffect(() => {
inEcosystem(id, user.id).then((res) => {
......@@ -40,14 +37,6 @@ const EcosystemDetailScreen = ({
getEcosystemRating(id, user.id).then((res) => setCurrentRating(res));
}, []);
useEffect(() => {
isOwner(id, user.id)
.then((res) => {
setIsEcosystemOnwer(res);
})
.then(() => setIsOwnerFetched(true));
}, []);
const alertFollow = () => {
Alert.alert("Joined Ecosystem", "You have joined the ecosystem");
inEcosystem(id, user.id).then((res) => setIsInEcosystem(res));
......@@ -143,7 +132,9 @@ const EcosystemDetailScreen = ({
<Text style={styles.textBody}>{desc}</Text>
<Spacer variant={"xl"} />
{(() => {
if (isInEcosystem && isFetched) {
if (creatorId == user.id) {
return null;
} else if (isInEcosystem && isFetched) {
return (
<SmallButton
text={"Keluar dari Ekosistem"}
......@@ -180,7 +171,7 @@ const EcosystemDetailScreen = ({
)}
<Spacer variant={"l"} />
{(() => {
if (isEcosystemOwner && isOwnerFetched) {
if (creatorId == user.id) {
return (
<SmallButton
text={"Hapus Ekosistem"}
......
......@@ -97,6 +97,7 @@ const EcosystemSearch = ({ route }: EcosystemStackScreenProps<"Search">) => {
image: item.pic,
member: item.followerCount.toString(),
rating: item.rating.toString(),
creatorId: item.creatorId,
},
});
}}
......
......@@ -101,6 +101,7 @@ const RecommendedEcosystemScreen = ({
image: item.pic,
member: item.followerCount.toString(),
rating: item.rating.toString(),
creatorId: item.creatorId,
},
});
}}
......
......@@ -8,6 +8,7 @@ export const followEcosystem = async (ecosystemId: string, userId: string) => {
const followDoc: IEcosystemFollow = {
userId: userId,
ecosystemId: ecosystemId,
isCreator: false,
};
return await db
......
......@@ -12,6 +12,7 @@ export const getByFollowed = async (
const query = db
.collection("ecosystem_follows_" + getEnv())
.where("userId", "==", userId)
.where("isCreator", "==", false)
.limit(10);
const followedEcosystemIdSnap = await (async () => {
......
......@@ -2,4 +2,5 @@ export type IEcosystemFollow = {
id?: string;
userId: string;
ecosystemId: string;
isCreator: boolean;
};
......@@ -23,6 +23,7 @@ export type EcosystemStackParamList = {
image: string;
member: string;
rating: string;
creatorId: string;
};
UserList: {
headerTitle?: string;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment