feat: colleciton delete
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user