Skip to content

Commit b1905e3

Browse files
committed
Adapt types to new SDK types
1 parent e6ae878 commit b1905e3

11 files changed

Lines changed: 23 additions & 26 deletions

File tree

src/components/modals/DriveItemInfoModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function DriveItemInfoModal(): JSX.Element {
101101
{
102102
dbItemId: dbItem?.id || item.id,
103103
id: isFolder ? item.id.toString() : (item.fileId as string),
104-
uuid: item?.uuid,
104+
uuid: item.uuid,
105105
type: isFolder ? 'folder' : 'file',
106106
},
107107
],

src/contexts/Drive/Drive.context.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export const DriveContextProvider: React.FC<DriveContextProviderProps> = ({ chil
151151
uuid: folder.uuid,
152152
id: folder.id,
153153
userId: folder.userId,
154-
// @ts-expect-error - API is returning status, missing from SDK
155154
status: folder.status,
156155
}),
157156
),
@@ -167,9 +166,11 @@ export const DriveContextProvider: React.FC<DriveContextProviderProps> = ({ chil
167166
createdAt: file.createdAt.toString(),
168167
updatedAt: file.updatedAt.toString(),
169168
deletedAt: null,
169+
deleted: false,
170170
status: file.status,
171-
size: typeof file.size === 'bigint' ? Number(file.size) : file.size,
171+
size: Number(file.size),
172172
folderId: file.folderId,
173+
// @ts-expect-error - API is returning status, missing from SDK
173174
thumbnails: file.thumbnails ?? [],
174175
}),
175176
),

src/helpers/driveItems.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ describe('Drive item classification', () => {
339339
size: 2048,
340340
updatedAt: '2025-12-18T00:00:00Z',
341341
isFolder: false,
342+
uuid: 'file-uuid',
342343
};
343344

344345
expect(checkIsFile(focusedFile)).toBe(true);
@@ -352,6 +353,7 @@ describe('Drive item classification', () => {
352353
parentUuid: 'parent-uuid',
353354
updatedAt: '2025-12-18T00:00:00Z',
354355
isFolder: true,
356+
uuid: 'folder-uuid',
355357
};
356358

357359
expect(checkIsFile(focusedFolder)).toBe(false);

src/hooks/useDriveItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const useDriveItem = (props: UseDriveItemProps) => {
6161
dispatch(
6262
driveActions.setFocusedItem({
6363
...props.data,
64-
uuid: props.data.uuid ?? undefined,
64+
uuid: props.data.uuid,
6565
folderUuid: props.data.folderUuid ?? undefined,
6666
bucket: props.data?.bucket ?? undefined,
6767
shareId: props.data.shareId,

src/screens/drive/DriveFolderScreen/search/GlobalSearchModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export const GlobalSearchModal: React.FC<GlobalSearchModalProps> = ({ visible, o
131131
isFolder: false,
132132
currentThumbnail: null,
133133
id: fileMeta.id,
134+
// @ts-expect-error thumbnails missinig in type in SDK
134135
thumbnails: fileMeta.thumbnails ?? [],
135136
parentId: fileMeta.folderId,
136137
},
@@ -148,13 +149,14 @@ export const GlobalSearchModal: React.FC<GlobalSearchModalProps> = ({ visible, o
148149
updatedAt: driveFileData.data.updatedAt,
149150
isFolder: driveFileData.data.isFolder,
150151
bucket: driveFileData.data.bucket,
152+
fileId: driveFileData.data.fileId ?? undefined,
151153
}),
152154
);
153155
const thunk = dispatch(
154156
driveThunks.downloadFileThunk({
155157
...driveFileData,
156158
bucketId: driveFileData.data.bucket as string,
157-
size: driveFileData.data.size as number,
159+
size: driveFileData.data.size as unknown as number,
158160
parentId: driveFileData.data.parentId as number,
159161
name: driveFileData.data.name ?? '',
160162
type: driveFileData.data.type as string,

src/services/drive/database/driveLocalDB.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface DriveRowItem {
2020
encrypt_version: string;
2121
parentId: number | null;
2222
parentUuid?: string;
23-
fileId?: string;
23+
fileId?: string | null;
2424
folderUuid?: string;
2525
icon: string | null;
2626
size?: number;

src/services/drive/file/utils/uploadFileUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export async function uploadSingleFile(
250250
if (!bucketId) {
251251
throw new BucketNotFoundError();
252252
}
253-
console.log('Creating file entry for empty file:', file);
253+
254254
await createEmptyFileEntry(bucketId, file);
255255
} else {
256256
await uploadFile(file, 'document');

src/services/drive/trash/driveTrash.service.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SdkManager } from '@internxt-mobile/services/common';
2-
import { AddItemsToTrashPayload, FetchTrashContentResponse } from '@internxt/sdk/dist/drive/storage/types';
2+
import { FetchTrashContentResponse } from '@internxt/sdk/dist/drive/storage/types';
33
import { DeleteItemsPermanentlyPayload } from '@internxt/sdk/dist/drive/trash/types';
44
import { mapTrashFile, mapTrashFolder } from '../../../helpers/driveItemMappers';
55
import { driveFileService } from '../file';
@@ -81,22 +81,14 @@ class DriveTrashService {
8181
return this.sdk.trash.clearTrash();
8282
}
8383

84-
public async moveToTrash(items: { id: number | string; type: 'folder' | 'file'; uuid?: string }[]) {
84+
public async moveToTrash(items: { id: number | string; type: 'folder' | 'file'; uuid: string }[]) {
8585
const itemsToMove = items.map((item) => {
86-
if (item.uuid !== undefined) {
87-
return {
88-
id: null,
89-
uuid: item.uuid,
90-
type: item.type,
91-
};
92-
}
93-
9486
return {
95-
id: item.id,
87+
uuid: item.uuid,
9688
type: item.type,
9789
};
9890
});
99-
return this.sdk.trash.addItemsToTrash({ items: itemsToMove } as AddItemsToTrashPayload);
91+
return this.sdk.trash.addItemsToTrash({ items: itemsToMove });
10092
}
10193
}
10294

src/types/drive.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface DriveNavigationStackItem {
2929
}
3030
export type DriveNavigationStack = DriveNavigationStackItem[];
3131

32-
export type DriveItemData = DriveFileData & DriveFolderData & { uuid?: string; isFolder: boolean };
32+
export type DriveItemData = DriveFileData & DriveFolderData & { uuid: string; isFolder: boolean };
3333

3434
export type DriveFile = DriveFileData & { uuid?: string; isFolder: boolean };
3535

@@ -41,7 +41,7 @@ export type DriveItemFocused = {
4141
parentId?: number;
4242
parentUuid?: string;
4343
folderUuid?: string;
44-
fileId?: string;
44+
fileId?: string | null;
4545
type?: string;
4646
size?: string | number;
4747
updatedAt: string;
@@ -52,7 +52,7 @@ export type DriveItemFocused = {
5252
isFromFolderActions?: boolean;
5353
isFolder: boolean;
5454
bucket?: string;
55-
uuid?: string;
55+
uuid: string;
5656
thumbnails?: Thumbnail[];
5757
} | null;
5858

@@ -162,7 +162,7 @@ export type DriveItemDataProps = Pick<
162162
isFolder: boolean;
163163
folderId?: number;
164164
folderUuid?: string | null;
165-
fileId?: string;
165+
fileId?: string | null;
166166
parentId?: number | null;
167167
parentUuid?: string;
168168
code?: string;
@@ -171,7 +171,7 @@ export type DriveItemDataProps = Pick<
171171
type?: string;
172172
shareId?: string;
173173
thumbnail?: DownloadedThumbnail;
174-
uuid?: string;
174+
uuid: string;
175175
bucket?: string | null;
176176
};
177177

src/useCases/drive/getShareLink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const generateShareLink = async ({
106106
plainPassword,
107107
}: {
108108
itemId: string;
109-
fileId?: string;
109+
fileId?: string | null;
110110
plainPassword?: string;
111111
displayCopyNotification?: boolean;
112112
type: 'file' | 'folder';

0 commit comments

Comments
 (0)