Skip to content
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

[expo-dev-launcher] Remove debug settings for EAS Updates extension #27603

Merged
merged 2 commits into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/expo-dev-launcher/CHANGELOG.md
Expand Up @@ -21,6 +21,7 @@
- Fixed lint warning ([#26876](https://github.com/expo/expo/pull/26876) by [@GaelCO](https://github.com/GaelCO))
- Decouple from "bridge" in `expo-updates`. ([#27216](https://github.com/expo/expo/pull/27216) by [@kudo](https://github.com/kudo))
- Removed [Flipper workaround](https://github.com/expo/expo/pull/18105) on Android. ([#27508](https://github.com/expo/expo/pull/27508) by [@kudo](https://github.com/kudo))
- Remove debug settings for EAS Updates extension. ([#27603](https://github.com/expo/expo/pull/27603) by [@wschurman](https://github.com/wschurman))

### 📚 3rd party library updates

Expand Down

Large diffs are not rendered by default.

@@ -1,46 +1,14 @@
import * as React from 'react';

import {
EXUpdatesConfig,
updatesConfig as initialUpdatesConfig,
} from '../native-modules/DevLauncherInternal';
import { EXUpdatesConfig, updatesConfig } from '../native-modules/DevLauncherInternal';

const defaultUpdatesConfig: EXUpdatesConfig = {
runtimeVersion: '',
sdkVersion: '',
appId: '',
usesEASUpdates: false,
projectUrl: '',
};

const Context = React.createContext<EXUpdatesConfig>(defaultUpdatesConfig);
const Context = React.createContext<EXUpdatesConfig | null>(null);
export const useUpdatesConfig = () => React.useContext(Context);

type UpdatesConfigProviderProps = {
children: React.ReactNode;
initialUpdatesConfig?: EXUpdatesConfig;
};

type SetUpdatesConfigContext = (config: Partial<EXUpdatesConfig>) => void;
const SetConfigContext = React.createContext<SetUpdatesConfigContext>(() => {});

export const useSetUpdatesConfig = () => React.useContext(SetConfigContext);

export function UpdatesConfigProvider({ children }: UpdatesConfigProviderProps) {
const [updatesConfig, setUpdatesConfig] = React.useState(initialUpdatesConfig);

function onSetUpdatesConfig(updates: Partial<EXUpdatesConfig>) {
setUpdatesConfig((previousConfig) => {
return {
...previousConfig,
...updates,
};
});
}

return (
<SetConfigContext.Provider value={onSetUpdatesConfig}>
<Context.Provider value={updatesConfig}>{children}</Context.Provider>
</SetConfigContext.Provider>
);
return <Context.Provider value={updatesConfig}>{children}</Context.Provider>;
}
79 changes: 2 additions & 77 deletions packages/expo-dev-launcher/bundle/screens/SettingsScreen.tsx
Expand Up @@ -10,7 +10,6 @@ import {
ShowMenuIcon,
ThreeFingerPressIcon,
CheckIcon,
TextInput,
} from 'expo-dev-client-components';
import * as React from 'react';
import { ScrollView, Switch } from 'react-native';
Expand All @@ -24,7 +23,7 @@ import { useBuildInfo } from '../providers/BuildInfoProvider';
import { useDevMenuPreferences } from '../providers/DevMenuPreferencesProvider';
import { useQueryOptions } from '../providers/QueryProvider';
import { useToastStack } from '../providers/ToastStackProvider';
import { useSetUpdatesConfig, useUpdatesConfig } from '../providers/UpdatesConfigProvider';
import { useUpdatesConfig } from '../providers/UpdatesConfigProvider';
import { useUser } from '../providers/UserContextProvider';

export function SettingsScreen() {
Expand Down Expand Up @@ -307,45 +306,10 @@ function DebugSettings() {

function UpdatesDebugSettings() {
const updatesConfig = useUpdatesConfig();
const defaultUpdatesConfig = React.useRef(updatesConfig).current;
const setUpdatesConfig = useSetUpdatesConfig();
const toastStack = useToastStack();

function onUrlChange({ nativeEvent: { text: appId } }) {
let appliedAppId = appId;
let usesEASUpdates = true;

if (appId.length === 0) {
appliedAppId = defaultUpdatesConfig.appId;
usesEASUpdates = false;
}

setUpdatesConfig({ appId, usesEASUpdates });
toastStack.push(() => <Toasts.Info>{`Updated appId to ${appliedAppId}`}</Toasts.Info>);
}

function onRuntimeVersionChange({ nativeEvent: { text: runtimeVersion } }) {
let appliedRuntimeVersion = runtimeVersion;

if (runtimeVersion.length === 0) {
appliedRuntimeVersion = defaultUpdatesConfig.runtimeVersion;
}

setUpdatesConfig({ runtimeVersion });
toastStack.push(() => (
<Toasts.Info>{`Updated runtimeVersion to ${appliedRuntimeVersion}`}</Toasts.Info>
));
}

return (
<View my="medium">
<View px="medium">
<Heading color="secondary">EAS Update Debug Settings</Heading>
<Spacer.Vertical size="medium" />
</View>

<View px="medium">
<Text color="secondary">Current Settings</Text>
<Heading color="secondary">EAS Update configuration</Heading>
<Spacer.Vertical size="medium" />
</View>

Expand All @@ -354,45 +318,6 @@ function UpdatesDebugSettings() {
{JSON.stringify(updatesConfig, null, 2)}
</Text>
</View>

<Spacer.Vertical size="medium" />

<View px="medium">
<Heading size="small" color="secondary">
EAS project ID
</Heading>
<Spacer.Vertical size="small" />
</View>

<View bg="default" rounded="large" py="small" px="small">
<TextInput
blurOnSubmit
autoCapitalize="none"
keyboardType="url"
placeholder="Set EAS project ID"
defaultValue={updatesConfig?.appId ?? ''}
onSubmitEditing={onUrlChange}
/>
</View>
<Spacer.Vertical size="small" />
<View px="medium">
<Heading size="small" color="secondary">
Runtime Version
</Heading>
<Spacer.Vertical size="small" />
</View>
<View bg="default" rounded="large" py="small" px="small">
<TextInput
blurOnSubmit
autoCapitalize="none"
keyboardType="url"
placeholder="Set Runtime Version"
defaultValue={updatesConfig?.runtimeVersion ?? ''}
onSubmitEditing={onRuntimeVersionChange}
/>
</View>

<Spacer.Vertical size="large" />
</View>
);
}