Skip to content

Commit

Permalink
chore(website): Enable Orbit to all macOS users (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldonadel authored Nov 16, 2023
1 parent 61e5b12 commit cab9239
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
4 changes: 1 addition & 3 deletions website/src/client/components/EditorToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export default function EditorToolbar(props: Props) {
const isPublishing = saveStatus === 'publishing';
const isPublished = saveStatus === 'published';

const { isEnabled: showOrbitButton, openWithExperienceURL: onOpenWithOrbit } = useOrbit({
experiments: viewer?.experiments,
});
const { isEnabled: showOrbitButton, openWithExperienceURL: onOpenWithOrbit } = useOrbit();

return (
<ToolbarShell>
Expand Down
12 changes: 2 additions & 10 deletions website/src/client/utils/orbit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import customProtocolCheck from 'custom-protocol-check';
import { useCallback, useEffect, useState } from 'react';

import { isMacOS } from './detectPlatform';
import { Experiment, UserData } from '../auth/authManager';

const ORBIT_SERVER_PORTS = [35783, 47909, 44171, 50799];

Expand Down Expand Up @@ -57,17 +56,10 @@ async function fetchLocalOrbitServer<T extends keyof LocalServerRoutes>(
return undefined;
}

interface UseOrbitParams {
experiments?: UserData['experiments'];
}

export function useOrbit({ experiments }: UseOrbitParams = {}) {
export function useOrbit() {
const [isRunning, setIsRunning] = useState(false);
const isRunningMacOS = isMacOS(navigator?.userAgent);

const hasEnabledOrbitExperiment =
experiments?.find(({ experiment }) => experiment === Experiment.Orbit)?.enabled ?? false;

const openWithExperienceURL = useCallback(
async (experienceURL: string, onFail?: () => void) => {
if (!experienceURL) {
Expand Down Expand Up @@ -97,7 +89,7 @@ export function useOrbit({ experiments }: UseOrbitParams = {}) {
}, [isRunningMacOS]);

return {
isEnabled: hasEnabledOrbitExperiment || isRunning,
isEnabled: isRunningMacOS,
openWithExperienceURL,
};
}

0 comments on commit cab9239

Please sign in to comment.