static-cms icon indicating copy to clipboard operation
static-cms copied to clipboard

[refactor proposal] Separate existing and draft media

Open denyskon opened this issue 1 year ago • 1 comments

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 to Entry 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

denyskon avatar Sep 15 '23 04:09 denyskon

That sounds like a good approach to me.

KaneFreeman avatar Sep 15 '23 14:09 KaneFreeman