-
Notifications
You must be signed in to change notification settings - Fork 2
Fce 2879/fix docs #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fce 2879/fix docs #485
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,16 @@ | ||
| import React, { useState, useCallback } from "react"; | ||
| import { router } from "expo-router"; | ||
| import { useState } from "react"; | ||
| import { | ||
| Dimensions, | ||
| Image, | ||
| KeyboardAvoidingView, | ||
| Keyboard, | ||
| KeyboardAvoidingView, | ||
| StyleSheet, | ||
| Text, | ||
| View, | ||
| View | ||
| } from "react-native"; | ||
| import { SafeAreaView } from "react-native-safe-area-context"; | ||
| import { router, useFocusEffect } from "expo-router"; | ||
| import AsyncStorage from "@react-native-async-storage/async-storage"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: I think we don't use this library anymore and it could be removed. |
||
| import { Button, TextInput, DismissKeyboard } from "../../components"; | ||
| import { Button, DismissKeyboard, TextInput } from "../../components"; | ||
| import { changeFishjamId } from "../../utils/fishjamIdStore"; | ||
|
|
||
| const FishjamLogo = require("../../assets/images/fishjam-logo.png"); | ||
|
|
@@ -23,31 +22,12 @@ const VIDEOROOM_PROD_SANDBOX_URL = | |
|
|
||
| type VideoRoomEnv = "staging" | "prod"; | ||
|
|
||
| type VideoRoomData = { | ||
| videoRoomEnv: VideoRoomEnv; | ||
| roomName: string; | ||
| userName: string; | ||
| }; | ||
|
|
||
| async function saveStorageData(videoRoomData: VideoRoomData) { | ||
| await AsyncStorage.setItem("videoRoomData", JSON.stringify(videoRoomData)); | ||
| } | ||
|
|
||
| async function readStorageData(): Promise<VideoRoomData> { | ||
| const storageData = await AsyncStorage.getItem("videoRoomData"); | ||
| if (storageData) { | ||
| const videoRoomData = JSON.parse(storageData) as VideoRoomData; | ||
| return videoRoomData; | ||
| } | ||
| return { videoRoomEnv: "staging", roomName: "", userName: "" }; | ||
| } | ||
|
|
||
| export default function RoomScreen() { | ||
| const [connectionError, setConnectionError] = useState<string | null>(null); | ||
| const [roomName, setRoomName] = useState(""); | ||
| const [userName, setUserName] = useState(""); | ||
| const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>("staging"); | ||
|
|
||
| const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>("prod"); | ||
|
||
| const handleEnvChange = (env: VideoRoomEnv) => { | ||
| setVideoRoomEnv(env); | ||
| if (env === "staging") { | ||
|
|
@@ -57,43 +37,18 @@ export default function RoomScreen() { | |
| } | ||
| }; | ||
|
|
||
| useFocusEffect( | ||
| useCallback(() => { | ||
| const loadData = async () => { | ||
| const { | ||
| videoRoomEnv: storedVideoRoomEnv, | ||
| roomName: storedRoomName, | ||
| userName: storedUserName, | ||
| } = await readStorageData(); | ||
|
|
||
| setRoomName(storedRoomName); | ||
| setUserName(storedUserName); | ||
| setVideoRoomEnv(storedVideoRoomEnv); | ||
|
|
||
| if (storedVideoRoomEnv === "staging") { | ||
| changeFishjamId(VIDEOROOM_STAGING_SANDBOX_URL); | ||
| } else { | ||
| changeFishjamId(VIDEOROOM_PROD_SANDBOX_URL); | ||
| } | ||
| }; | ||
| loadData(); | ||
| }, []) | ||
| ); | ||
|
|
||
| const validateInputs = () => { | ||
| if (!roomName) { | ||
| throw new Error("Room name is required"); | ||
| } | ||
| }; | ||
|
|
||
| const onTapConnectButton = async () => { | ||
| const displayName = userName || "Mobile User"; | ||
| try { | ||
| validateInputs(); | ||
Magmusacy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| setConnectionError(null); | ||
|
|
||
| const displayName = userName || "Mobile User"; | ||
| await saveStorageData({ videoRoomEnv, roomName, userName: displayName }); | ||
|
|
||
| Keyboard.dismiss(); | ||
| router.push({ | ||
| pathname: "/room/preview", | ||
|
|
@@ -118,7 +73,7 @@ export default function RoomScreen() { | |
| source={FishjamLogo} | ||
| resizeMode="contain" | ||
| /> | ||
| <View | ||
| {VIDEOROOM_STAGING_SANDBOX_URL && (<View | ||
| style={{ | ||
| flexDirection: 'row', | ||
| justifyContent: 'space-around', | ||
|
|
@@ -134,7 +89,7 @@ export default function RoomScreen() { | |
| type={videoRoomEnv === 'prod' ? 'primary' : 'secondary'} | ||
| onPress={() => handleEnvChange('prod')} | ||
| /> | ||
| </View> | ||
| </View>)} | ||
|
Comment on lines
76
to
+92
|
||
| <TextInput | ||
| onChangeText={setRoomName} | ||
| placeholder="Room Name" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||
| import { Stack } from "expo-router"; | ||||||||||||||||||||||
| import { FishjamProvider } from "@fishjam-cloud/react-native-client"; | ||||||||||||||||||||||
| import { useState, useEffect } from "react"; | ||||||||||||||||||||||
| import { Stack } from "expo-router"; | ||||||||||||||||||||||
| import { useEffect, useState } from "react"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import { setFishjamIdChangeCallback } from "../utils/fishjamIdStore"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -13,6 +13,12 @@ export default function RootLayout() { | |||||||||||||||||||||
| setFishjamIdChangeCallback(setFishjamId); | ||||||||||||||||||||||
| }, []); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||
| if (!fishjamId) { | ||||||||||||||||||||||
| console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable."); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }, [fishjamId]); | ||||||||||||||||||||||
|
Comment on lines
+17
to
+20
|
||||||||||||||||||||||
| if (!fishjamId) { | |
| console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable."); | |
| } | |
| }, [fishjamId]); | |
| if (!DEFAULT_FISHJAM_ID) { | |
| console.error( | |
| "Fishjam ID is not configured. Set the EXPO_PUBLIC_FISHJAM_ID environment variable or select a preset that provides a Fishjam ID.", | |
| ); | |
| } | |
| }, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a trailing space at the end of the sentence "There also exists this additional environment variable, which is used for internal testing purposes: " (after the colon). This should be removed.