From e642b502ce630786c817665b6999560d2f44f770 Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Fri, 26 Jul 2024 16:17:55 +0200 Subject: [PATCH 1/3] feat(cozy-intent): Add `flagshipLinkRequest` native method `flagshipLinkRequest` intent will be used by new `FlagshipLink` link in cozy-client --- packages/cozy-intent/src/api/models/methods.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cozy-intent/src/api/models/methods.ts b/packages/cozy-intent/src/api/models/methods.ts index 227cb49d1d..4182153530 100644 --- a/packages/cozy-intent/src/api/models/methods.ts +++ b/packages/cozy-intent/src/api/models/methods.ts @@ -26,6 +26,7 @@ interface _NativeMethodsRegister { ocr: (base64: string) => unknown openAppOSSettings: () => Promise isAvailable: (featureName: string) => Promise + flagshipLinkRequest: (operation: unknown) => Promise } export type NativeMethodsRegister = _NativeMethodsRegister & PostMeDefault From 155cb57900ee112ee97d8d3d7783262ecfbdde84 Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Mon, 26 Aug 2024 17:53:52 +0200 Subject: [PATCH 2/3] feat(cozy-intent): Add `downloadFile` native method `downloadFile` intent will be used by `cozy-client/models/file` in order to download files through Flagship app --- packages/cozy-intent/src/api/models/methods.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cozy-intent/src/api/models/methods.ts b/packages/cozy-intent/src/api/models/methods.ts index 4182153530..61447cc71b 100644 --- a/packages/cozy-intent/src/api/models/methods.ts +++ b/packages/cozy-intent/src/api/models/methods.ts @@ -27,6 +27,7 @@ interface _NativeMethodsRegister { openAppOSSettings: () => Promise isAvailable: (featureName: string) => Promise flagshipLinkRequest: (operation: unknown) => Promise + downloadFile: (file: unknown) => Promise } export type NativeMethodsRegister = _NativeMethodsRegister & PostMeDefault From cf2cdcbbe5ed80e2a74ec465af86c0fde3e75224 Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Mon, 26 Aug 2024 17:58:08 +0200 Subject: [PATCH 3/3] feat(cozy-device-helper): Add `isFlagshipOfflineSupported()` method 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 --- packages/cozy-device-helper/src/flagship.ts | 4 ++++ packages/cozy-device-helper/src/index.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cozy-device-helper/src/flagship.ts b/packages/cozy-device-helper/src/flagship.ts index 80730fc610..8814d7ccbc 100644 --- a/packages/cozy-device-helper/src/flagship.ts +++ b/packages/cozy-device-helper/src/flagship.ts @@ -16,6 +16,7 @@ export interface FlagshipMetadata { biometry_type?: BiometryType immersive?: boolean navbarHeight?: number + offline_available?: boolean platform?: Record route?: FlagshipRoutes settings_PINEnabled?: boolean @@ -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 diff --git a/packages/cozy-device-helper/src/index.ts b/packages/cozy-device-helper/src/index.ts index b15dcb51b5..ca921f2fb8 100644 --- a/packages/cozy-device-helper/src/index.ts +++ b/packages/cozy-device-helper/src/index.ts @@ -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'