Clean up useFallback for the push adapter
This commit is contained in:
parent
cf6c025bf2
commit
1cbb862b33
3 changed files with 9 additions and 7 deletions
|
|
@ -5,7 +5,7 @@ import {maybe, now} from "@welshman/lib"
|
|||
import type {Filter} from "@welshman/util"
|
||||
import type {Session} from "@welshman/app"
|
||||
import {app, session} from "@app/core"
|
||||
import {pushState} from "@app/push/adapters/common"
|
||||
import {pushState, requiresFallback} from "@app/push/adapters/common"
|
||||
import type {IPushAdapter} from "@app/push/adapters/common"
|
||||
import {syncRelaySubscriptions} from "@app/push/adapters/common"
|
||||
|
||||
|
|
@ -92,6 +92,6 @@ export class AndroidFallbackNotifications implements IPushAdapter {
|
|||
|
||||
await AndroidPushFallback.syncState({state: {}})
|
||||
|
||||
pushState.set({})
|
||||
pushState.set({useFallback: requiresFallback})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {writable} from "svelte/store"
|
||||
import type {Subscriber, Unsubscriber} from "svelte/store"
|
||||
import {Capacitor} from "@capacitor/core"
|
||||
import {assoc, call, ms, now, on, parseJson, poll, spec, throttle, uniq} from "@welshman/lib"
|
||||
import {LOCAL_RELAY_URL} from "@welshman/net"
|
||||
import type {RepositoryUpdate} from "@welshman/net"
|
||||
|
|
@ -33,7 +34,11 @@ export type PushState = {
|
|||
subscription?: PushSubscription
|
||||
}
|
||||
|
||||
export const pushState = withGetter(writable<PushState>({}))
|
||||
// The F-Droid build ships without the push plugin, so those installs can only ever poll
|
||||
export const requiresFallback =
|
||||
Capacitor.getPlatform() === "android" && !Capacitor.isPluginAvailable("PushNotifications")
|
||||
|
||||
export const pushState = withGetter(writable<PushState>({useFallback: requiresFallback}))
|
||||
|
||||
export interface IPushAdapter {
|
||||
request: (prompt?: boolean) => Promise<string>
|
||||
|
|
|
|||
|
|
@ -18,10 +18,7 @@ export class Push {
|
|||
|
||||
if (Capacitor.getPlatform() === "electron") {
|
||||
Push._adapter = new ElectronNotifications()
|
||||
} else if (
|
||||
Capacitor.getPlatform() === "android" &&
|
||||
(useFallback || !Capacitor.isPluginAvailable("PushNotifications"))
|
||||
) {
|
||||
} else if (Capacitor.getPlatform() === "android" && useFallback) {
|
||||
Push._adapter = new AndroidFallbackNotifications()
|
||||
} else if (Capacitor.isPluginAvailable("PushNotifications")) {
|
||||
Push._adapter = new CapacitorNotifications()
|
||||
|
|
|
|||
Loading…
Reference in a new issue