Skip to content

Commit

Permalink
fix: ShareFiles and OsReceive broken because of intent options
Browse files Browse the repository at this point in the history
With cozy-intent 2.22, local methods receive an option object as
first argument. I forgot to update ShareFiles and OsReceive intents.
Fixed here.
  • Loading branch information
zatteo committed Jun 24, 2024
1 parent 04c2bfa commit e59eb4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/app/domain/osReceive/models/OsReceiveState.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PostMeMessageOptions } from 'cozy-intent'

import { AcceptFromFlagshipManifest } from './OsReceiveCozyApp'

import { ReceivedFile } from '/app/domain/osReceive/models/ReceivedFile'
Expand Down Expand Up @@ -66,11 +68,12 @@ export interface ServiceResponse<T> {

export interface OsReceiveApiMethods {
getFilesToHandle: (
options: PostMeMessageOptions,
base64: boolean,
state: OsReceiveState
) => Promise<OsReceiveFile[]>
hasFilesToHandle: () => Promise<UploadStatus>
uploadFiles: (arg: string) => boolean
uploadFiles: (options: PostMeMessageOptions, arg: string) => boolean
resetFilesToHandle: () => Promise<boolean>
cancelUploadByCozyApp: () => boolean
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/domain/osReceive/models/ShareFiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type CozyClient from 'cozy-client'
import { PostMeMessageOptions } from 'cozy-intent'

export interface ShareFilesDependencies {
showOverlay: (message?: string) => void
Expand All @@ -9,4 +10,7 @@ export interface ShareFilesDependencies {

export type ShareFilesPayload = string[]

export type ShareFilesIntent = (filesIds: ShareFilesPayload) => Promise<void>
export type ShareFilesIntent = (
options: PostMeMessageOptions,
filesIds: ShareFilesPayload
) => Promise<void>
5 changes: 3 additions & 2 deletions src/app/domain/osReceive/services/OsReceiveApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ export const OsReceiveApi = (
dispatch: Dispatch<OsReceiveAction>
): OsReceiveApiMethods => ({
hasFilesToHandle: () => hasFilesToHandle(state),
getFilesToHandle: (base64 = false) => getFilesToHandle(base64, state),
uploadFiles: arg => uploadFiles(arg, state, client, dispatch),
getFilesToHandle: (_options, base64 = false) =>
getFilesToHandle(base64, state),
uploadFiles: (_options, arg) => uploadFiles(arg, state, client, dispatch),
resetFilesToHandle: () => resetFilesToHandle(dispatch),
cancelUploadByCozyApp: () => cancelUploadByCozyApp(dispatch)
})
5 changes: 4 additions & 1 deletion src/app/domain/osReceive/services/shareFilesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
ShareFilesIntent
} from '/app/domain/osReceive/models/ShareFiles'

import { PostMeMessageOptions } from 'cozy-intent'

const downloadFilesInParallel = async (
fileInfos: FileMetadata[],
headers: string
Expand Down Expand Up @@ -116,6 +118,7 @@ export const useShareFiles = (): { shareFiles: ShareFilesIntent } => {
}

return {
shareFiles: filesIds => intentShareFiles(dependencies, filesIds)
shareFiles: (_options: PostMeMessageOptions, filesIds) =>
intentShareFiles(dependencies, filesIds)
}
}

0 comments on commit e59eb4b

Please sign in to comment.