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

fix: styling and other issues on Apple Devices #3065

Merged
merged 13 commits into from
Mar 18, 2024
19 changes: 19 additions & 0 deletions src/app/router/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ import Popup from "./Popup";
// Get the active theme and apply corresponding Tailwind classes to the document
setTheme();

// Occupy full width in Safari Extension on iOS
document.addEventListener("DOMContentLoaded", function () {
const isSafariOniOS =
navigator.userAgent.match(/iPhone/i) &&
navigator.userAgent.match(/Safari/i);
const isSafariOniPad =
navigator.userAgent.match(/Macintosh/i) &&
navigator.userAgent.match(/Safari/i) &&
navigator.maxTouchPoints &&
navigator.maxTouchPoints > 1;
if (isSafariOniOS) {
document.body.classList.remove("w-96");
document.body.classList.add("w-full");
}
if (isSafariOniPad) {
document.body.classList.remove("max-w-full");
reneaaron marked this conversation as resolved.
Show resolved Hide resolved
}
});

const container = document.getElementById("popup-root") as HTMLElement;
const root = createRoot(container);
root.render(<Popup />);
12 changes: 7 additions & 5 deletions src/app/screens/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ const Home: FC = () => {
if (currentUrl) {
const url = new URL(currentUrl);
setCurrentUrl(url);
}

if (currentUrl && currentUrl.startsWith("http")) {
browser.tabs.sendMessage(tabs[0].id as number, {
action: "extractLightningData",
});
if (currentUrl.startsWith("http")) {
browser.tabs.sendMessage(tabs[0].id as number, {
action: "extractLightningData",
});
}
} else {
setLoadingAllowance(false);
reneaaron marked this conversation as resolved.
Show resolved Hide resolved
}
};

Expand Down
8 changes: 5 additions & 3 deletions src/extension/background-script/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,14 @@ const state = create<State>((set, get) => ({

// https://stackoverflow.com/a/54317362/1667461
const allTabIds = Array.from(allTabs, (tab) => tab.id).filter(
(i): i is number => {
return typeof i === "number";
(id, index): id is number => {
// Safari: allTabs consist of Start Pages too
return typeof id === "number" && allTabs[index].title !== "";
reneaaron marked this conversation as resolved.
Show resolved Hide resolved
}
);

browser.tabs.remove(allTabIds);
// Safari: extension popup is not a tab
if (allTabIds.length) browser.tabs.remove(allTabIds);

if (get().connector) {
const connector = (await get().connector) as Connector;
Expand Down
Loading