feat(update): gate in-app updater to Android only
The updater downloads an .apk and hands it to the system package installer, which only exists on Android. Add an isAndroid() flag in mobile.js and run the update check behind it, so the update row never appears on iOS or the web build.
This commit is contained in:
1 parent
15b95eb434
commit
2c5678e877
4 files changed
+22
-4
No files matched your search
@@ -38,7 +38,7 @@ vi.mock('../lib/api.js', () => ({
|
||||
}))
|
||||
vi.mock('../lib/push.js', () => ({ pushSupported: () => false, enablePush: vi.fn(), disablePush: vi.fn(), sendTestPush: vi.fn() }))
|
||||
vi.mock('../lib/wakelock.js', () => ({ wakeLockSupported: () => false }))
|
||||
vi.mock('../lib/mobile.js', () => ({ MOBILE: false, shareExport: vi.fn(), syncReminder: vi.fn() }))
|
||||
vi.mock('../lib/mobile.js', () => ({ MOBILE: false, isAndroid: () => Promise.resolve(false), shareExport: vi.fn(), syncReminder: vi.fn() }))
|
||||
vi.mock('./MobileOnboarding.jsx', () => ({ ConnectSheet: () => null }))
|
||||
vi.mock('../sheets.jsx', () => ({
|
||||
loadStarterPlan: vi.fn(), confirmSheet: vi.fn(), importFromApp: vi.fn(),
|
||||
|
||||
@@ -9,7 +9,7 @@ import { pushSupported, enablePush, disablePush, sendTestPush } from '../lib/pus
|
||||
import { wakeLockSupported } from '../lib/wakelock.js'
|
||||
import { t, LANGS, INSTR_LANGS } from '../lib/i18n.js'
|
||||
import { DEMO, REPO } from '../lib/demo.js'
|
||||
import { MOBILE, shareExport, syncReminder } from '../lib/mobile.js'
|
||||
import { MOBILE, isAndroid, shareExport, syncReminder } from '../lib/mobile.js'
|
||||
import { checkForUpdate, downloadAndInstall } from '../lib/update.js'
|
||||
import { ConnectSheet } from './MobileOnboarding.jsx'
|
||||
import { loadStarterPlan, confirmSheet, importFromApp, importFromHevy, equipmentProfileSheet } from '../sheets.jsx'
|
||||
@@ -32,7 +32,9 @@ export default function Settings() {
|
||||
const [updateInfo, setUpdateInfo] = useState(null) // { hasUpdate, latestVersion, apkUrl, hashUrl } | null
|
||||
|
||||
useEffect(() => {
|
||||
checkForUpdate().then(setUpdateInfo).catch(() => {})
|
||||
// The in-app updater installs an .apk, so it only applies to the native Android build.
|
||||
// On iOS and the web this check is skipped and the update row never appears.
|
||||
isAndroid().then(ok => { if (ok) checkForUpdate().then(setUpdateInfo).catch(() => {}) })
|
||||
}, [])
|
||||
|
||||
const onUpdateRowClick = () => {
|
||||
|
||||
@@ -41,7 +41,7 @@ vi.mock('../lib/api.js', () => ({
|
||||
}))
|
||||
vi.mock('../lib/push.js', () => ({ pushSupported: () => false, enablePush: vi.fn(), disablePush: vi.fn(), sendTestPush: vi.fn() }))
|
||||
vi.mock('../lib/wakelock.js', () => ({ wakeLockSupported: () => false }))
|
||||
vi.mock('../lib/mobile.js', () => ({ MOBILE: false, shareExport: vi.fn(), syncReminder: vi.fn() }))
|
||||
vi.mock('../lib/mobile.js', () => ({ MOBILE: false, isAndroid: () => Promise.resolve(false), shareExport: vi.fn(), syncReminder: vi.fn() }))
|
||||
vi.mock('./MobileOnboarding.jsx', () => ({ ConnectSheet: () => null }))
|
||||
vi.mock('../sheets.jsx', () => ({
|
||||
loadStarterPlan: vi.fn(), confirmSheet: vi.fn(), importFromApp: vi.fn(),
|
||||
|
||||
Reference in new issue
Block a user