Skip to content

Commit

Permalink
Fix misdetecting iPadOS as Mac
Browse files Browse the repository at this point in the history
Signed-off-by: William So <[email protected]>
  • Loading branch information
polyipseity committed Jun 6, 2024
1 parent 6a6b55b commit efc2ffc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-phones-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@polyipseity/obsidian-plugin-library": patch
---

Fix misdetecting iPadOS as Mac.
25 changes: 14 additions & 11 deletions sources/platform.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { LibraryUUIDs } from "./magic.js"
import type { Opaque } from "ts-essentials"
import { Platform as Platform0 } from "obsidian"
import { deepFreeze } from "./util.js"

export namespace Platform {
Expand All @@ -12,21 +13,23 @@ export namespace Platform {
export type All = typeof ALL[number]
export type Current = Opaque<All, typeof LibraryUUIDs["UUID2"]>
export const CURRENT = ((): All => {
const { userAgent } = self.navigator
if (userAgent.includes("like Mac")) {
if (Platform0.isIosApp) {
return "ios"
}
if (userAgent.includes("Android")) {
if (Platform0.isAndroidApp) {
return "android"
}
if (userAgent.includes("Mac")) {
return "darwin"
}
if (userAgent.includes("Win")) {
return "win32"
}
if (userAgent.includes("Linux") || userAgent.includes("X11")) {
return "linux"
if (Platform0.isDesktopApp) {
const { userAgent } = self.navigator
if (userAgent.includes("Mac")) {
return "darwin"
}
if (userAgent.includes("Win")) {
return "win32"
}
if (userAgent.includes("Linux") || userAgent.includes("X11")) {
return "linux"
}
}
return "unknown"
})() as Current
Expand Down

0 comments on commit efc2ffc

Please sign in to comment.