-
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.
- Loading branch information
Showing
19 changed files
with
232 additions
and
174 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
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,27 @@ | ||
import React, { createContext, useContext, useState } from "react"; | ||
import { UserProfile } from "../types/User"; | ||
import { getNearbyUsers } from "@app/services/SocketService"; | ||
import { Socket } from "socket.io-client"; | ||
|
||
const NearbyUsersContext = createContext<{ [uid: string]: UserProfile }>({}); | ||
|
||
export const useNearbyUsers = () => { | ||
return useContext(NearbyUsersContext); | ||
}; | ||
|
||
var setNearbyUsersCallback: React.Dispatch<React.SetStateAction<{ | ||
[uid: string]: UserProfile; | ||
}>> | undefined = undefined; | ||
export const refreshNearbyUsers = async (socket: Socket) => { | ||
if (setNearbyUsersCallback === undefined) return; | ||
const nearbyUsers = await getNearbyUsers(socket); | ||
console.log(nearbyUsers); | ||
setNearbyUsersCallback(nearbyUsers); | ||
} | ||
|
||
export const NearbyUsersProvider = ({ children }: { children: React.ReactNode }) => { | ||
const [user, setNearbyUsers] = useState<{ [uid: string]: UserProfile }>({}); | ||
setNearbyUsersCallback = setNearbyUsers; | ||
|
||
return <NearbyUsersContext.Provider value={user}>{children}</NearbyUsersContext.Provider>; | ||
}; |
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
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 was deleted.
Oops, something went wrong.
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,6 +1,8 @@ | ||
declare module "@env" { | ||
export const EXPO_IP: string; | ||
export const SOCKET_IP: string; | ||
export const SOCKET_PORT: number; | ||
export const API_KEY: string; | ||
export const AUTH_DOMAIN: string; | ||
export const PROJECT_ID: string; | ||
export const LOCATION_REFRESH_RATE: string; | ||
} |
Oops, something went wrong.