static-cms
static-cms copied to clipboard
[refactor proposal] Separate existing and draft media
The useMediaFiles
hook and other media management code is a mess, especially because the behaviour is very different between the media library tab and the draft entry editor.
To make it easier to maintain, I propose to separate 'media files' which already exist in a folder and are being retrieved from the backend, and 'media operations', which contain file replacement, creation and deletion.
This would consist of the following changes:
- add
mediaOperations
toEntry
interface - simplify
useMediaFiles
to a unified method - implement a method to put mediaFiles and mediaOperations together
- refactor creation, deletion and replacement behaviour -> possibility: implement "draft deleting" inside entries, batch media operations
I would try to implement this refactor, but first I want to know what you think about it @KaneFreeman
That sounds like a good approach to me.