Shared with me browser integration (#84)

This commit is contained in:
Montassar Ghanmy
2023-06-21 15:25:11 +01:00
committed by GitHub
parent 19b2d7d009
commit 4bef09abff
8 changed files with 175 additions and 33 deletions
@@ -1,11 +1,11 @@
import { ToasterService } from '@features/global/services/toaster-service';
import useRouterCompany from '@features/router/hooks/use-router-company';
import { useCallback } from 'react';
import { useRecoilCallback } from 'recoil';
import { useRecoilValue, useRecoilCallback } from 'recoil';
import { DriveApiClient } from '../api-client/api-client';
import { DriveItemAtom, DriveItemChildrenAtom } from '../state/store';
import { DriveItem, DriveItemVersion } from '../types';
import { BrowseFilter, DriveItem, DriveItemVersion } from '../types';
import { SharedWithMeFilterState } from '../state/shared-with-me-filter';
/**
* Returns the children of a drive item
* @param id
@@ -13,13 +13,18 @@ import { DriveItem, DriveItemVersion } from '../types';
*/
export const useDriveActions = () => {
const companyId = useRouterCompany();
const sharedFilter = useRecoilValue(SharedWithMeFilterState);
const refresh = useRecoilCallback(
({ set, snapshot }) =>
async (parentId: string) => {
if (parentId) {
const filter:BrowseFilter = {
company_id: companyId,
mime_type: sharedFilter.mimeType.value,
};
try {
const details = await DriveApiClient.get(companyId, parentId);
const details = await DriveApiClient.browse(companyId, parentId, filter);
set(DriveItemChildrenAtom(parentId), details.children);
set(DriveItemAtom(parentId), details);
for (const child of details.children) {
@@ -71,8 +71,10 @@ export const useDriveItem = (id: string) => {
);
const inTrash = id === 'trash' || item?.path?.some(i => i.parent_id === 'trash');
const sharedWithMe = id =="shared_with_me";
return {
sharedWithMe,
inTrash,
loading: loading,
children: children || [],