Skip to content

Commit

Permalink
fix: styling and other issues on Apple Devices (#3065)
Browse files Browse the repository at this point in the history
* fix: use min width instead fo fixed width

* fix: use useragent to adjust width

* chore: stop loading allowance if no url is present

* chore: remove full width class on iPad

* chore: don't remove start page on lock

* chore: remove unnecessary line

* chore: loadAllowance after setting current url

* chore: rename getcurrenturl

* fix: home screen in start page

---------

Co-authored-by: René Aaron <[email protected]>
  • Loading branch information
im-adithya and reneaaron authored Mar 18, 2024
1 parent 760887d commit 9e76550
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
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");
}
});

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);
}
};

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 !== "";
}
);

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

0 comments on commit 9e76550

Please sign in to comment.