🩹 back,front: when moving an item, check for a new available name (#706)

This commit is contained in:
Eric Doughty-Papassideris
2024-10-24 18:05:19 +02:00
committed by ericlinagora
parent e07ddf5197
commit d0609f7fc7
7 changed files with 19 additions and 2 deletions
@@ -138,9 +138,11 @@ export const useDriveActions = (inPublicSharing?: boolean) => {
);
const update = useCallback(
async (update: Partial<DriveItem>, id: string, parentId: string) => {
async (update: Partial<DriveItem>, id: string, parentId: string, previousName?: string) => {
try {
await DriveApiClient.update(companyId, id, update);
const newItem = await DriveApiClient.update(companyId, id, update);
if (previousName && previousName !== newItem.name && !update.name)
ToasterService.warn(Languages.t('hooks.use-drive-actions.update_caused_a_rename', [previousName, newItem.name]));
await refresh(id || '', true);
if (!inPublicSharing) await refresh(parentId || '', true);
if (update?.parent_id !== parentId) await refresh(update?.parent_id || '', true);
@@ -148,6 +148,7 @@ export const useOnBuildContextMenu = (
},
item.id,
item.parent_id,
item.name,
);
},
}),