Skip to content

Commit 347b6b1

Browse files
authored
Fce 2879/fix docs (#485)
## 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 - [ ] Documentation update required - [ ] Documentation updated [in another PR](_) - [X] No documentation update required ## Types of changes - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
1 parent 473ba1d commit 347b6b1

5 files changed

Lines changed: 25 additions & 88 deletions

File tree

examples/mobile-client/fishjam-chat/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
## Prerequisites
44

5-
Create a `.env` file in the `examples/mobile-client/fishjam-chat` directory (optional), or copy the `.env.example` file. The following environment variables are required:
5+
Copy `.env.example` to `.env` in the `examples/mobile-client/fishjam-chat` directory and fill in the required value:
66

7-
- `EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL` - Sandbox URL for VideoRoom staging environment
87
- `EXPO_PUBLIC_FISHJAM_ID` - Fishjam ID for production environment
98

9+
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.
10+
11+
There also exists this additional environment variable, which is used for internal testing purposes:
12+
13+
- `EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL` - Sandbox URL for VideoRoom staging environment
14+
1015
## Example Overview
1116

1217
The app has 2 tabs showing different ways to connect to Fishjam video calls:

examples/mobile-client/fishjam-chat/app/(tabs)/room.tsx

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import React, { useState, useCallback } from "react";
1+
import { router } from "expo-router";
2+
import { useState } from "react";
23
import {
34
Dimensions,
45
Image,
5-
KeyboardAvoidingView,
66
Keyboard,
7+
KeyboardAvoidingView,
78
StyleSheet,
89
Text,
9-
View,
10+
View
1011
} from "react-native";
1112
import { SafeAreaView } from "react-native-safe-area-context";
12-
import { router, useFocusEffect } from "expo-router";
13-
import AsyncStorage from "@react-native-async-storage/async-storage";
14-
import { Button, TextInput, DismissKeyboard } from "../../components";
13+
import { Button, DismissKeyboard, TextInput } from "../../components";
1514
import { changeFishjamId } from "../../utils/fishjamIdStore";
1615

1716
const FishjamLogo = require("../../assets/images/fishjam-logo.png");
@@ -23,31 +22,12 @@ const VIDEOROOM_PROD_SANDBOX_URL =
2322

2423
type VideoRoomEnv = "staging" | "prod";
2524

26-
type VideoRoomData = {
27-
videoRoomEnv: VideoRoomEnv;
28-
roomName: string;
29-
userName: string;
30-
};
31-
32-
async function saveStorageData(videoRoomData: VideoRoomData) {
33-
await AsyncStorage.setItem("videoRoomData", JSON.stringify(videoRoomData));
34-
}
35-
36-
async function readStorageData(): Promise<VideoRoomData> {
37-
const storageData = await AsyncStorage.getItem("videoRoomData");
38-
if (storageData) {
39-
const videoRoomData = JSON.parse(storageData) as VideoRoomData;
40-
return videoRoomData;
41-
}
42-
return { videoRoomEnv: "staging", roomName: "", userName: "" };
43-
}
44-
4525
export default function RoomScreen() {
4626
const [connectionError, setConnectionError] = useState<string | null>(null);
4727
const [roomName, setRoomName] = useState("");
4828
const [userName, setUserName] = useState("");
49-
const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>("staging");
50-
29+
const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>("prod");
30+
5131
const handleEnvChange = (env: VideoRoomEnv) => {
5232
setVideoRoomEnv(env);
5333
if (env === "staging") {
@@ -57,43 +37,18 @@ export default function RoomScreen() {
5737
}
5838
};
5939

60-
useFocusEffect(
61-
useCallback(() => {
62-
const loadData = async () => {
63-
const {
64-
videoRoomEnv: storedVideoRoomEnv,
65-
roomName: storedRoomName,
66-
userName: storedUserName,
67-
} = await readStorageData();
68-
69-
setRoomName(storedRoomName);
70-
setUserName(storedUserName);
71-
setVideoRoomEnv(storedVideoRoomEnv);
72-
73-
if (storedVideoRoomEnv === "staging") {
74-
changeFishjamId(VIDEOROOM_STAGING_SANDBOX_URL);
75-
} else {
76-
changeFishjamId(VIDEOROOM_PROD_SANDBOX_URL);
77-
}
78-
};
79-
loadData();
80-
}, [])
81-
);
82-
8340
const validateInputs = () => {
8441
if (!roomName) {
8542
throw new Error("Room name is required");
8643
}
8744
};
8845

8946
const onTapConnectButton = async () => {
47+
const displayName = userName || "Mobile User";
9048
try {
9149
validateInputs();
9250
setConnectionError(null);
9351

94-
const displayName = userName || "Mobile User";
95-
await saveStorageData({ videoRoomEnv, roomName, userName: displayName });
96-
9752
Keyboard.dismiss();
9853
router.push({
9954
pathname: "/room/preview",
@@ -118,7 +73,7 @@ export default function RoomScreen() {
11873
source={FishjamLogo}
11974
resizeMode="contain"
12075
/>
121-
<View
76+
{VIDEOROOM_STAGING_SANDBOX_URL && (<View
12277
style={{
12378
flexDirection: 'row',
12479
justifyContent: 'space-around',
@@ -134,7 +89,7 @@ export default function RoomScreen() {
13489
type={videoRoomEnv === 'prod' ? 'primary' : 'secondary'}
13590
onPress={() => handleEnvChange('prod')}
13691
/>
137-
</View>
92+
</View>)}
13893
<TextInput
13994
onChangeText={setRoomName}
14095
placeholder="Room Name"

examples/mobile-client/fishjam-chat/app/_layout.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Stack } from "expo-router";
21
import { FishjamProvider } from "@fishjam-cloud/react-native-client";
3-
import { useState, useEffect } from "react";
2+
import { Stack } from "expo-router";
3+
import { useEffect, useState } from "react";
44

55
import { setFishjamIdChangeCallback } from "../utils/fishjamIdStore";
66

@@ -13,6 +13,12 @@ export default function RootLayout() {
1313
setFishjamIdChangeCallback(setFishjamId);
1414
}, []);
1515

16+
useEffect(() => {
17+
if (!fishjamId) {
18+
console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable.");
19+
}
20+
}, [fishjamId]);
21+
1622
return (
1723
<FishjamProvider fishjamId={fishjamId}>
1824
<Stack screenOptions={{ headerShown: false }}>

examples/mobile-client/fishjam-chat/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"dependencies": {
1616
"@expo/vector-icons": "^15.0.3",
1717
"@fishjam-cloud/react-native-client": "workspace:*",
18-
"@react-native-async-storage/async-storage": "^2.2.0",
1918
"@react-navigation/bottom-tabs": "^7.4.0",
2019
"@react-navigation/elements": "^2.6.3",
2120
"@react-navigation/native": "^7.1.8",

yarn.lock

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5715,17 +5715,6 @@ __metadata:
57155715
languageName: node
57165716
linkType: hard
57175717

5718-
"@react-native-async-storage/async-storage@npm:^2.2.0":
5719-
version: 2.2.0
5720-
resolution: "@react-native-async-storage/async-storage@npm:2.2.0"
5721-
dependencies:
5722-
merge-options: "npm:^3.0.4"
5723-
peerDependencies:
5724-
react-native: ^0.0.0-0 || >=0.65 <1.0
5725-
checksum: 10c0/84900eba46a40225c4ac9bf5eb58885200dc1e789d873ecda46a2a213870cc7110536ed1fd7a74b873071f3603c093958fbd84c635d6f6d4f94bfbb616ffa0ef
5726-
languageName: node
5727-
linkType: hard
5728-
57295718
"@react-native/assets-registry@npm:0.81.5":
57305719
version: 0.81.5
57315720
resolution: "@react-native/assets-registry@npm:0.81.5"
@@ -12038,7 +12027,6 @@ __metadata:
1203812027
dependencies:
1203912028
"@expo/vector-icons": "npm:^15.0.3"
1204012029
"@fishjam-cloud/react-native-client": "workspace:*"
12041-
"@react-native-async-storage/async-storage": "npm:^2.2.0"
1204212030
"@react-navigation/bottom-tabs": "npm:^7.4.0"
1204312031
"@react-navigation/elements": "npm:^2.6.3"
1204412032
"@react-navigation/native": "npm:^7.1.8"
@@ -13175,13 +13163,6 @@ __metadata:
1317513163
languageName: node
1317613164
linkType: hard
1317713165

13178-
"is-plain-obj@npm:^2.1.0":
13179-
version: 2.1.0
13180-
resolution: "is-plain-obj@npm:2.1.0"
13181-
checksum: 10c0/e5c9814cdaa627a9ad0a0964ded0e0491bfd9ace405c49a5d63c88b30a162f1512c069d5b80997893c4d0181eadc3fed02b4ab4b81059aba5620bfcdfdeb9c53
13182-
languageName: node
13183-
linkType: hard
13184-
1318513166
"is-potential-custom-element-name@npm:^1.0.1":
1318613167
version: 1.0.1
1318713168
resolution: "is-potential-custom-element-name@npm:1.0.1"
@@ -14615,15 +14596,6 @@ __metadata:
1461514596
languageName: node
1461614597
linkType: hard
1461714598

14618-
"merge-options@npm:^3.0.4":
14619-
version: 3.0.4
14620-
resolution: "merge-options@npm:3.0.4"
14621-
dependencies:
14622-
is-plain-obj: "npm:^2.1.0"
14623-
checksum: 10c0/02b5891ceef09b0b497b5a0154c37a71784e68ed71b14748f6fd4258ffd3fe4ecd5cb0fd6f7cae3954fd11e7686c5cb64486daffa63c2793bbe8b614b61c7055
14624-
languageName: node
14625-
linkType: hard
14626-
1462714599
"merge-stream@npm:^2.0.0":
1462814600
version: 2.0.0
1462914601
resolution: "merge-stream@npm:2.0.0"

0 commit comments

Comments
 (0)