Skip to content

Commit

Permalink
Modify changes to match current code
Browse files Browse the repository at this point in the history
  • Loading branch information
twsl committed Feb 19, 2022
1 parent 02ccddb commit e0a386c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
11 changes: 10 additions & 1 deletion app/packages/app/src/components/Flashlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ export let sampleIndices = new Map<number, string>();
let nextIndex = 0;
let lookers = createLookerCache();

const url = `${http}page?`;
const url = (() => {
let origin = window.location.origin;
try {
// @ts-ignore
if (import.meta.env.DEV) {
origin = "http://localhost:5151";
}
} catch {}
return `${http}/page?`;
})();

const Container = styled.div`
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion app/packages/app/src/components/ViewBar/viewBarMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const createStage = (
});

function getStageInfo(context) {
return fetch(`${context.http}stages`).then((response) => response.json());
return fetch(`${context.http}/stages`).then((response) => response.json());
}

function serializeStage(stage, stageMap, fieldNames) {
Expand Down
4 changes: 2 additions & 2 deletions app/packages/app/src/recoil/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const fiftyone = selector({
let response = null;
do {
try {
response = await (await fetch(`${http}fiftyone`)).json();
response = await (await fetch(`${http}/fiftyone`)).json();
} catch {}
if (response) break;
await new Promise((r) => setTimeout(r, 2000));
Expand All @@ -66,7 +66,7 @@ export const showTeamsButton = selector({
const storedTeams = window.localStorage.getItem("fiftyone-teams");
if (storedTeams) {
window.localStorage.removeItem("fiftyone-teams");
fetch(`${http}teams?submitted=true`, { method: "post" });
fetch(`${http}/teams?submitted=true`, { method: "post" });
}
if (
teams.submitted ||
Expand Down
12 changes: 6 additions & 6 deletions app/packages/app/src/shared/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ export const handleId = new URLSearchParams(window.location.search).get(
export const sessionId = uuid();

const host = import.meta.env.DEV ? "localhost:5151" : window.location.host;
const path =
window.location.pathname +
(window.location.pathname.endsWith("/") ? "" : "/");
const path = window.location.pathname.endsWith("/") ? window.location.pathname.slice(0, -1) : window.location.pathname;

export const port = isElectron()
? parseInt(process.env.FIFTYONE_SERVER_PORT) || 5151
Expand All @@ -122,19 +120,21 @@ export const http = isElectron()
: window.location.protocol + "//" + host + path;

export const ws = isElectron()
? `ws://${address}:${port}${path}state`
? `ws://${address}:${port}${path}/state`
: `${
window.location.protocol === "https:" ? "wss:" : "ws:"
}//${host}${path}state`;
}//${host}${path}/state`;

export const appContext = isElectron()
? "desktop"
: isColab
? "colab"
: isDatabricks
? "databricks"
: isNotebook
? "notebook"
: "browser";

export default polling
? new HTTPSSocket(`${http}polling?sessionId=${sessionId}`)
? new HTTPSSocket(`${http}/polling?sessionId=${sessionId}`)
: new ReconnectingWebSocket(ws);

0 comments on commit e0a386c

Please sign in to comment.