🐛 Fixing pagination for "Shared with me"/ES (#778)
This commit is contained in:
@@ -70,7 +70,13 @@ export class DriveApiClient {
|
||||
);
|
||||
}
|
||||
|
||||
static async browse(companyId: string, id: string | 'trash' | '', filter: BrowseFilter, sort: BrowseSort, paginate: BrowsePaginate) {
|
||||
static async browse(
|
||||
companyId: string,
|
||||
id: string | 'trash' | '',
|
||||
filter: BrowseFilter,
|
||||
sort: BrowseSort,
|
||||
paginate: BrowsePaginate,
|
||||
) {
|
||||
return await Api.post<BrowseQuery, DriveItemDetails>(
|
||||
`/internal/services/documents/v1/companies/${companyId}/browse/${id}${appendTdriveToken()}`,
|
||||
{
|
||||
@@ -79,7 +85,10 @@ export class DriveApiClient {
|
||||
paginate: {
|
||||
page_token: paginate.page.toString(),
|
||||
limitStr: paginate.limit.toString(),
|
||||
}
|
||||
},
|
||||
nextPage: {
|
||||
page_token: paginate.nextPage?.page_token || '',
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -93,7 +102,7 @@ export class DriveApiClient {
|
||||
static async restore(companyId: string, id: string | 'trash' | '') {
|
||||
return await Api.post<any, any>(
|
||||
`/internal/services/documents/v1/companies/${companyId}/item/${id}/restore${appendTdriveToken()}`,
|
||||
{}
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,13 +120,10 @@ export class DriveApiClient {
|
||||
if (!data.version) data.version = {} as Partial<DriveItemVersion>;
|
||||
|
||||
return new Promise<DriveItem>((resolve, reject) => {
|
||||
Api.post<
|
||||
{ item: Partial<DriveItem>; version: Partial<DriveItemVersion> },
|
||||
DriveItem
|
||||
>(
|
||||
Api.post<{ item: Partial<DriveItem>; version: Partial<DriveItemVersion> }, DriveItem>(
|
||||
`/internal/services/documents/v1/companies/${companyId}/item${appendTdriveToken()}`,
|
||||
data as { item: Partial<DriveItem>; version: Partial<DriveItemVersion> },
|
||||
(res) => {
|
||||
res => {
|
||||
if ((res as any)?.statusCode || (res as any)?.error) {
|
||||
reject(res);
|
||||
}
|
||||
@@ -151,7 +157,9 @@ export class DriveApiClient {
|
||||
|
||||
static getDownloadUrl(companyId: string, id: string, versionId?: string) {
|
||||
if (versionId)
|
||||
return Api.route(`/internal/services/documents/v1/companies/${companyId}/item/${id}/download?version_id=${versionId}`);
|
||||
return Api.route(
|
||||
`/internal/services/documents/v1/companies/${companyId}/item/${id}/download?version_id=${versionId}`,
|
||||
);
|
||||
return Api.route(`/internal/services/documents/v1/companies/${companyId}/item/${id}/download`);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
DriveItemPagination,
|
||||
DriveItemSort,
|
||||
} from '../state/store';
|
||||
import { BrowseFilter, DriveItem, DriveItemVersion } from '../types';
|
||||
import { BrowseFilter, DriveItem, DriveItemDetails, DriveItemVersion } from '../types';
|
||||
import { SharedWithMeFilterState } from '../state/shared-with-me-filter';
|
||||
import Languages from 'features/global/services/languages-service';
|
||||
import { useUserQuota } from 'features/users/hooks/use-user-quota';
|
||||
@@ -70,11 +70,12 @@ export const useDriveActions = (inPublicSharing?: boolean) => {
|
||||
let pagination = await snapshot.getPromise(DriveItemPagination);
|
||||
|
||||
if (resetPagination) {
|
||||
pagination = { page: 0, limit: pagination.limit };
|
||||
pagination = { page: 0, limit: pagination.limit, nextPage: pagination.nextPage };
|
||||
set(DriveItemPagination, pagination);
|
||||
}
|
||||
let details: DriveItemDetails | undefined;
|
||||
try {
|
||||
const details = await DriveApiClient.browse(
|
||||
details = await DriveApiClient.browse(
|
||||
companyId,
|
||||
parentId,
|
||||
filter,
|
||||
@@ -94,7 +95,13 @@ export const useDriveActions = (inPublicSharing?: boolean) => {
|
||||
} catch (e) {
|
||||
ToasterService.error(Languages.t('hooks.use-drive-actions.unable_load_file'));
|
||||
} finally {
|
||||
set(DriveItemPagination, { page: pagination.limit, limit: pagination.limit });
|
||||
set(DriveItemPagination, {
|
||||
page: pagination.limit,
|
||||
limit: pagination.limit,
|
||||
nextPage: {
|
||||
page_token: details?.nextPage?.page_token || '',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -11,9 +11,9 @@ export const DriveItemAtom = atomFamily<Partial<DriveItemDetails> | null, string
|
||||
default: () => null,
|
||||
});
|
||||
|
||||
export const DriveItemSelectedList = atom<{[key: string]: boolean }>({
|
||||
export const DriveItemSelectedList = atom<{ [key: string]: boolean }>({
|
||||
key: 'DriveItemSelectedList',
|
||||
default: {}
|
||||
default: {},
|
||||
});
|
||||
|
||||
export const DriveItemSort = atom<BrowseSort>({
|
||||
|
||||
@@ -5,6 +5,9 @@ export type BrowseQuery = {
|
||||
page_token: string;
|
||||
limitStr: string;
|
||||
};
|
||||
nextPage?: {
|
||||
page_token: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type BrowseFilter = {
|
||||
@@ -21,6 +24,9 @@ export type BrowsePaginate = {
|
||||
page: number;
|
||||
limit: number;
|
||||
lastPage?: boolean;
|
||||
nextPage?: {
|
||||
page_token: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type DriveItemDetails = {
|
||||
@@ -33,6 +39,9 @@ export type DriveItemDetails = {
|
||||
room: string;
|
||||
token?: string;
|
||||
}[];
|
||||
nextPage?: {
|
||||
page_token: string;
|
||||
}
|
||||
};
|
||||
|
||||
export type DriveItem = {
|
||||
|
||||
@@ -137,7 +137,6 @@ export default memo(
|
||||
useEffect(() => {
|
||||
setChecked({});
|
||||
refresh(parentId);
|
||||
if (!inPublicSharing) refresh('trash');
|
||||
}, [parentId, refresh, filter]);
|
||||
|
||||
const uploadItemModal = useCallback(() => {
|
||||
|
||||
Reference in New Issue
Block a user