diff --git a/src/routes/protected.tsx b/src/routes/protected.tsx
index 7aee6e6..8433b58 100644
--- a/src/routes/protected.tsx
+++ b/src/routes/protected.tsx
@@ -6,7 +6,7 @@ import Join from "@/screens/protected/Join";
import Settings from "@/screens/protected/Settings";
export type ProtectedStackParamList = {
- Home: undefined;
+ Home: { newCircleAdded: string | null };
Settings: undefined;
Join: undefined;
Create: undefined;
@@ -21,7 +21,11 @@ export function ProtectedStack() {
headerShown: false,
}}
>
-
+
diff --git a/src/screens/protected/Create.tsx b/src/screens/protected/Create.tsx
index 2d41e34..eb7739d 100644
--- a/src/screens/protected/Create.tsx
+++ b/src/screens/protected/Create.tsx
@@ -201,7 +201,7 @@ export default function Create({ navigation }: JoinProps) {
});
setTimeout(() => {
- navigation.navigate("Home");
+ navigation.navigate("Home", { newCircleAdded: name });
}, 1000);
} catch (error) {
console.log(error);
diff --git a/src/screens/protected/Home.tsx b/src/screens/protected/Home.tsx
index c14c5a1..7480b7a 100644
--- a/src/screens/protected/Home.tsx
+++ b/src/screens/protected/Home.tsx
@@ -471,7 +471,7 @@ export default function Home({ navigation }: HomeProps) {
// TODO: Get a user's information, given their id, from the db
const user = dummyProfiles.find((profile) => profile.id === profileId);
- if (user) {
+ if (user && user.id !== profile?.id) {
// TODO: Get a user's location from the db
usersInCircle.push(
@@ -494,7 +494,13 @@ export default function Home({ navigation }: HomeProps) {
);
}
});
-
+ if (usersInCircle.length === 0) {
+ return (
+
+ You are the only one in this circle!
+
+ );
+ }
return usersInCircle;
};
@@ -553,6 +559,21 @@ export default function Home({ navigation }: HomeProps) {
updateProfileIdsInCurrentCircle();
}, [selectedCircle]);
+ // Fetch all the user's circles from db if a new circle has been created.
+ const newCirclePossiblyAdded = useRef(false);
+ const newCircleAdded = navigation.getState().routes[0].params?.newCircleAdded;
+ const updateStateIfNewlyCreatedCircle = async () => {
+ if (
+ newCircleAdded !== null &&
+ newCircleAdded !== undefined &&
+ newCirclePossiblyAdded.current === true
+ ) {
+ newCirclePossiblyAdded.current = false;
+ await getUsersCircles();
+ }
+ };
+ updateStateIfNewlyCreatedCircle();
+
useEffect(() => {
(async () => {
checkPermissionsAndUpdateScreen();
@@ -591,6 +612,7 @@ export default function Home({ navigation }: HomeProps) {
variant="primary"
label="Create a Circle"
onPress={() => {
+ newCirclePossiblyAdded.current = true;
navigation.navigate("Create");
}}
/>