Skip to content

Commit f17edbe

Browse files
committed
[frontend] use puter.env to check environment instead of ancestorOrigins hack
1 parent 1669168 commit f17edbe

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

frontend/src/Browser.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { HistoryState } from "./History";
77
import { focusOmnibox } from "./components/UrlInput";
88

99
import * as tldts from "tldts";
10-
import { scramjet } from "./main";
10+
import { isPuter, scramjet } from "./main";
1111
import { animateDownloadFly } from "./components/Omnibox";
1212
import { showDownloadsPopup } from "./components/DownloadsPopup";
1313
export const pushTab = createDelegate<Tab>();
@@ -220,10 +220,7 @@ export class Browser extends StatefulClass {
220220

221221
destroyTab(tab: Tab) {
222222
this.tabs = this.tabs.filter((t) => t !== tab);
223-
if (
224-
this.tabs.length === 0 &&
225-
location.ancestorOrigins[0] === "https://puter.com"
226-
) {
223+
if (this.tabs.length === 0 && isPuter) {
227224
puter.exit();
228225
}
229226

frontend/src/components/Menu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Checkbox } from "./Checkbox";
1010
import { Icon } from "./Icon";
1111
import type { IconifyIcon } from "@iconify/types";
1212
import { emToPx } from "../utils";
13+
import { isPuter } from "../main";
1314

1415
export const closeMenu = createDelegate<void>();
1516

@@ -206,7 +207,7 @@ export function createMenu(
206207
y: number,
207208
items: MenuItem[]
208209
): DLElement<typeof Menu> {
209-
if (location.ancestorOrigins[0] === "https://puter.com") {
210+
if (isPuter) {
210211
puter.ui.contextMenu({
211212
items: items.map((i) =>
212213
i == "-"

frontend/src/components/Omnibox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import iconInfo from "@ktibow/iconset-ion/information-circle-outline";
2020
import iconSettings from "@ktibow/iconset-ion/settings-outline";
2121
import { showDownloadsPopup } from "./DownloadsPopup";
2222
import type { HistoryState } from "../History";
23+
import { isPuter } from "../main";
2324

2425
export const animateDownloadFly = createDelegate<void>();
2526

@@ -263,7 +264,7 @@ export const Omnibox: Component<{
263264
},
264265
icon: iconSettings,
265266
},
266-
...(location.ancestorOrigins[0] === "https://puter.com"
267+
...(isPuter
267268
? [
268269
{
269270
label: "Exit",

frontend/src/main.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { css, type Component } from "dreamland/core";
1212

1313
const { ScramjetController } = $scramjetLoadController();
1414

15+
export const isPuter = !import.meta.env.VITE_LOCAL && puter.env == "app";
16+
1517
const scramjetcfg: Partial<ScramjetInitConfig> = {
1618
wisp: "ws://localhost:1337/",
1719
files: {

0 commit comments

Comments
 (0)