Tinacms: Media Manager list not being called after second delete

Created on 28 Oct 2020  ยท  1Comment  ยท  Source: tinacms/tinacms

Description

Hello. When deleting an item in the media list the first time it runs the list function as expected, but not the second time. media:list:start is not fired after a successful second delete.

Steps to reproduce

const media = {
    accept: '*',
    list: (options) =>
        new Promise((resolve) => {
            const _list = async () => {
                const items = await tinaUploadListRefresh({
                    ...options,
                });

                resolve(items?.data?.media_list ?? { items: [] });
            };
            _list();
        }),
    delete: (item) =>
        new Promise((resolve) => {
            const _delete = async () => {
                await deleteTinaUpload({
                    variables: { id: item.id },
                });

                resolve();
            };
            _delete();
        }),
    persist: (files) =>
        new Promise((resolve) => {
            const _add = async () => {
                const item = await addTinaUpload();

                resolve(item.data.tina_upload);
            };
            _add();
        }),
};
const cms = new TinaCMS({
    media,
});

Expected result

Whenever something's deleted it should re-list (in my opinion).

Actual result

First delete triggers a re-list, second does not.

Environment

Tinacms Package Versions

โ”œโ”€โ”ฌ [email protected]
โ”œโ”€โ”ฌ [email protected]
โ”œโ”€โ”ฌ [email protected]
โ”œโ”€โ”ฌ UNMET PEER DEPENDENCY [email protected]
โ”‚ โ”œโ”€โ”€ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”€ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”€ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”€ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”€ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”€ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”‚ โ”œโ”€โ”ฌ @tinacms/[email protected]
โ”œโ”€โ”ฌ [email protected]
โ”œโ”€โ”ฌ [email protected]

Tools

| Tool | Version |
| ------- | ------- |
| browser | Chrome |
| os | Mac 10.15.7 |
| node | 14.5 |
| npm | 6.14.5 |

bug

Most helpful comment

After opening this I rearranged my setup (React code) to create my TinaCms instance only once in a useEffect, whereas before it was creating a new instance every render, and it works as expected now.

>All comments

After opening this I rearranged my setup (React code) to create my TinaCms instance only once in a useEffect, whereas before it was creating a new instance every render, and it works as expected now.

Was this page helpful?
0 / 5 - 0 ratings