-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched to publish subscribe model for messages (#208)
* added pubsub for messages * test * finished pub sub * testing empty secret * Delete server/firebase-secrets.json * added pubsub for messages * test * rebased --------- Co-authored-by: AlexanderWangY <[email protected]>
- Loading branch information
1 parent
787e006
commit 7b7b946
Showing
8 changed files
with
99 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
export interface MessageType { | ||
export interface Message { | ||
author: { | ||
uid: string | ||
displayName?: string // To be only used for display purposes (do not send to server) | ||
uid: string, | ||
displayName: string, | ||
} | ||
msgId: string | ||
msgContent: string | ||
timeSent: number // Unix timestamp; Date.now() returns a Number. | ||
timestamp: number | ||
lastUpdated: number | ||
location: { | ||
lat: number | ||
lon: number | ||
geohash?: string | ||
} | ||
isReply: boolean | ||
replyTo: string | ||
reactions: { | ||
[key: string]: number | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,7 @@ dist | |
build | ||
|
||
# Private Key JSON | ||
./private_key/* | ||
./firebase-secrets.json | ||
|
||
# Other | ||
.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const degreesToRadians = (degrees: number) => { | ||
return degrees * Math.PI / 180; | ||
} | ||
|
||
export const calculateDistanceInMeters = (lat1: number, lon1: number, lat2: number, lon2: number) => { | ||
const earthRadiusKm = 6371; | ||
|
||
const dLat = degreesToRadians(lat2-lat1); | ||
const dLon = degreesToRadians(lon2-lon1); | ||
|
||
lat1 = degreesToRadians(lat1); | ||
lat2 = degreesToRadians(lat2); | ||
|
||
const a = Math.sin(dLat/2) * Math.sin(dLat/2) + | ||
Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); | ||
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); | ||
return earthRadiusKm * c * 1000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
export interface Message { | ||
uid: string | ||
author: { | ||
uid: string, | ||
displayName: string, | ||
} | ||
msgId: string | ||
msgContent: string | ||
timeSent: number | ||
timestamp: number | ||
lastUpdated: number | ||
location: { | ||
lat: number | ||
lon: number | ||
geohash?: string | ||
} | ||
visibleToUids?: Array<string> | ||
isReply: boolean | ||
replyTo: string | ||
reactions: { | ||
[key: string]: number | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters