Skip to content

Commit

Permalink
fix: think of visionos always as ios
Browse files Browse the repository at this point in the history
There is currently no effective way to detect visionOS in Apple Vision (Designed for iPad) mode.
So it can only always be treated as ios to handle any surprises.
setBadgeText `null` value tested working on Safari 15.6.1 (macOS 12.6).
  • Loading branch information
ACTCD committed Feb 10, 2024
1 parent b660a36 commit af2954f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/ext/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,10 @@ function setClipboard(data, type = "text/plain") {
}

async function setBadgeCount() {
const clearBadge = () => {
if (import.meta.env.SAFARI_VERSION < 16.4) {
browser.browserAction.setBadgeText({ text: "" });
} else {
browser.browserAction.setBadgeText({ text: null });
}
};
const clearBadge = () => browser.browserAction.setBadgeText({ text: null });
// @todo until better introduce in ios, only set badge on macOS
const platform = await getPlatform();
// set a text badge or an empty string in visionOS will cause the extension's icon to no longer be displayed
// set it to null to fix already affected users
if (platform === "visionos") {
browser.browserAction.setBadgeText({ text: null });
return;
}
const platform = await getPlatform();
if (platform !== "macos") return clearBadge();
// @todo settingsStorage.get("global_exclude_match")
const settings = await settingsStorage.get([
Expand Down
1 change: 1 addition & 0 deletions xcode/Shared/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func getPlatform() -> String {
return "macos"
#elseif os(iOS)
// https://developer.apple.com/documentation/uikit/uiuserinterfaceidiom
// There is no reliable way to detect visionOS for now, will match `.phone` in Apple Vision (Designed for iPad) mode
switch UIDevice.current.userInterfaceIdiom {
case .phone:
return "ios"
Expand Down

0 comments on commit af2954f

Please sign in to comment.