migrate deleted-collection to remove undefined values

This commit is contained in:
Abhinav 2023-02-01 09:52:48 +05:30
parent 36fda1ae1d
commit d176212a05

View file

@ -30,7 +30,13 @@ export async function getLocalTrash() {
export async function getLocalDeletedCollections() { export async function getLocalDeletedCollections() {
const trashedCollections: Array<Collection> = const trashedCollections: Array<Collection> =
(await localForage.getItem<Collection[]>(DELETED_COLLECTION)) || []; (await localForage.getItem<Collection[]>(DELETED_COLLECTION)) || [];
return trashedCollections; const nonUndefinedCollections = trashedCollections.filter(
(collection) => !!collection
);
if (nonUndefinedCollections.length !== trashedCollections.length) {
await localForage.setItem(DELETED_COLLECTION, nonUndefinedCollections);
}
return nonUndefinedCollections;
} }
export async function cleanTrashCollections(fileTrash: Trash) { export async function cleanTrashCollections(fileTrash: Trash) {