From 116f2fd279a05d00e4a81e258e8514cb5a883ddd Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 27 Feb 2024 13:56:56 +0530 Subject: [PATCH] refactor: update provider method signatures --- .../src/services/new-workspace/index.ts | 20 +++++++-------- .../src/services/new-workspace/provider.ts | 10 ++++---- .../providers/personal.workspace.ts | 25 ++++++++----------- 3 files changed, 25 insertions(+), 30 deletions(-) diff --git a/packages/hoppscotch-common/src/services/new-workspace/index.ts b/packages/hoppscotch-common/src/services/new-workspace/index.ts index f48e749be..c1c370b10 100644 --- a/packages/hoppscotch-common/src/services/new-workspace/index.ts +++ b/packages/hoppscotch-common/src/services/new-workspace/index.ts @@ -479,7 +479,7 @@ export class NewWorkspaceService extends Service { public async reorderRESTCollection( collectionHandle: HandleRef, - destinationCollectionIndex: string | null + destinationCollectionID: string | null ): Promise< E.Either, void> > { @@ -497,7 +497,7 @@ export class NewWorkspaceService extends Service { const result = await provider.reorderRESTCollection( collectionHandle, - destinationCollectionIndex + destinationCollectionID ) if (E.isLeft(result)) { @@ -509,7 +509,7 @@ export class NewWorkspaceService extends Service { public async moveRESTCollection( collectionHandle: HandleRef, - destinationCollectionIndex: string | null + destinationCollectionID: string | null ): Promise< E.Either, void> > { @@ -527,7 +527,7 @@ export class NewWorkspaceService extends Service { const result = await provider.moveRESTCollection( collectionHandle, - destinationCollectionIndex + destinationCollectionID ) if (E.isLeft(result)) { @@ -539,8 +539,8 @@ export class NewWorkspaceService extends Service { public async reorderRESTRequest( requestHandle: HandleRef, - destinationCollectionIndex: string, - destinationRequestIndex: string | null + destinationCollectionID: string, + destinationRequestID: string | null ): Promise< E.Either, void> > { @@ -558,8 +558,8 @@ export class NewWorkspaceService extends Service { const result = await provider.reorderRESTRequest( requestHandle, - destinationCollectionIndex, - destinationRequestIndex + destinationCollectionID, + destinationRequestID ) if (E.isLeft(result)) { @@ -571,7 +571,7 @@ export class NewWorkspaceService extends Service { public async moveRESTRequest( requestHandle: HandleRef, - destinationCollectionIndex: string + destinationCollectionID: string ): Promise< E.Either, void> > { @@ -589,7 +589,7 @@ export class NewWorkspaceService extends Service { const result = await provider.moveRESTRequest( requestHandle, - destinationCollectionIndex + destinationCollectionID ) if (E.isLeft(result)) { diff --git a/packages/hoppscotch-common/src/services/new-workspace/provider.ts b/packages/hoppscotch-common/src/services/new-workspace/provider.ts index 2633fcf70..af34b5f07 100644 --- a/packages/hoppscotch-common/src/services/new-workspace/provider.ts +++ b/packages/hoppscotch-common/src/services/new-workspace/provider.ts @@ -89,19 +89,19 @@ export interface WorkspaceProvider { reorderRESTCollection( collectionHandle: HandleRef, - destinationCollectionIndex: string | null + destinationCollectionID: string | null ): Promise> moveRESTCollection( collectionHandle: HandleRef, - destinationCollectionIndex: string | null + destinationCollectionID: string | null ): Promise> reorderRESTRequest( requestHandle: HandleRef, - destinationCollectionIndex: string, - destinationRequestIndex: string | null + destinationCollectionID: string, + destinationRequestID: string | null ): Promise> moveRESTRequest( requestHandle: HandleRef, - destinationCollectionIndex: string + destinationCollectionID: string ): Promise> } diff --git a/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts b/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts index ddfa549a2..3a50ce857 100644 --- a/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts +++ b/packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts @@ -490,7 +490,7 @@ export class PersonalWorkspaceProviderService public reorderRESTCollection( collectionHandle: HandleRef, - destinationCollectionIndex: string | null + destinationCollectionID: string | null ): Promise> { if ( collectionHandle.value.type !== "ok" || @@ -502,17 +502,14 @@ export class PersonalWorkspaceProviderService const draggedCollectionIndex = collectionHandle.value.data.collectionID - updateRESTCollectionOrder( - draggedCollectionIndex, - destinationCollectionIndex - ) + updateRESTCollectionOrder(draggedCollectionIndex, destinationCollectionID) return Promise.resolve(E.right(undefined)) } public moveRESTCollection( collectionHandle: HandleRef, - destinationCollectionIndex: string | null + destinationCollectionID: string | null ): Promise> { if ( collectionHandle.value.type !== "ok" || @@ -524,7 +521,7 @@ export class PersonalWorkspaceProviderService moveRESTFolder( collectionHandle.value.data.collectionID, - destinationCollectionIndex + destinationCollectionID ) return Promise.resolve(E.right(undefined)) @@ -532,8 +529,8 @@ export class PersonalWorkspaceProviderService public reorderRESTRequest( requestHandle: HandleRef, - destinationCollectionIndex: string, - destinationRequestIndex: string | null + destinationCollectionID: string, + destinationRequestID: string | null ): Promise> { if ( requestHandle.value.type !== "ok" || @@ -547,10 +544,8 @@ export class PersonalWorkspaceProviderService updateRESTRequestOrder( this.pathToLastIndex(draggedRequestIndex), - destinationRequestIndex - ? this.pathToLastIndex(destinationRequestIndex) - : null, - destinationCollectionIndex + destinationRequestID ? this.pathToLastIndex(destinationRequestID) : null, + destinationCollectionID ) return Promise.resolve(E.right(undefined)) @@ -558,7 +553,7 @@ export class PersonalWorkspaceProviderService public moveRESTRequest( requestHandle: HandleRef, - destinationCollectionIndex: string + destinationCollectionID: string ): Promise> { if ( requestHandle.value.type !== "ok" || @@ -577,7 +572,7 @@ export class PersonalWorkspaceProviderService moveRESTRequest( parentCollectionIndexPath, this.pathToLastIndex(requestIndex), - destinationCollectionIndex + destinationCollectionID ) return Promise.resolve(E.right(undefined))