From af2954f17a66384945d4bd6e1429cd4e7d24236e Mon Sep 17 00:00:00 2001 From: ACTCD <101378590+ACTCD@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:04:29 +0800 Subject: [PATCH] fix: think of visionos always as ios 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). --- src/ext/background/main.js | 15 ++------------- xcode/Shared/Utilities.swift | 1 + 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/ext/background/main.js b/src/ext/background/main.js index 1c51e2c4..135661bb 100644 --- a/src/ext/background/main.js +++ b/src/ext/background/main.js @@ -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([ diff --git a/xcode/Shared/Utilities.swift b/xcode/Shared/Utilities.swift index 8e3f0949..dfb00425 100644 --- a/xcode/Shared/Utilities.swift +++ b/xcode/Shared/Utilities.swift @@ -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"