Skip to content

Commit

Permalink
feat(cozy-device-helper): Add isFlagshipOfflineSupported() method
Browse files Browse the repository at this point in the history
Since cozy/cozy-flagship-app#1209 the Flagship app can inject the
`offline_available` attribute into WebViews metadata in order to tell
the cozy-app when offline mode is supported

The new `` method can now be used to check this attribute
  • Loading branch information
Ldoppea committed Sep 9, 2024
1 parent 4e4b2fb commit c1db89e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/cozy-device-helper/src/flagship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface FlagshipMetadata {
biometry_type?: BiometryType
immersive?: boolean
navbarHeight?: number
offline_available?: boolean
platform?: Record<string, unknown>
route?: FlagshipRoutes
settings_PINEnabled?: boolean
Expand All @@ -40,3 +41,6 @@ export const getFlagshipMetadata = (): FlagshipMetadata =>

export const isFlagshipApp = (): boolean =>
getGlobalWindow()?.cozy?.flagship !== undefined

export const isFlagshipOfflineSupported = (): boolean =>
getGlobalWindow()?.cozy?.flagship?.offline_available
6 changes: 5 additions & 1 deletion packages/cozy-device-helper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export { isCordova } from './cordova'
export { nativeLinkOpen } from './link'
export { openDeeplinkOrRedirect } from './deeplink'

export { isFlagshipApp, getFlagshipMetadata } from './flagship'
export {
isFlagshipApp,
isFlagshipOfflineSupported,
getFlagshipMetadata
} from './flagship'

0 comments on commit c1db89e

Please sign in to comment.