Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the documentation for the fishjam-chat example app to guide external contributors on how to obtain the required environment variables. It also cleans up leftover code by removing the AsyncStorage-based persistence of environment preferences (now managed purely via env variables), and conditionally hides the staging/prod environment toggle UI when the staging env variable is not set.
Changes:
- Updated
README.mdto clarify which env variables are required, how to obtain them, and to distinguish the internal-only staging URL variable. - Removed
AsyncStoragepersistence logic anduseFocusEffectfromroom.tsx, defaulting to"prod"environment and conditionally rendering environment toggle buttons only whenEXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URLis set. - Added a
console.errorwarning in_layout.tsxwhenEXPO_PUBLIC_FISHJAM_IDis not set.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
examples/mobile-client/fishjam-chat/README.md |
Reorders and clarifies env variable documentation for external developers |
examples/mobile-client/fishjam-chat/app/(tabs)/room.tsx |
Removes AsyncStorage persistence, conditionally shows env toggle, defaults to prod env |
examples/mobile-client/fishjam-chat/app/_layout.tsx |
Adds a diagnostic error log when EXPO_PUBLIC_FISHJAM_ID is missing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!fishjamId) { | ||
| console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable."); | ||
| } |
There was a problem hiding this comment.
The console.error call is placed directly in the render function body (not inside a useEffect). This means it will fire on every render while fishjamId is falsy, causing repeated error messages to be logged (e.g., during normal re-renders while the app is waiting for the environment variable to be loaded, or if the user's context causes a re-render).
Since this is a diagnostic one-time warning (not a per-render concern), it should be placed inside the existing useEffect, or a separate useEffect with fishjamId as a dependency, so it fires only once when the condition is detected.
| if (!fishjamId) { | |
| console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable."); | |
| } | |
| useEffect(() => { | |
| if (!fishjamId) { | |
| console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable."); | |
| } | |
| }, [fishjamId]); |
| process.env.EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL ?? ""; | ||
| const VIDEOROOM_PROD_SANDBOX_URL = | ||
| process.env.EXPO_PUBLIC_FISHJAM_ID ?? ""; | ||
| process.env.EXPO_PUBLIC_FISHJAM_ID!; |
There was a problem hiding this comment.
Using the non-null assertion operator (!) on process.env.EXPO_PUBLIC_FISHJAM_ID only suppresses the TypeScript compiler warning — it does not guarantee the value is defined at runtime. If the environment variable is absent, VIDEOROOM_PROD_SANDBOX_URL will be undefined at runtime, which can cause silent failures when changeFishjamId is called with it (e.g., when the prod env button is pressed).
For consistency with how this env variable is handled elsewhere in the codebase (e.g., _layout.tsx line 7 uses ?? "", and livestream.tsx line 20 also uses ?? ""), consider using process.env.EXPO_PUBLIC_FISHJAM_ID ?? "" instead.
| process.env.EXPO_PUBLIC_FISHJAM_ID!; | |
| process.env.EXPO_PUBLIC_FISHJAM_ID ?? ""; |
| - `EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL` - Sandbox URL for VideoRoom staging environment | ||
| - `EXPO_PUBLIC_FISHJAM_ID` - Fishjam ID for production environment | ||
|
|
||
| You can find value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard. |
There was a problem hiding this comment.
The sentence "You can find value for this variable..." is missing the article "the" before "value". It should read "You can find the value for this variable...".
| You can find value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard. | |
| You can find the value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard. |
|
|
||
| You can find value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard. | ||
|
|
||
| There also exists this additional environment variable, which is used for internal testing purposes: |
There was a problem hiding this comment.
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.
| There also exists this additional environment variable, which is used for internal testing purposes: | |
| There also exists this additional environment variable, which is used for internal testing purposes: |
8d7a896 to
eb26f7c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>( | ||
| VIDEOROOM_PROD_SANDBOX_URL ? "prod" : "staging", | ||
| ); | ||
|
|
There was a problem hiding this comment.
There is a trailing whitespace on this line (line 32 in the new file, line 53 in the diff). While not a functional issue, this is inconsistent with the surrounding code style.
| const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>( | ||
| VIDEOROOM_PROD_SANDBOX_URL ? "prod" : "staging", | ||
| ); |
There was a problem hiding this comment.
When only EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL is set and EXPO_PUBLIC_FISHJAM_ID is empty, the default videoRoomEnv is "staging" (line 30), but changeFishjamId(VIDEOROOM_STAGING_SANDBOX_URL) is never called on mount. This means the fishjamId in FishjamProvider (in _layout.tsx) starts as an empty string, so the staging URL is not actually applied until the user manually presses the "Staging" button. The old code handled this via useFocusEffect. A useEffect that calls changeFishjamId with the appropriate URL on mount (based on the initial videoRoomEnv value) would fix this regression.
| @@ -134,7 +91,7 @@ export default function RoomScreen() { | |||
| type={videoRoomEnv === 'prod' ? 'primary' : 'secondary'} | |||
| onPress={() => handleEnvChange('prod')} | |||
| /> | |||
| </View> | |||
| </View>)} | |||
There was a problem hiding this comment.
The env switcher (staging/prod buttons) is conditionally shown only when VIDEOROOM_STAGING_SANDBOX_URL is set, but it does not also check whether VIDEOROOM_PROD_SANDBOX_URL is set. When only staging is available, pressing the "Production" button calls changeFishjamId(""), which sets the Fishjam ID to an empty string and would cause connection errors. The condition should also verify that VIDEOROOM_PROD_SANDBOX_URL is non-empty before showing both buttons, or at minimum the "Production" button should be disabled/hidden when VIDEOROOM_PROD_SANDBOX_URL is absent.
| if (!fishjamId) { | ||
| console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable."); | ||
| } | ||
| }, [fishjamId]); |
There was a problem hiding this comment.
The error message says "Please set the EXPO_PUBLIC_FISHJAM_ID environment variable" but fishjamId can also be legitimately changed to an empty string by changeFishjamId("") (e.g., via the "Production" button when no prod URL is configured). In such cases this error message is misleading. Additionally, this effect fires on every change to fishjamId, so if fishjamId goes empty after already being set, users would see a confusing console error. Consider restricting this log to mount only (using a ref to track initial mount), or making the message more general.
| 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.", | |
| ); | |
| } | |
| }, []); |
eb26f7c to
de9a6d0
Compare
| } 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"; |
There was a problem hiding this comment.
suggestion: I think we don't use this library anymore and it could be removed.
Description
Fix documentation to tell the user where to get env variables from as well as remove env buttons from Room tab when env variable for VIDEOROOM_STAGING_SANDBOX_URL is not present. I also deleted some code that was left over from the times when we didn't use env variables to save in async storage preferred environment.
Motivation and Context
It helps outsiders build fishjam-chat example and cleans the code a little bit
Documentation impact
Types of changes
not work as expected)