feat: colleciton delete
Some checks failed
Build Test / test (pull_request) Successful in 30s
JS Unit Tests / test (pull_request) Failing after 28s
PHP Unit Tests / test (pull_request) Successful in 1m7s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-05 22:32:52 -04:00
parent 5988a372bc
commit b682b0629c
6 changed files with 74 additions and 11 deletions

View File

@@ -123,8 +123,14 @@ export const collectionService = {
*
* @returns Promise with deletion result
*/
async delete(request: CollectionDeleteRequest): Promise<CollectionDeleteResponse> {
return await transceivePost<CollectionDeleteRequest, CollectionDeleteResponse>('collection.delete', request);
async delete(request: CollectionDeleteRequest): Promise<boolean | CollectionObject> {
const response = await transceivePost<CollectionDeleteRequest, CollectionDeleteResponse>('collection.delete', request);
if (response.outcome === 'moved' && response.data) {
return createCollectionObject(response.data);
}
return true;
},
};

View File

@@ -26,7 +26,6 @@ import type {
EntityStreamRequest,
EntityStreamResponse,
} from '../types/entity';
import type { EntityIdentifier } from '../types/common';
import { useIntegrationStore } from '@KTXC/stores/integrationStore';
import { EntityObject } from '../models';

View File

@@ -385,12 +385,16 @@ export const useCollectionsStore = defineStore('mailCollectionsStore', () => {
*
* @returns Promise with deletion result
*/
async function remove(provider: string, service: string | number, identifier: string | number): Promise<any> {
async function remove(provider: string, service: string | number, identifier: string | number): Promise<CollectionObject | boolean> {
transceiving.value = true
try {
await collectionService.delete({ provider, service, identifier })
const response = await collectionService.delete({ provider, service, identifier })
// Remove deleted collection from state
if (response !== true && !(response instanceof CollectionObject)) {
console.warn('[Mail Manager][Store] - Delete failed. Received unexpected response from delete operation:', response)
return false
}
const key = identifierKey(provider, service, identifier)
const previousCollection = _collections.value[key]
@@ -400,7 +404,19 @@ export const useCollectionsStore = defineStore('mailCollectionsStore', () => {
delete _collections.value[key]
if (response instanceof CollectionObject) {
const movedCollection = response
const movedKey = identifierKey(movedCollection.provider, movedCollection.service, movedCollection.identifier)
_collections.value[movedKey] = movedCollection
indexCollection(movedCollection)
console.debug('[Mail Manager][Store] - Successfully moved collection to trash', key, '->', movedKey)
return response
}
console.debug('[Mail Manager][Store] - Successfully deleted collection:', key)
return response
} catch (error: any) {
console.error('[Mail Manager][Store] - Failed to delete collection:', error)
throw error

View File

@@ -124,5 +124,6 @@ export interface CollectionDeleteRequest {
}
export interface CollectionDeleteResponse {
success: boolean;
outcome: 'deleted' | 'moved';
data?: CollectionInterface | null; // If moved, the new location of the collection
}