Skip to content

Commit

Permalink
Merge branch 'main' into api-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kavipatel0 committed Sep 9, 2024
2 parents 942d5df + 5555e5c commit 03e7b30
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Echo is a new chat messaging app aimed at allowing you to talk to strangers *(or

This repository holds the all of the code that our Echo app utilizes (pretty cool right? 😎). This repository is public because we believe in the future of open source projects, the community is what makes developing so special ✨! It is split into the frontend/app `/client` and the backend/server `/server`. Take a look around, we're sure you'll find yourself wanting to help out! Ready? Head here 👉 [contributing](#contributing)

If you are interested in contributing to the UI/UX design of our app, please see our Figma design [here](https://www.figma.com/file/2mvddKeA4XMODdCidYkDid/Proximity-Chat-App?type=design&node-id=0%3A1&mode=design&t=V5A9MVRhlmdxGH0M-1). Improvements here are always welcome.

## Installation

Expand Down
9 changes: 1 addition & 8 deletions client/app/components/auth/AuthButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const SignOutButton: React.FC<SignOutButtonProps> = () => {
disabled={loading}>
<Text style={styles.button_text}>Sign Out</Text>
</TouchableOpacity>

);
};

Expand All @@ -72,14 +73,6 @@ export const LogInButton: React.FC<{ onPress?: () => void }> = ({
export const SignUpButton: React.FC<{ onPress?: () => void }> = ({
onPress,
}) => {
const [fontsLoaded, fontError] = useFonts({
"Gilroy-ExtraBold": require("../../../assets/fonts/Gilroy-ExtraBold.otf"),
"Gilroy-Light": require("../../../assets/fonts/Gilroy-Light.otf"),
});

if (!fontsLoaded && !fontError) {
return null;
}

return (
<TouchableOpacity style={styles.login_button} onPress={onPress}>
Expand Down
6 changes: 1 addition & 5 deletions client/app/configs/firebaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import {

const firebaseConfig = {
apiKey: API_KEY || "Mock-Key",
authDomain: AUTH_DOMAIN,
// projectId: PROJECT_ID,
// storageBucket: STORAGE_BUCKET,
// messagingSenderId: MESSAGING_SENDER_ID,
// appId: APP_ID,
authDomain: AUTH_DOMAIN
};

let app;
Expand Down
4 changes: 0 additions & 4 deletions client/config_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ LOCATION_REFRESH_RATE=3000

API_KEY = place_your_apiKey_here
AUTH_DOMAIN = place_your_authDomain_here
PROJECT_ID = place_your_projectId_here
STORAGE_BUCKET = place_your_storageBucket_here
MESSAGING_SENDER_ID = place_your_messagingSenderId_here
APP_ID = place_your_appId_here
1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ build

# Private Key JSON
firebase-secrets.json
firebase-secret.json

# Other
.env
Expand Down
16 changes: 8 additions & 8 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const { createServer } = require("http");
const { Server } = require("socket.io");
const socket_port = process.env.socket_port;
const express_port = process.env.express_port;
const message_outreach_radius = Number(process.env.message_outreach_radius);
const app = express();

// Middleware
Expand Down Expand Up @@ -77,8 +78,8 @@ io.on("connection", async (socket: any) => {
await toggleUserConnectionStatus(socket.id);

const observer = messagesCollection
.order('lastUpdated', "desc")
.limit(0)
.orderBy('lastUpdated', "desc")
.limit(1)
.onSnapshot((querySnapshot) => {
querySnapshot.docChanges().forEach((change) => {
if (change.type === "added") {
Expand All @@ -97,20 +98,19 @@ io.on("connection", async (socket: any) => {
userLon
);

if (distance < 300) {
console.log("Message is within 300m of user");
if (distance < message_outreach_radius) {
console.log(`Message is within ${message_outreach_radius} meters of the user ${socket.id}.`);
socket.emit("message", change.doc.data());
} else {
console.log("Message is not within 300m of user");
console.log(`Message is not within ${message_outreach_radius} meters of the user ${socket.id}.`);
}
}
});
});
});

socket.on("disconnect", () => {
console.log(`[WS] User <${socket.id}> exited.`);
deleteConnectedUserByUID(socket.id);
observer();
});
socket.on("ping", (ack) => {
// The (ack) parameter stands for "acknowledgement." This function sends a message back to the originating socket.
Expand All @@ -123,7 +123,7 @@ io.on("connection", async (socket: any) => {
try {
const messageCreated = await createMessage(message);
if (!messageCreated) throw new Error("createMessage() failed.");
if (ack) ack("message recieved");
if (ack) ack("message recieved");
} catch (error) {
console.error("[WS] Error sending message:", error.message);
}
Expand Down

0 comments on commit 03e7b30

Please sign in to comment.